From 2cb52883417510f79b822d62b0c5e1fc1656cf5c Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Sun, 7 Jul 2019 12:39:16 +0900 Subject: [PATCH] Don't use prebuilt_apex when TARGET_FLATTEN_APEX is set to true When the device does not support non-flattened APEX (i.e. TARGET_FLATTEN_APEX is set to true), then ignore the prebuilt_apex modules even when `prefer: true`. Bug: 136251130 Bug: 136662772 Test: build marlin, and check if /system/apex has flattened APEXes Merged-In: I9f3dfefc3bd357d6750fbb1e418937d095720b04 (cherry picked from commit 0a573d798ffa8941b8028e76d0f6a6951863a6e4) Change-Id: I9f3dfefc3bd357d6750fbb1e418937d095720b04 --- android/prebuilt.go | 4 ++++ apex/apex.go | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/android/prebuilt.go b/android/prebuilt.go index ad7c4aa13..b6741531d 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -215,3 +215,7 @@ func (p *Prebuilt) getSingleSourceFieldValue() string { } return value.String() } + +func (p *Prebuilt) SourceExists() bool { + return p.properties.SourceExists +} diff --git a/apex/apex.go b/apex/apex.go index f95bd05df..f7042fc83 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1403,7 +1403,8 @@ type Prebuilt struct { type PrebuiltProperties struct { // the path to the prebuilt .apex file to import. - Source string `blueprint:"mutated"` + Source string `blueprint:"mutated"` + ForceDisable bool `blueprint:"mutated"` Src *string Arch struct { @@ -1432,6 +1433,14 @@ func (p *Prebuilt) installable() bool { } func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { + if ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() && p.prebuilt.SourceExists() { + // If the device is configured to use flattened APEX, don't set + // p.properties.Source so that the prebuilt module (which is + // a non-flattened APEX) is not used. + p.properties.ForceDisable = true + return + } + // This is called before prebuilt_select and prebuilt_postdeps mutators // The mutators requires that src to be set correctly for each arch so that // arch variants are disabled when src is not provided for the arch. @@ -1473,6 +1482,10 @@ func (p *Prebuilt) InstallFilename() string { } func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { + if p.properties.ForceDisable { + return + } + // TODO(jungjw): Check the key validity. p.inputApex = p.Prebuilt().SingleSourcePath(ctx) p.installDir = android.PathForModuleInstall(ctx, "apex")