Store native libraries uncompressed and page-aligned - #111
Open
AbhinavKrShukla wants to merge 1 commit into
Open
Store native libraries uncompressed and page-aligned#111AbhinavKrShukla wants to merge 1 commit into
AbhinavKrShukla wants to merge 1 commit into
Conversation
android:extractNativeLibs="false" lets the platform mmap a native library straight out of the APK/AAB instead of extracting a copy to app-private storage at install time, but it only works if the library's zip entry is stored (not deflated) and its data starts on a page boundary. Today every entry except resources.arsc goes through the Deflated path with 4-byte alignment, so that manifest flag isn't reachable. This adds a native-library detection matching both the APK layout (lib/<abi>/*.so) and the AAB base module layout (base/lib/<abi>/*.so, kept generic instead of hardcoding known ABI names) and stores those entries uncompressed with 16 KiB alignment - large enough to satisfy both the traditional 4 KiB page size and the 16 KiB page size newer devices require, so callers don't need to pick per-target-device. Non-native-library files are unaffected: resources.arsc keeps its existing stored/4-byte-aligned handling, everything else still deflates.
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.
android:extractNativeLibs="false"lets the platformmmapa native librarystraight out of the APK/AAB instead of extracting a copy to app-private
storage at install time, but it only works if the library's zip entry is
stored (not deflated) and its data starts on a page boundary. Today every
entry except
resources.arscgoes through theDeflatedpath with 4-bytealignment, so that manifest flag isn't reachable.
This adds native-library detection matching both the APK layout
(
lib/<abi>/*.so) and the AAB base-module layout (base/lib/<abi>/*.so,kept generic instead of hardcoding known ABI names) and stores those
entries uncompressed with 16 KiB alignment — large enough to satisfy both
the traditional 4 KiB page size and the 16 KiB page size newer devices
require.
Non-native-library files are unaffected:
resources.arsckeeps itsexisting stored/4-byte-aligned handling, everything else still deflates.
Tested:
pack-zip(compression method, page alignment,path-matching edge cases for both APK and AAB layouts)
cargo test --workspace --lib --binspasses unmodified(the one pre-existing
pack-apidoctest failure is unrelated — it failsidentically on
mainbefore this change)cargo +nightly fmt --checkcleanthis branch, output still passes real
apksigner verify(v2+v3),zipalign -c, andaapt2 dump packagename