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
This commit is contained in:
parent
2b526bf7f3
commit
ead7b66590
|
@ -1,5 +1,6 @@
|
||||||
# Handle AndroidManifest.xmls
|
# Handle AndroidManifest.xmls
|
||||||
# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES
|
# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES,
|
||||||
|
# LOCAL_USE_EMBEDDED_NATIVE_LIBS
|
||||||
# Output: full_android_manifest
|
# Output: full_android_manifest
|
||||||
|
|
||||||
ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
|
ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
|
||||||
|
@ -65,6 +66,18 @@ ifeq (true,$(LOCAL_USE_EMBEDDED_DEX))
|
||||||
my_manifest_fixer_flags += --use-embedded-dex
|
my_manifest_fixer_flags += --use-embedded-dex
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(LOCAL_MODULE_CLASS),APPS)
|
||||||
|
ifeq (true,$(call math_gt_or_eq,$(patsubst $(PLATFORM_VERSION_CODENAME),100,$(call module-min-sdk-version)),23))
|
||||||
|
ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
|
||||||
|
my_manifest_fixer_flags += --extract-native-libs=false
|
||||||
|
else
|
||||||
|
my_manifest_fixer_flags += --extract-native-libs=true
|
||||||
|
endif
|
||||||
|
else ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
|
||||||
|
$(call pretty-error,LOCAL_USE_EMBEDDED_NATIVE_LIBS is set but minSdkVersion $(call module-min-sdk-version) does not support it)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
$(fixed_android_manifest): PRIVATE_MANIFEST_FIXER_FLAGS := $(my_manifest_fixer_flags)
|
$(fixed_android_manifest): PRIVATE_MANIFEST_FIXER_FLAGS := $(my_manifest_fixer_flags)
|
||||||
# These two libs are added as optional dependencies (<uses-library> with
|
# These two libs are added as optional dependencies (<uses-library> with
|
||||||
# android:required set to false). This is because they haven't existed in pre-P
|
# android:required set to false). This is because they haven't existed in pre-P
|
||||||
|
|
|
@ -211,6 +211,7 @@ LOCAL_PREBUILT_OBJ_FILES:=
|
||||||
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
|
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
|
||||||
LOCAL_PREBUILT_STRIP_COMMENTS:=
|
LOCAL_PREBUILT_STRIP_COMMENTS:=
|
||||||
LOCAL_USE_EMBEDDED_DEX:=
|
LOCAL_USE_EMBEDDED_DEX:=
|
||||||
|
LOCAL_USE_EMBEDDED_NATIVE_LIBS:=
|
||||||
LOCAL_PRESUBMIT_DISABLED:=
|
LOCAL_PRESUBMIT_DISABLED:=
|
||||||
LOCAL_PRIVATE_PLATFORM_APIS:=
|
LOCAL_PRIVATE_PLATFORM_APIS:=
|
||||||
LOCAL_PRIVILEGED_MODULE:=
|
LOCAL_PRIVILEGED_MODULE:=
|
||||||
|
|
|
@ -2275,24 +2275,15 @@ $(hide) cp $(3) $(dir $(1))lib/$(2)
|
||||||
|
|
||||||
endef
|
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
|
# $(1): the package file
|
||||||
|
# $(2): if true, uncompress jni libs
|
||||||
define create-jni-shared-libs-package
|
define create-jni-shared-libs-package
|
||||||
rm -rf $(dir $(1))lib
|
rm -rf $(dir $(1))lib
|
||||||
mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
|
mkdir -p $(addprefix $(dir $(1))lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
|
||||||
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
|
$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
|
||||||
$(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
|
$(call _add-jni-shared-libs-to-package-per-abi,$(1),$(abi),\
|
||||||
$(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
|
$(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
|
rm -rf $(dir $(1))lib
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -2360,7 +2351,7 @@ $(hide) if ! $(ZIPALIGN) -c $(ZIPALIGN_PAGE_ALIGN_FLAGS) 4 $@ >/dev/null ; then
|
||||||
mv $@ $@.unaligned; \
|
mv $@ $@.unaligned; \
|
||||||
$(ZIPALIGN) \
|
$(ZIPALIGN) \
|
||||||
-f \
|
-f \
|
||||||
$(ZIPALIGN_PAGE_ALIGN_FLAGS) \
|
-p \
|
||||||
4 \
|
4 \
|
||||||
$@.unaligned $@.aligned; \
|
$@.unaligned $@.aligned; \
|
||||||
mv $@.aligned $@; \
|
mv $@.aligned $@; \
|
||||||
|
|
|
@ -332,6 +332,12 @@ ifdef LOCAL_COMPRESSED_MODULE
|
||||||
LOCAL_DEX_PREOPT := false
|
LOCAL_DEX_PREOPT := false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Default to use uncompressed native libraries in APKs if minSdkVersion >= marshmallow
|
||||||
|
ifndef LOCAL_USE_EMBEDDED_NATIVE_LIBS
|
||||||
|
LOCAL_USE_EMBEDDED_NATIVE_LIBS := $(call math_gt_or_eq, \
|
||||||
|
$(patsubst $(PLATFORM_VERSION_CODENAME),100,$(call module-min-sdk-version)),23)
|
||||||
|
endif
|
||||||
|
|
||||||
include $(BUILD_SYSTEM)/android_manifest.mk
|
include $(BUILD_SYSTEM)/android_manifest.mk
|
||||||
|
|
||||||
resource_export_package :=
|
resource_export_package :=
|
||||||
|
@ -612,6 +618,7 @@ $(LOCAL_BUILT_MODULE) : $(intermediates)/strip.sh
|
||||||
$(LOCAL_BUILT_MODULE) : | $(DEXPREOPT_STRIP_DEPS)
|
$(LOCAL_BUILT_MODULE) : | $(DEXPREOPT_STRIP_DEPS)
|
||||||
$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d
|
$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d
|
||||||
endif
|
endif
|
||||||
|
$(LOCAL_BUILT_MODULE): PRIVATE_USE_EMBEDDED_NATIVE_LIBS := $(LOCAL_USE_EMBEDDED_NATIVE_LIBS)
|
||||||
$(LOCAL_BUILT_MODULE):
|
$(LOCAL_BUILT_MODULE):
|
||||||
@echo "target Package: $(PRIVATE_MODULE) ($@)"
|
@echo "target Package: $(PRIVATE_MODULE) ($@)"
|
||||||
rm -rf $@.parts
|
rm -rf $@.parts
|
||||||
|
@ -622,7 +629,7 @@ else # ! LOCAL_USE_AAPT2
|
||||||
$(call create-assets-package,$@.parts/apk.zip)
|
$(call create-assets-package,$@.parts/apk.zip)
|
||||||
endif # LOCAL_USE_AAPT2
|
endif # LOCAL_USE_AAPT2
|
||||||
ifneq ($(jni_shared_libraries),)
|
ifneq ($(jni_shared_libraries),)
|
||||||
$(call create-jni-shared-libs-package,$@.parts/jni.zip)
|
$(call create-jni-shared-libs-package,$@.parts/jni.zip,$(PRIVATE_USE_EMBEDDED_NATIVE_LIBS))
|
||||||
endif
|
endif
|
||||||
ifeq ($(full_classes_jar),)
|
ifeq ($(full_classes_jar),)
|
||||||
# We don't build jar, need to add the Java resources here.
|
# We don't build jar, need to add the Java resources here.
|
||||||
|
|
Loading…
Reference in New Issue