From 0abc1b484d214a96aa7ebbd8f59af00ef01d2d0e Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Thu, 9 Jan 2020 17:43:39 +0900 Subject: [PATCH] Prevent overridden APEX from being installed even when flattened Previously, both overridden APEX and overriding APEX were installed together when TARGET_FLATTEN_APEX is set to true. This was because the Make modules for flattened APEXes are phony where LOCAL_OVERRIDES_MODULES isn't respected. Fixing the problem by letting apex_manifest.pb for the overriding APEX to override all modules for the overridden APEXes. Bug: 147384966 Test: OVERRIDE_TARGET_FLATTEN_APEX=true m dump-files | grep mediaprovider shows : out/target/product/coral/system/apex/com.google.android.mediaprovider/apex_manifest.pb : out/target/product/coral/system/apex/com.google.android.mediaprovider/apex_pubkey : out/target/product/coral/system/apex/com.google.android.mediaprovider/javalib/framework-mediaprovider.jar : out/target/product/coral/system/apex/com.google.android.mediaprovider/lib64/libfuse.so : out/target/product/coral/system/apex/com.google.android.mediaprovider/priv-app/MediaProvider/MediaProviderGoogle.apk only Change-Id: I6dc3fc7aaee0474cbad9fadbfce765be4b751328 --- apex/androidmk.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apex/androidmk.go b/apex/androidmk.go index b5c533173..734228892 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -151,9 +151,19 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk") } else { fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base()) - // For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex - if a.primaryApexType && fi.builtFile == a.manifestPbOut && len(a.compatSymlinks) > 0 { - fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(a.compatSymlinks, " && ")) + if a.primaryApexType && fi.builtFile == a.manifestPbOut { + // Make apex_manifest.pb module for this APEX to override all other + // modules in the APEXes being overridden by this APEX + var patterns []string + for _, o := range a.overridableProperties.Overrides { + patterns = append(patterns, "%."+o+a.suffix) + } + fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " ")) + + if len(a.compatSymlinks) > 0 { + // For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex + fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(a.compatSymlinks, " && ")) + } } fmt.Fprintln(w, "include $(BUILD_PREBUILT)") }