diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 399d9b92f..cebbae9a6 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -639,7 +639,7 @@ func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutator return false } - name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child)) + name := java.ModuleStemForDeapexing(child) if _, ok := tag.(android.RequiresFilesFromPrebuiltApexTag); ok { commonModules = append(commonModules, name) diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 201780175..0ebab4d8c 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -103,8 +103,8 @@ type classpathJar struct { func gatherPossibleApexModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string { set := map[string]struct{}{} for _, name := range contents { - dep := ctx.GetDirectDepWithTag(name, tag) - set[name] = struct{}{} + dep, _ := ctx.GetDirectDepWithTag(name, tag).(android.Module) + set[ModuleStemForDeapexing(dep)] = struct{}{} if m, ok := dep.(ModuleWithStem); ok { set[m.Stem()] = struct{}{} } else { diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 01f60d403..f7e3cb93a 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -726,13 +726,19 @@ func (m *apexNameToApexExportsInfoMap) javaLibraryDexPathOnHost(ctx android.Modu return nil, false } +// Returns the stem of an artifact inside a prebuilt apex +func ModuleStemForDeapexing(m android.Module) string { + bmn, _ := m.(interface{ BaseModuleName() string }) + return bmn.BaseModuleName() +} + // Returns the java libraries exported by the apex for hiddenapi and dexpreopt // This information can come from two mechanisms // 1. New: Direct deps to _selected_ apexes. The apexes return a ApexExportsInfo // 2. Legacy: An edge to java_library or java_import (java_sdk_library) module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes // TODO: b/308174306 - Once all mainline modules have been flagged, drop (2) func getDexJarForApex(ctx android.ModuleContext, pair apexJarModulePair, apexNameToApexExportsInfoMap apexNameToApexExportsInfoMap) android.Path { - if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, pair.apex, android.RemoveOptionalPrebuiltPrefix(pair.jarModule.Name())); found { + if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, pair.apex, ModuleStemForDeapexing(pair.jarModule)); found { return dex } // TODO: b/308174306 - Remove the legacy mechanism