diff --git a/android/apex.go b/android/apex.go index 79ee0a8f8..22cdb2a61 100644 --- a/android/apex.go +++ b/android/apex.go @@ -87,6 +87,9 @@ type ApexInfo struct { // Returns the name of the overridden apex (com.android.foo) BaseApexName string + + // Returns the value of `apex_available_name` + ApexAvailableName string } // AllApexInfo holds the ApexInfo of all apexes that include this module. diff --git a/apex/apex.go b/apex/apex.go index d5776b5de..4dd605544 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1073,6 +1073,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { ApexContents: []*android.ApexContents{apexContents}, TestApexes: testApexes, BaseApexName: mctx.ModuleName(), + ApexAvailableName: proptools.String(a.properties.Apex_available_name), } mctx.WalkDeps(func(child, parent android.Module) bool { if !continueApexDepsWalk(child, parent) { diff --git a/java/dexpreopt.go b/java/dexpreopt.go index f949b123a..b55ef7310 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -209,13 +209,18 @@ func disableSourceApexVariant(ctx android.BaseModuleContext) bool { psi = prebuiltSelectionInfo } }) + // Find the apex variant for this module - var apexVariantsWithoutTestApexes []string + apexVariantsWithoutTestApexes := []string{} if apexInfo.BaseApexName != "" { // This is a transitive dependency of an override_apex - apexVariantsWithoutTestApexes = []string{apexInfo.BaseApexName} + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.BaseApexName) } else { - _, apexVariantsWithoutTestApexes, _ = android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes) + _, variants, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes) + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, variants...) + } + if apexInfo.ApexAvailableName != "" { + apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.ApexAvailableName) } disableSource := false // find the selected apexes