diff --git a/core/Makefile b/core/Makefile index e94939b95..8cc9907f0 100644 --- a/core/Makefile +++ b/core/Makefile @@ -40,7 +40,9 @@ $(foreach cf,$(unique_product_copy_files_pairs), \ $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \ $(if $(filter %.xml,$(_dest)),\ $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\ - $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \ + $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\ + $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \ + $(eval $(call copy-one-file,$(_src),$(_fulldest))))) \ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \ $(eval unique_product_copy_files_destinations += $(_dest)))) unique_product_copy_files_pairs := diff --git a/core/definitions.mk b/core/definitions.mk index 550634b58..34a3f2c0d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2599,6 +2599,14 @@ $(2): $(1) $$(copy-file-to-target) endef +define copy-and-uncompress-dexs +$(2): $(1) $(ZIPALIGN) + @echo "Uncompress dexs in: $$@" + $$(copy-file-to-target) + $$(uncompress-dexs) + $$(align-package) +endef + # Copies many files. # $(1): The files to copy. Each entry is a ':' separated src:dst pair # Evaluates to the list of the dst files (ie suitable for a dependency list) diff --git a/core/java_library.mk b/core/java_library.mk index f93365381..4a7a508f2 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -63,12 +63,16 @@ else # !LOCAL_IS_STATIC_JAVA_LIBRARY $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar) $(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) -$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) +$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN) @echo "target Jar: $(PRIVATE_MODULE) ($@)" $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp) $(call add-dex-to-package-arg,$@.tmp) $(hide) $(ZIPTIME) $@.tmp $(call commit-change-for-toc,$@) +ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE))) + $(uncompress-dexs) + $(align-package) +endif # PRODUCT_LOADED_BY_PRIVILEGED_MODULES .KATI_RESTAT: $(common_javalib.jar) diff --git a/core/package_internal.mk b/core/package_internal.mk index 5a1ef051b..5a3cc0bd4 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -546,7 +546,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package) $(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP) else $(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_LIST := $(all_res_assets) -$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT) +$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT) $(ZIPALIGN) endif @echo "target Package: $(PRIVATE_MODULE) ($@)" ifdef LOCAL_USE_AAPT2 @@ -584,6 +584,9 @@ ifneq (nostripping,$(LOCAL_DEX_PREOPT)) $(call dexpreopt-remove-classes.dex,$@) endif endif +ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE))) + $(uncompress-dexs) +endif # PRODUCT_LOADED_BY_PRIVILEGED_MODULES $(sign-package) ############################### diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 3622c9c60..2b7a92063 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -344,6 +344,10 @@ $(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR) ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)) ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) $(uncompress-dexs) +else + ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE))) + $(uncompress-dexs) + endif # PRODUCT_LOADED_BY_PRIVILEGED_MODULES endif # LOCAL_PRIVILEGED_MODULE endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS ifdef LOCAL_DEX_PREOPT diff --git a/core/product.mk b/core/product.mk index cf622830a..8619f6332 100644 --- a/core/product.mk +++ b/core/product.mk @@ -116,6 +116,7 @@ _product_var_list := \ PRODUCT_SYSTEM_SERVER_APPS \ PRODUCT_SYSTEM_SERVER_JARS \ PRODUCT_DEXPREOPT_SPEED_APPS \ + PRODUCT_LOADED_BY_PRIVILEGED_MODULES \ PRODUCT_VBOOT_SIGNING_KEY \ PRODUCT_VBOOT_SIGNING_SUBKEY \ PRODUCT_VERITY_SIGNING_KEY \ diff --git a/core/product_config.mk b/core/product_config.mk index cd62fb2e4..94e1bc471 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -259,6 +259,7 @@ PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS)) PRODUCT_SYSTEM_SERVER_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_JARS)) PRODUCT_SYSTEM_SERVER_APPS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_APPS)) PRODUCT_DEXPREOPT_SPEED_APPS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEXPREOPT_SPEED_APPS)) +PRODUCT_LOADED_BY_PRIVILEGED_MODULES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOADED_BY_PRIVILEGED_MODULES)) # Find the device that this product maps to. TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)