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

@@ -1744,11 +1744,13 @@ func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
}
func (ctx *moduleContextImpl) isForPlatform() bool {
return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
return apexInfo.IsForPlatform()
}
func (ctx *moduleContextImpl) apexVariationName() string {
return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName
apexInfo, _ := android.ModuleProvider(ctx.ctx, android.ApexInfoProvider)
return apexInfo.ApexVariationName
}
func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel {
@@ -1991,7 +1993,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
c.Properties.SubName = GetSubnameProperty(actx, c)
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
c.hideApexVariantFromMake = true
}
@@ -2982,7 +2984,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.GeneratedHeaders...)
}
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
c.apexSdkVersion = findApexSdkVersion(ctx, apexInfo)
skipModuleList := map[string]bool{}
@@ -3402,7 +3404,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
bootstrap = linkable.Bootstrap()
}
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
useStubs := false
@@ -3436,7 +3438,7 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
// Another exception: if this module is a test for an APEX, then
// it is linked with the non-stub variant of a module in the APEX
// as if this is part of the APEX.
testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo)
testFor, _ := android.ModuleProvider(ctx, android.ApexTestForInfoProvider)
for _, apexContents := range testFor.ApexContents {
if apexContents.DirectlyInApex(depName) {
useStubs = false

View File

@@ -194,8 +194,8 @@ func shouldCreateSourceAbiDumpForLibrary(ctx android.BaseModuleContext) bool {
return false
}
isPlatformVariant := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
if isPlatformVariant {
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if apexInfo.IsForPlatform() {
// Bionic libraries that are installed to the bootstrap directory are not ABI checked.
// Only the runtime APEX variants, which are the implementation libraries of bionic NDK stubs,
// are checked.

View File

@@ -1627,7 +1627,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
addStaticDeps := func(dep string, hideSymbols bool) {
// If we're using snapshots, redirect to snapshot whenever possible
snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
if lib, ok := snapshot.StaticLibs[dep]; ok {
dep = lib
}
@@ -1714,7 +1714,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
addStaticDeps(runtimeSharedLibrary, true)
} else if !c.static() && !c.Header() {
// If we're using snapshots, redirect to snapshot whenever possible
snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
snapshot, _ := android.ModuleProvider(mctx, SnapshotInfoProvider)
if lib, ok := snapshot.SharedLibs[runtimeSharedLibrary]; ok {
runtimeSharedLibrary = lib
}