OSDN Git Service

Store entry alignment information in APK.
authorAlex Klyubin <klyubin@google.com>
Mon, 23 May 2016 21:19:51 +0000 (14:19 -0700)
committerAlex Klyubin <klyubin@google.com>
Tue, 24 May 2016 00:46:18 +0000 (17:46 -0700)
commit26f00cda4b979d7e74db6872990682335b36612b
treec57d855ddd2a7e814a92133480fb245b1c1bd32d
parentac68c28831f3947e47a924cb677b740975dbbc6f
Store entry alignment information in APK.

Data of uncompressed APK entries is often aligned to a multiple of 4
or 4096 in the APK to make it easier to mmap the data. Unfortunately,
the current method for achieving alignment suffers from two issues:
(1) the way it uses the Local File Header extra field is not compliant
with ZIP format (for example, this prevents older versions of Python's
zipfile from reading APKs: https://bugs.python.org/issue14315), and
(2) it does not store information about the alignment multiple in the
APK, making it harder/impossible to preserve the intended alignment
when rearranging entries in the APK.

This change solves these issues by switching to a different method for
aligning data of uncompressed APK entries. Same as before, alignment
is achieved using Local File Header entry field. What's different is
that alignment is achieved by placing a well-formed extensible data
field/block into the extra field. The new field/block contains the
alignment multiple (e.g., 4 or 4096) as well as the necessary padding
(if any). Compared to the original alignment method, the new method
uses 6 more bytes for each uncompressed entry.

Bug: 27461702
Change-Id: I8cffbecc50bf634b28fca5bc39eb23f671961cf9
tools/signapk/src/com/android/signapk/SignApk.java