Make manifest and APK agree on uncompressed native libs
Only put uncompressed native libs in an APK if the min_sdk_version
supports it (>= 23, Marshmallow), and set
android:extractNativeLibs="false" in the AndroidManifest.xml so
that the platform won't extract them anyways.
Bug: 117618214
Test: m checkbuild
Change-Id: Iae26e4676c29c68fa3f76187512c82786bfa0522
diff --git a/core/definitions.mk b/core/definitions.mk
index 2aa2aed..4739204 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2275,24 +2275,15 @@
endef
-# For apps_only build, don't uncompress/page-align the jni libraries,
-# because the apk may be run on older platforms that don't support loading jni directly from apk.
-ifdef TARGET_BUILD_APPS
-JNI_COMPRESS_FLAGS :=
-ZIPALIGN_PAGE_ALIGN_FLAGS :=
-else
-JNI_COMPRESS_FLAGS := -L 0
-ZIPALIGN_PAGE_ALIGN_FLAGS := -p
-endif
-
# $(1): the package file
+# $(2): if true, uncompress jni libs
define create-jni-shared-libs-package
rm -rf $(dir $(1))lib
mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
$(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
-$(SOONG_ZIP) $(JNI_COMPRESS_FLAGS) -o $(1) -C $(dir $(1)) -D $(dir $(1))lib
+$(SOONG_ZIP) $(if $(2),-L 0) -o $(1) -C $(dir $(1)) -D $(dir $(1))lib
rm -rf $(dir $(1))lib
endef
@@ -2360,7 +2351,7 @@
mv $@ $@.unaligned; \
$(ZIPALIGN) \
-f \
- $(ZIPALIGN_PAGE_ALIGN_FLAGS) \
+ -p \
4 \
$@.unaligned $@.aligned; \
mv $@.aligned $@; \