support Android SDK build-tools apksigner v35/v36; fix #96 - #109
Open
XenoAmess wants to merge 4 commits into
Open
support Android SDK build-tools apksigner v35/v36; fix #96#109XenoAmess wants to merge 4 commits into
XenoAmess wants to merge 4 commits into
Conversation
ZipDiff saves the target's local file header info (local header offset + local header extra field, per entry) into a new diff format tag ZiPat2&, whenever the local header extra differs from the central directory extra (apksigner v35 writes a 0xd935 alignment extra field only in the local header when re-aligning uncompressed files). ZipPatch then writes local headers byte-verbatim at their saved offsets, so the patched apk is byte-by-byte equal for apksigner v35 signed apks. Old ZiPat1& diffs stay unchanged for v34/unaligned targets and remain readable by old ZipPatch; new v1.9.0 ZipPatch reads both formats. Also fix UnZipper_getHugePageAlign for the v35 layout and add a v34/v35 apksigner round-trip test to CI.
…s: note v36 support;
Author
|
do you have any ohter test cases we shall cover for this? I can also try adding them into the ci. |
Owner
|
非常感谢你的PR,它解决了库对新版本apksigner的兼容问题,这对有需求或新采纳这个方案的团队很有帮助。 我也考虑过修复这个和apksigner的兼容问题,但因为要求升级patcher端,所以就想对ApkDiffPatch进行一次更大范围的更新(v2.0),一并解决本库已知的其他设计问题:
|
Author
(原来这边说中文啊!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #96: support Android SDK build-tools apksigner v35 (and later v36).
Root cause
apksigner v35+ re-aligns uncompressed ZIP entries while signing and writes a
dedicated
0xd935alignment extra field only in the local file header (thecentral directory keeps the pre-signing extra fields). This breaks the
local header extra == central directory extrainvariant that ZipPatch'sreconstruction relies on, so the patched APK was not byte-by-byte equal to the
released (re-signed) APK.
Fix
ZipDiffnow saves the target's local file header info (local headeroffset + local header extra field, per entry) into the diff, using a new
diff format tag
ZiPat2&, whenever the local header extra differs fromthe central directory extra (i.e. apksigner v35/v36-signed targets).
ZipPatchwrites those local headers byte-verbatim at their saved offsets,so the patched APK is byte-by-byte equal.
ZiPat1&diffs stay unchanged for v34 / not-re-signed targets, so oldZipPatch keeps working for them; new v1.9.0+ ZipPatch reads both formats.
Old ZipPatch cleanly rejects
ZiPat2&(version check), never silentlycorrupting.
UnZipper_getHugePageAlignfor the v35 layout (local header lengthderived when CD extra != local extra).
Tests
builds/apksigner_roundtrip_test.sh+ CI jobapksigner-roundtrip-testrunning
ApkNormalized -> apksigner -> ZipDiff -> ZipPatchround-trips forbuild-tools 34.0.0 / 35.0.0 / 36.1.0, verifying the patched APK is
byte-by-byte equal and its signature verifies.
ZiPat1&(legacy, old tools compatible)ZiPat2&(new format)Backward compatibility matrix is documented in
docs/issue-96-fix-plan.md.