Convert OtherModuleProvider to generic providers API

Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider
to use the type-safe android.OtherModuleProvider API.

Bug: 316410648
Test: builds
Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
This commit is contained in:
Colin Cross
2023-12-13 13:47:44 -08:00
parent ff694a8c88
commit 313aa5475f
43 changed files with 128 additions and 168 deletions

View File

@@ -861,7 +861,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
prebuiltJniPackages := android.Paths{}
ctx.VisitDirectDeps(func(module android.Module) {
if info, ok := ctx.OtherModuleProvider(module, JniPackageProvider).(JniPackageInfo); ok {
if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok {
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
})

View File

@@ -509,7 +509,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
var aconfigTextFilePaths android.Paths
ctx.VisitDirectDepsWithTag(aconfigDeclarationTag, func(dep android.Module) {
if provider, ok := ctx.OtherModuleProvider(dep, aconfig.DeclarationsProviderKey).(aconfig.DeclarationsProviderData); ok {
if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.DeclarationsProviderKey); ok {
aconfigTextFilePaths = append(aconfigTextFilePaths, provider.IntermediateDumpOutputPath)
} else {
ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
@@ -537,7 +537,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
var staticLibProguardFlagFiles android.Paths
ctx.VisitDirectDeps(func(m android.Module) {
depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.UnconditionallyExportedProguardFlags.ToList()...)
if ctx.OtherModuleDependencyTag(m) == staticLibTag {
staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.ProguardFlagsFiles.ToList()...)
@@ -974,7 +974,7 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface,
return shouldCollectRecursiveNativeDeps
}
if info, ok := ctx.OtherModuleProvider(module, JniPackageProvider).(JniPackageInfo); ok {
if info, ok := android.OtherModuleProvider(ctx, module, JniPackageProvider); ok {
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}

View File

@@ -1726,7 +1726,7 @@ func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpec
transitiveProguardFlags := []*android.DepSet[android.Path]{}
ctx.VisitDirectDeps(func(m android.Module) {
depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
depTag := ctx.OtherModuleDependencyTag(m)
if depProguardInfo.UnconditionallyExportedProguardFlags != nil {
@@ -1912,7 +1912,7 @@ func (j *providesTransitiveHeaderJars) collectTransitiveHeaderJars(ctx android.M
return
}
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
tag := ctx.OtherModuleDependencyTag(module)
_, isUsesLibDep := tag.(usesLibraryDependencyTag)
if tag == libTag || tag == r8LibraryJarTag || isUsesLibDep {
@@ -2037,7 +2037,7 @@ func (j *Module) collectTransitiveSrcFiles(ctx android.ModuleContext, mine andro
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
if tag == staticLibTag {
depInfo := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
if depInfo.TransitiveSrcFiles != nil {
fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles)
}
@@ -2209,15 +2209,14 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
} else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
if sdkLinkType != javaPlatform &&
ctx.OtherModuleHasProvider(module, SyspropPublicStubInfoProvider) {
// dep is a sysprop implementation library, but this module is not linking against
// the platform, so it gets the sysprop public stubs library instead. Replace
// dep with the JavaInfo from the SyspropPublicStubInfoProvider.
syspropDep := ctx.OtherModuleProvider(module, SyspropPublicStubInfoProvider).(SyspropPublicStubInfo)
dep = syspropDep.JavaInfo
} else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
if sdkLinkType != javaPlatform {
if syspropDep, ok := android.OtherModuleProvider(ctx, module, SyspropPublicStubInfoProvider); ok {
// dep is a sysprop implementation library, but this module is not linking against
// the platform, so it gets the sysprop public stubs library instead. Replace
// dep with the JavaInfo from the SyspropPublicStubInfoProvider.
dep = syspropDep.JavaInfo
}
}
switch tag {
case bootClasspathTag:

View File

@@ -876,7 +876,7 @@ func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx andro
// Get the hidden API information from the module.
mctx := ctx.SdkModuleContext()
hiddenAPIInfo := mctx.OtherModuleProvider(module, HiddenAPIInfoForSdkProvider).(HiddenAPIInfoForSdk)
hiddenAPIInfo, _ := android.OtherModuleProvider(mctx, module, HiddenAPIInfoForSdkProvider)
b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory
// Copy all the generated file paths.

View File

@@ -21,7 +21,6 @@ import (
"strings"
"android/soong/android"
"github.com/google/blueprint"
)
// Supports constructing a list of ClasspathElement from a set of fragments and modules.
@@ -72,8 +71,7 @@ var _ ClasspathElement = (*ClasspathLibraryElement)(nil)
// ClasspathElementContext defines the context methods needed by CreateClasspathElements
type ClasspathElementContext interface {
OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool
OtherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) interface{}
android.OtherModuleProviderContext
ModuleErrorf(fmt string, args ...interface{})
}
@@ -123,12 +121,12 @@ func CreateClasspathElements(ctx ClasspathElementContext, libraries []android.Mo
// associated with a particular apex.
apexToFragment := map[string]android.Module{}
for _, fragment := range fragments {
if !ctx.OtherModuleHasProvider(fragment, android.ApexInfoProvider) {
apexInfo, ok := android.OtherModuleProvider(ctx, fragment, android.ApexInfoProvider)
if !ok {
ctx.ModuleErrorf("fragment %s is not part of an apex", fragment)
continue
}
apexInfo := ctx.OtherModuleProvider(fragment, android.ApexInfoProvider).(android.ApexInfo)
for _, apex := range apexInfo.InApexVariants {
if existing, ok := apexToFragment[apex]; ok {
ctx.ModuleErrorf("apex %s has multiple fragments, %s and %s", apex, fragment, existing)
@@ -146,8 +144,7 @@ skipLibrary:
// Iterate over the libraries to construct the ClasspathElements list.
for _, library := range libraries {
var element ClasspathElement
if ctx.OtherModuleHasProvider(library, android.ApexInfoProvider) {
apexInfo := ctx.OtherModuleProvider(library, android.ApexInfoProvider).(android.ApexInfo)
if apexInfo, ok := android.OtherModuleProvider(ctx, library, android.ApexInfoProvider); ok {
var fragment android.Module

View File

@@ -97,8 +97,7 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont
}
ctx.VisitDirectDepsWithTag(deviceHostConverterDepTag, func(m android.Module) {
if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
d.headerJars = append(d.headerJars, dep.HeaderJars...)
d.implementationJars = append(d.implementationJars, dep.ImplementationJars...)
d.implementationAndResourceJars = append(d.implementationAndResourceJars, dep.ImplementationAndResourcesJars...)

View File

@@ -261,7 +261,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
// See b/20667396
var proguardRaiseDeps classpath
ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) {
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
dep, _ := android.OtherModuleProvider(ctx, m, JavaInfoProvider)
proguardRaiseDeps = append(proguardRaiseDeps, dep.HeaderJars...)
})

View File

@@ -544,7 +544,7 @@ func gatherBootclasspathFragments(ctx android.ModuleContext) map[string]android.
return true
}
if tag == bootclasspathFragmentDepTag {
apexInfo := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
for _, apex := range apexInfo.InApexVariants {
fragments[apex] = child
}
@@ -682,7 +682,7 @@ func extractEncodedDexJarsFromModulesOrBootclasspathFragments(ctx android.Module
pair.jarModule.Name(),
pair.apex)
}
bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragment, BootclasspathFragmentApexContentInfoProvider).(BootclasspathFragmentApexContentInfo)
bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, fragment, BootclasspathFragmentApexContentInfoProvider)
jar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(pair.jarModule)
if err != nil {
ctx.ModuleErrorf("%s", err)

View File

@@ -363,8 +363,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
switch tag {
case bootClasspathTag:
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars...)
} else if sm, ok := module.(SystemModulesProvider); ok {
// A system modules dependency has been added to the bootclasspath
@@ -376,8 +375,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
case libTag, sdkLibTag:
if dep, ok := module.(SdkLibraryDependency); ok {
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...)
} else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
} else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.classpath = append(deps.classpath, dep.HeaderJars...)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
} else if dep, ok := module.(android.SourceFileProducer); ok {
@@ -387,8 +385,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
ctx.ModuleErrorf("depends on non-java module %q", otherName)
}
case java9LibTag:
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...)
} else {
ctx.ModuleErrorf("depends on non-java module %q", otherName)

View File

@@ -121,7 +121,7 @@ func (j *JavaFuzzTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
_, sharedDeps := cc.CollectAllSharedDependencies(ctx)
for _, dep := range sharedDeps {
sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider)
if sharedLibInfo.SharedLibrary != nil {
arch := "lib"
if sharedLibInfo.Target.Arch.ArchType.Multilib == "lib64" {

View File

@@ -94,7 +94,7 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar OptionalDexJ
// processing.
classesJars := android.Paths{classesJar}
ctx.VisitDirectDepsWithTag(hiddenApiAnnotationsTag, func(dep android.Module) {
javaInfo := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
javaInfo, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
classesJars = append(classesJars, javaInfo.ImplementationJars...)
})
h.classesJarPaths = classesJars

View File

@@ -579,8 +579,7 @@ func (i *HiddenAPIInfo) mergeFromFragmentDeps(ctx android.ModuleContext, fragmen
// Merge all the information from the fragments. The fragments form a DAG so it is possible that
// this will introduce duplicates so they will be resolved after processing all the fragments.
for _, fragment := range fragments {
if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
i.TransitiveStubDexJarsByScope.addStubDexJarsByModule(info.TransitiveStubDexJarsByScope)
}
}
@@ -777,8 +776,7 @@ func (i *HiddenAPIPropertyInfo) extractPackageRulesFromProperties(p *HiddenAPIPa
func (i *HiddenAPIPropertyInfo) gatherPropertyInfo(ctx android.ModuleContext, contents []android.Module) {
for _, module := range contents {
if ctx.OtherModuleHasProvider(module, hiddenAPIPropertyInfoProvider) {
info := ctx.OtherModuleProvider(module, hiddenAPIPropertyInfoProvider).(HiddenAPIPropertyInfo)
if info, ok := android.OtherModuleProvider(ctx, module, hiddenAPIPropertyInfoProvider); ok {
i.FlagFilesByCategory.append(info.FlagFilesByCategory)
i.PackagePrefixes = append(i.PackagePrefixes, info.PackagePrefixes...)
i.SinglePackages = append(i.SinglePackages, info.SinglePackages...)
@@ -1404,7 +1402,7 @@ func deferReportingMissingBootDexJar(ctx android.ModuleContext, module android.M
}
if am, ok := module.(android.ApexModule); ok && am.InAnyApex() {
apexInfo := ctx.OtherModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
if apexInfo.IsForPlatform() {
return true
}

View File

@@ -67,8 +67,7 @@ func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory F
case *ClasspathFragmentElement:
fragment := e.Module()
if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) {
info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo)
if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
monolithicInfo.append(&info)
} else {
ctx.ModuleErrorf("%s does not provide hidden API information", fragment)

View File

@@ -162,7 +162,7 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
return false
}
apexInfo := ctx.OtherModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
// Now match the apex part of the boot image configuration.
requiredApex := configuredBootJars.Apex(index)

View File

@@ -1257,7 +1257,7 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext,
})
ctx.VisitDirectDepsWithTag(jniLibTag, func(dep android.Module) {
sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider)
if sharedLibInfo.SharedLibrary != nil {
// Copy to an intermediate output directory to append "lib[64]" to the path,
// so that it's compatible with the default rpath values.
@@ -1902,19 +1902,19 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
tag := ctx.OtherModuleDependencyTag(dep)
switch tag {
case javaApiContributionTag:
provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
provider, _ := android.OtherModuleProvider(ctx, dep, JavaApiImportProvider)
if provider.ApiFile == nil && !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("Error: %s has an empty api file.", dep.Name())
}
srcFilesInfo = append(srcFilesInfo, provider)
case libTag:
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
classPaths = append(classPaths, provider.HeaderJars...)
case staticLibTag:
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
staticLibs = append(staticLibs, provider.HeaderJars...)
case depApiSrcsTag:
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
depApiSrcsStubsJar = provider.HeaderJars[0]
case systemModulesTag:
module := dep.(SystemModulesProvider)
@@ -2220,8 +2220,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.collectTransitiveHeaderJars(ctx)
ctx.VisitDirectDeps(func(module android.Module) {
tag := ctx.OtherModuleDependencyTag(module)
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
switch tag {
case libTag, sdkLibTag:
flags.classpath = append(flags.classpath, dep.HeaderJars...)

View File

@@ -413,8 +413,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
for _, extraLintCheckModule := range extraLintCheckModules {
if ctx.OtherModuleHasProvider(extraLintCheckModule, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(extraLintCheckModule, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, extraLintCheckModule, JavaInfoProvider); ok {
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars...)
} else {
ctx.PropertyErrorf("lint.extra_check_modules",

View File

@@ -180,7 +180,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
var transitiveSrcFiles android.Paths
for _, module := range allModules {
depInfo := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
if depInfo.TransitiveSrcFiles != nil {
transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...)
}
@@ -219,7 +219,7 @@ func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext)
// Include jars from APEXes that don't populate their classpath proto config.
remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
for _, fragment := range b.fragments {
info := ctx.OtherModuleProvider(fragment, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo)
info, _ := android.OtherModuleProvider(ctx, fragment, ClasspathFragmentProtoContentInfoProvider)
if info.ClasspathFragmentProtoGenerated {
remainingJars = remainingJars.RemoveList(info.ClasspathFragmentProtoContents)
}
@@ -241,7 +241,7 @@ func (b *platformBootclasspathModule) platformJars(ctx android.PathContext) andr
func (b *platformBootclasspathModule) checkPlatformModules(ctx android.ModuleContext, modules []android.Module) {
// TODO(satayev): change this check to only allow core-icu4j, all apex jars should not be here.
for _, m := range modules {
apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider)
fromUpdatableApex := apexInfo.Updatable
if fromUpdatableApex {
// error: this jar is part of an updatable apex
@@ -255,7 +255,7 @@ func (b *platformBootclasspathModule) checkPlatformModules(ctx android.ModuleCon
// checkApexModules ensures that the apex modules supplied are not from the platform.
func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext, modules []android.Module) {
for _, m := range modules {
apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.OtherModuleProvider(ctx, m, android.ApexInfoProvider)
fromUpdatableApex := apexInfo.Updatable
if fromUpdatableApex {
// ok: this jar is part of an updatable apex

View File

@@ -193,7 +193,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
}
handleLibDeps := func(dep android.Module) {
m := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
m, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
r.libs = append(r.libs, ctx.OtherModuleName(dep))
if !android.InList(ctx.OtherModuleName(dep), config.FrameworkLibraries) {
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars...)
@@ -305,8 +305,7 @@ func (r *robolectricTest) generateRoboSrcJar(ctx android.ModuleContext, outputFi
srcJarDeps := append(android.Paths(nil), instrumentedApp.srcJarDeps...)
for _, m := range ctx.GetDirectDepsWithTag(roboCoverageLibsTag) {
if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
srcJarArgs = append(srcJarArgs, dep.SrcJarArgs...)
srcJarDeps = append(srcJarDeps, dep.SrcJarDeps...)
}

View File

@@ -673,8 +673,7 @@ type scopePaths struct {
}
func (paths *scopePaths) extractStubsLibraryInfoFromDependency(ctx android.ModuleContext, dep android.Module) error {
if ctx.OtherModuleHasProvider(dep, JavaInfoProvider) {
lib := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
if lib, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
paths.stubsHeaderPath = lib.HeaderJars
paths.stubsImplPath = lib.ImplementationJars
@@ -2037,7 +2036,7 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s android.SdkS
// false.
func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
otherApexInfo := ctx.OtherModuleProvider(other, android.ApexInfoProvider).(android.ApexInfo)
otherApexInfo, _ := android.OtherModuleProvider(ctx, other, android.ApexInfoProvider)
return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
}

View File

@@ -159,7 +159,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
var jars android.Paths
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
dep, _ := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
jars = append(jars, dep.HeaderJars...)
})