tools/binary_size/libsupersize/zip_util.py
def MeasureApkSignatureBlock(zip_file):
  """Measures the size of the v2 / v3 signing block.

  Refer to: https://source.android.com/security/apksigning/v2
  """
  # Seek to "end of central directory" struct.
  eocd_offset_from_end = -22 - len(zip_file.comment)
  zip_file.fp.seek(eocd_offset_from_end, os.SEEK_END)
  assert zip_file.fp.read(4) == b'PK\005\006', (
      'failed to find end-of-central-directory')

  # Read out the "start of central directory" offset.
  zip_file.fp.seek(eocd_offset_from_end + 16, os.SEEK_END)
  start_of_central_directory = struct.unpack('<I', zip_file.fp.read(4))[0]

  # Compute the offset after the last zip entry.
  last_info = max(zip_file.infolist(), key=lambda i: i.header_offset)
  last_header_size = (30 + len(last_info.filename) +
                      ReadZipInfoExtraFieldLength(zip_file, last_info))
  end_of_last_file = (last_info.header_offset + last_header_size +
                      last_info.compress_size)
  return start_of_central_directory - end_of_last_file
Measures the size of the v2 / v3 signing block.

  Refer to: https://source.android.com/security/apksigning/v2
  
Measures the size of the v2 / v3 signing block.
Measures the size of the v2 / v3 signing block .
def MeasureApkSignatureBlock(zip_file):
  eocd_offset_from_end = -22 - len(zip_file.comment)
  zip_file.fp.seek(eocd_offset_from_end, os.SEEK_END)
  assert zip_file.fp.read(4) == b'PK\005\006', (
      'failed to find end-of-central-directory')
  zip_file.fp.seek(eocd_offset_from_end + 16, os.SEEK_END)
  start_of_central_directory = struct.unpack('<I', zip_file.fp.read(4))[0]
  last_info = max(zip_file.infolist(), key=lambda i: i.header_offset)
  last_header_size = (30 + len(last_info.filename) +
                      ReadZipInfoExtraFieldLength(zip_file, last_info))
  end_of_last_file = (last_info.header_offset + last_header_size +
                      last_info.compress_size)
  return start_of_central_directory - end_of_last_file
def MeasureApkSignatureBlock ( zip_file ) : eocd_offset_from_end = - 22 - len ( zip_file . comment ) zip_file . fp . seek ( eocd_offset_from_end , os . SEEK_END ) assert zip_file . fp . read ( 4 ) == b'PK\005\006' , ( 'failed to find end-of-central-directory' ) zip_file . fp . seek ( eocd_offset_from_end + 16 , os . SEEK_END ) start_of_central_directory = struct . unpack ( '<I' , zip_file . fp . read ( 4 ) ) [ 0 ] last_info = max ( zip_file . infolist ( ) , key = lambda i : i . header_offset ) last_header_size = ( 30 + len ( last_info . filename ) + ReadZipInfoExtraFieldLength ( zip_file , last_info ) ) end_of_last_file = ( last_info . header_offset + last_header_size + last_info . compress_size ) return start_of_central_directory - end_of_last_file
Measures the size of the v2 / v3 signing block.
Measures the size of the v2 / v3 signing block .
"""Measures the size of the v2 / v3 signing block.

  Refer to: https://source.android.com/security/apksigning/v2
  """ # Seek to "end of central directory" struct. # Read out the "start of central directory" offset. # Compute the offset after the last zip entry.
zip_file