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

@@ -411,7 +411,7 @@ func (a *AndroidApp) useEmbeddedNativeLibs(ctx android.ModuleContext) bool {
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.MinSdkVersion(ctx), err)
}
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return (minSdkVersion.FinalOrFutureInt() >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
!apexInfo.IsForPlatform()
}
@@ -436,7 +436,7 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
}
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
!apexInfo.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
}
@@ -745,7 +745,8 @@ func (a *AndroidApp) createPrivappAllowlist(ctx android.ModuleContext) android.P
func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
var apkDeps android.Paths
if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
a.hideApexVariantFromMake = true
}
@@ -890,8 +891,6 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.privAppAllowlist = android.OptionalPathForPath(allowlist)
}
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
// Install the app package.
shouldInstallAppPackage := (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() && !a.appProperties.PreventInstall
if shouldInstallAppPackage {