Revert "Revert "Make privileged apps always keep uncompressed dex files.""

bug: 30972906
bug: 63920015

Test: doing zipinfo on the produced apks after build.
Test: fugu build

This reverts commit f69441b76b.

Change-Id: I6b029f2044385f3e3fa332091a9244cec79d2474
This commit is contained in:
Nicolas Geoffray 2017-09-19 11:51:45 +00:00
parent 4971146b2b
commit b06c30b480
4 changed files with 32 additions and 0 deletions

View File

@ -659,6 +659,15 @@ $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets)
endif
endif
###########################################################
# Ensure privileged applications always have LOCAL_PRIVILEGED_MODULE
###########################################################
ifndef LOCAL_PRIVILEGED_MODULE
ifneq (,$(filter $(TARGET_OUT_APPS_PRIVILEGED)/% $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)/%,$(my_module_path)))
LOCAL_PRIVILEGED_MODULE := true
endif
endif
###########################################################
## NOTICE files
###########################################################

View File

@ -2717,6 +2717,18 @@ define remove-timestamps-from-package
$(hide) $(ZIPTIME) $@
endef
# Uncompress dex files embedded in an apk.
#
define uncompress-dexs
$(hide) if (zipinfo $@ '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
rm -rf $(dir $@)uncompresseddexs && mkdir $(dir $@)uncompresseddexs; \
unzip $@ '*.dex' -d $(dir $@)uncompresseddexs && \
zip -d $@ '*.dex' && \
( cd $(dir $@)uncompresseddexs && find . -type f | sort | zip -D -X -0 ../$(notdir $@) -@ ) && \
rm -rf $(dir $@)uncompresseddexs; \
fi
endef
# Uncompress shared libraries embedded in an apk.
#
define uncompress-shared-libs

View File

@ -606,6 +606,12 @@ ifneq ($(BUILD_PLATFORM_ZIP),)
@# Keep a copy of apk with classes.dex unstripped
$(hide) cp -f $@ $(dir $@)package.dex.apk
endif # BUILD_PLATFORM_ZIP
ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))
ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
@# No need to align, sign-package below will do it.
$(uncompress-dexs)
endif # LOCAL_PRIVILEGED_MODULE
endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
$(call dexpreopt-remove-classes.dex,$@)
endif

View File

@ -341,6 +341,11 @@ $(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR)
$(transform-prebuilt-to-target)
$(uncompress-shared-libs)
ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))
ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
$(uncompress-dexs)
endif # LOCAL_PRIVILEGED_MODULE
endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS
ifdef LOCAL_DEX_PREOPT
ifneq ($(BUILD_PLATFORM_ZIP),)
@# Keep a copy of apk with classes.dex unstripped