From dff3755a939a4f69475f22a110fa632981e002f5 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Wed, 15 Apr 2015 12:09:32 -0700 Subject: [PATCH] Move package signing after file stripping For dex preopt and JNI library extraction, we should remove the classes.dex and .so files before we sign the APK so that there isn't an entry in the manifest. Prebuilt APKs which are pre-signed will simply not have the files removed. This may cause some system.img bloat, but signature checks make this necessary. Bug: 20247329 Change-Id: I4742d1aa3aa64ab5aea2264304cb8c0bea24f784 --- core/package_internal.mk | 2 +- core/prebuilt_internal.mk | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/package_internal.mk b/core/package_internal.mk index 5dac455e6e..016e23fb58 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -402,12 +402,12 @@ ifeq ($(full_classes_jar),) else $(add-dex-to-package) endif - $(sign-package) ifdef LOCAL_DEX_PREOPT ifneq (nostripping,$(LOCAL_DEX_PREOPT)) $(call dexpreopt-remove-classes.dex,$@) endif endif + $(sign-package) @# Alignment must happen after all other zip operations. $(align-package) diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index d5446190e5..8595bce32f 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -193,16 +193,17 @@ include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk $(built_module) : PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES := $(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES) $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) $(transform-prebuilt-to-target) +ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) + @# Only strip out files if we can re-sign the package. ifdef extracted_jni_libs $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries. endif -ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) - $(sign-package) -endif ifdef LOCAL_DEX_PREOPT ifneq (nostripping,$(LOCAL_DEX_PREOPT)) $(call dexpreopt-remove-classes.dex,$@) endif +endif + $(sign-package) endif $(align-package)