From 716e9b686c555ce8b4d0b10c820881a4c04c385c Mon Sep 17 00:00:00 2001 From: Dario Freni Date: Tue, 31 Jul 2018 15:29:13 +0100 Subject: [PATCH] Run appcompat on vendor and product-services. Also add some more relevant information at the beginning of each report, to make triaging of the reports easier. To test this I declared ExactCalculator as LOCAL_PRODUCT_SERVICES_MODULE, and this is the resulting log: """ Package name: com.android.calculator2 Module name in Android tree: ExactCalculator Local path in Android tree: packages/apps/ExactCalculator Install path on aosp_marlin-eng: out/target/product/marlin/system/product-services/app/ExactCalculator/ExactCalculator.apk appcompat.sh output: NOTE: appcompat.sh is still under development. It can report API uses that do not execute at runtime, and reflection uses that do not exist. It can also miss on reflection uses. 1: Reflection light greylist Landroid/os/Bundle;->getIBinder use(s): Landroid/support/v4/app/BundleCompat$BundleCompatBaseImpl;->getBinder(Landroid/os/Bundle;Ljava/lang/String;)Landroid/os/IBinder; 2: Reflection light greylist Landroid/view/View;->mAccessibilityDelegate use(s): Landroid/support/v4/view/ViewCompat$ViewCompatBaseImpl;->hasAccessibilityDelegate(Landroid/view/View;)Z 3: Reflection light greylist Landroid/view/View;->mMinHeight use(s): Landroid/support/v4/view/ViewCompat$ViewCompatBaseImpl;->getMinimumHeight(Landroid/view/View;)I 4: Reflection light greylist Landroid/view/View;->mMinWidth use(s): Landroid/support/v4/view/ViewCompat$ViewCompatBaseImpl;->getMinimumWidth(Landroid/view/View;)I 4 hidden API(s) used: 0 linked against, 4 through reflection 0 in blacklist 0 in dark greylist 4 in light greylist To run an analysis that can give more reflection accesses, but could include false positives, pass the --imprecise flag. """ Test: m (also on internal) Bug: 110073830 Change-Id: I5114f51d1ab163e954fcffb159ef335abc289cf6 --- core/definitions.mk | 23 ++++++++++++++++++++--- core/package_internal.mk | 12 ++++++++++-- core/prebuilt_internal.mk | 12 ++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 351259817..514239bc4 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2547,14 +2547,31 @@ endef ifeq ($(HOST_OS),linux) # Runs appcompat and store logs in $(PRODUCT_OUT)/appcompat +define extract-package +$(if $(filter aapt2, $(1)), \ + $(AAPT2) dump $@ | awk -F ' |=' '/^Package/{print $$3}' >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log &&, \ + $(AAPT) dump badging $@ | awk -F \' '/^package/{print $$2}' >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log &&) +endef +define appcompat-header +$(hide) \ + mkdir -p $(PRODUCT_OUT)/appcompat && \ + rm -f $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + echo -n "Package name: " >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + $(call extract-package, $(1)) \ + echo "Module name in Android tree: $(PRIVATE_MODULE)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + echo "Local path in Android tree: $(PRIVATE_PATH)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + echo "Install path on $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT): $(PRIVATE_INSTALLED_MODULE)" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + echo >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log +endef define run-appcompat $(hide) \ - mkdir -p $(PRODUCT_OUT)/appcompat; \ - art/tools/veridex/appcompat.sh --dex-file=$@ 2>&1 > $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log; + echo "appcompat.sh output:" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \ + art/tools/veridex/appcompat.sh --dex-file=$@ 2>&1 >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log endef else +appcompat-header = run-appcompat = -endif +endif # HOST_OS == linux # Remove dynamic timestamps from packages # diff --git a/core/package_internal.mk b/core/package_internal.mk index 312635fb6..acb128cba 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -592,10 +592,12 @@ else endif endif -# Run veridex on product modules. +# Run veridex on product, product-services and vendor modules. # We skip it for unbundled app builds where we cannot build veridex. module_run_appcompat := -ifdef LOCAL_PRODUCT_MODULE +ifeq (true,$(filter true, \ + $(LOCAL_PRODUCT_MODULE) $(LOCAL_PRODUCT_SERVICES_MODULE) \ + $(LOCAL_VENDOR_MODULE) $(LOCAL_PROPRIETARY_MODULE))) ifeq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK))) # ! unbundled app build module_run_appcompat := true endif @@ -603,6 +605,7 @@ endif ifeq ($(module_run_appcompat),true) $(LOCAL_BUILT_MODULE) : $(call intermediates-dir-for,PACKAGING,veridex,HOST)/veridex.zip +$(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) endif $(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) @@ -647,6 +650,11 @@ ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) endif # Run appcompat before stripping the classes.dex file. ifeq ($(module_run_appcompat),true) +ifeq ($(LOCAL_USE_AAPT2),true) + $(call appcompat-header, aapt2) +else + $(appcompat-header) +endif $(run-appcompat) endif # module_run_appcompat ifdef LOCAL_DEX_PREOPT diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 347e72954..a4bf05559 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -95,10 +95,12 @@ else prebuilt_module_is_dex_javalib := endif -# Run veridex on product modules. +# Run veridex on product, product-services and vendor modules. # We skip it for unbundled app builds where we cannot build veridex. module_run_appcompat := -ifdef LOCAL_PRODUCT_MODULE +ifeq (true,$(filter true, \ + $(LOCAL_PRODUCT_MODULE) $(LOCAL_PRODUCT_SERVICES_MODULE) \ + $(LOCAL_VENDOR_MODULE) $(LOCAL_PROPRIETARY_MODULE))) ifeq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK))) # ! unbundled app build module_run_appcompat := true endif @@ -387,6 +389,7 @@ endif ifeq ($(module_run_appcompat),true) $(built_module) : $(call intermediates-dir-for,PACKAGING,veridex,HOST)/veridex.zip +$(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) endif $(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR) @@ -405,6 +408,11 @@ ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) @# Only strip out files if we can re-sign the package. # Run appcompat before stripping the classes.dex file. ifeq ($(module_run_appcompat),true) +ifeq ($(LOCAL_USE_AAPT2),true) + $(call appcompat-header, aapt2) +else + $(appcompat-header) +endif $(run-appcompat) endif # module_run_appcompat ifdef LOCAL_DEX_PREOPT