Convert Provider to generic providers API

Convert all of the callers of Provider/HasProvider to use the type-safe
android.ModuleProvider API.

Bug: 316410648
Test: builds

Change-Id: I73479de1625fa2865b6c73444cd477e50d56dc5a
This commit is contained in:
Colin Cross
2023-12-13 15:54:49 -08:00
parent 402130276c
commit ff694a8c88
16 changed files with 47 additions and 41 deletions

View File

@@ -747,7 +747,8 @@ func (mod *Module) installable(apexInfo android.ApexInfo) bool {
}
func (ctx moduleContext) apexVariationName() string {
return ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return apexInfo.ApexVariationName
}
var _ cc.LinkableInterface = (*Module)(nil)
@@ -897,7 +898,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ModuleContext: actx,
}
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
mod.hideApexVariantFromMake = true
}
@@ -978,7 +979,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
}
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !proptools.BoolDefault(mod.Installable(), mod.EverInstallable()) && !mod.ProcMacro() {
// If the module has been specifically configure to not be installed then
// hide from make as otherwise it will break when running inside make as the
@@ -1148,7 +1149,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// For the dependency from platform to apex, use the latest stubs
mod.apexSdkVersion = android.FutureApiLevel
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
mod.apexSdkVersion = apexInfo.MinSdkVersion
}

View File

@@ -270,7 +270,7 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
}
// If we're using snapshots, redirect to snapshot whenever possible
// TODO(b/178470649): clean manual snapshot redirections
snapshot := mctx.Provider(cc.SnapshotInfoProvider).(cc.SnapshotInfo)
snapshot, _ := android.ModuleProvider(mctx, cc.SnapshotInfoProvider)
if lib, ok := snapshot.StaticLibs[noteDep]; ok {
noteDep = lib
}