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
diff --git a/android/androidmk.go b/android/androidmk.go
index 097075e..6b6c3f1 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -624,8 +624,7 @@
}
}
- if ctx.ModuleHasProvider(mod, LicenseMetadataProvider) {
- licenseMetadata := ctx.ModuleProvider(mod, LicenseMetadataProvider).(*LicenseMetadataInfo)
+ if licenseMetadata, ok := SingletonModuleProvider(ctx, mod, LicenseMetadataProvider); ok {
a.SetPath("LOCAL_SOONG_LICENSE_METADATA", licenseMetadata.LicenseMetadataPath)
}
diff --git a/android/deapexer.go b/android/deapexer.go
index e5dd277..de933d1 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -150,7 +150,7 @@
func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
var di *DeapexerInfo
ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
- c := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
+ c, _ := OtherModuleProvider(ctx, m, DeapexerProvider)
p := &c
if di != nil {
// If two DeapexerInfo providers have been found then check if they are
diff --git a/android/license_metadata.go b/android/license_metadata.go
index 75df852..463fd07 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -78,8 +78,7 @@
return
}
- if ctx.OtherModuleHasProvider(dep, LicenseMetadataProvider) {
- info := ctx.OtherModuleProvider(dep, LicenseMetadataProvider).(*LicenseMetadataInfo)
+ if info, ok := OtherModuleProvider(ctx, dep, LicenseMetadataProvider); ok {
allDepMetadataFiles = append(allDepMetadataFiles, info.LicenseMetadataPath)
if isContainer || isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
allDepMetadataDepSets = append(allDepMetadataDepSets, info.LicenseMetadataDepSet)
diff --git a/android/prebuilt.go b/android/prebuilt.go
index a32a37d..6a417a8 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -461,8 +461,8 @@
// Propagate the provider received from `all_apex_contributions`
// to the source module
ctx.VisitDirectDepsWithTag(acDepTag, func(am Module) {
- psi := ctx.OtherModuleProvider(am, PrebuiltSelectionInfoProvider).(PrebuiltSelectionInfoMap)
- ctx.SetProvider(PrebuiltSelectionInfoProvider, psi)
+ psi, _ := OtherModuleProvider(ctx, am, PrebuiltSelectionInfoProvider)
+ SetProvider(ctx, PrebuiltSelectionInfoProvider, psi)
})
} else if s, ok := ctx.Module().(Module); ok {
@@ -548,9 +548,7 @@
// Use `all_apex_contributions` for source vs prebuilt selection.
psi := PrebuiltSelectionInfoMap{}
ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(am Module) {
- if ctx.OtherModuleHasProvider(am, PrebuiltSelectionInfoProvider) {
- psi = ctx.OtherModuleProvider(am, PrebuiltSelectionInfoProvider).(PrebuiltSelectionInfoMap)
- }
+ psi, _ = OtherModuleProvider(ctx, am, PrebuiltSelectionInfoProvider)
})
// If the source module is explicitly listed in the metadata module, use that