Allow overriding android_library_import manifests

Some of the androidx libraries have a transformed manifest
alongside that needs to be used to avoid introducing extra
androidx.startup provider entries.  Add a manifest property
that allows overriding the manifest provided by the aar file.

Bug: 336549758
Test: examine PermissionController.apk
Ignore-AOSP-First: submitting in topic with internal CL
Change-Id: I5c8daf810d2fde9a150cbfe48b4f4216f5d1ba0d
This commit is contained in:
Colin Cross
2024-04-23 12:39:54 -07:00
parent c860d063a3
commit be77e450df

View File

@@ -968,6 +968,9 @@ type AARImportProperties struct {
// will be passed transitively through android_libraries to an android_app.
//TODO(b/241138093) evaluate whether we can have this flag default to true for Bazel conversion
Extract_jni *bool
// If set, overrides the manifest extracted from the AAR with the provided path.
Manifest *string `android:"path"`
}
type AARImport struct {
@@ -990,7 +993,7 @@ type AARImport struct {
exportPackage android.WritablePath
transitiveAaptResourcePackagesFile android.Path
extraAaptPackagesFile android.WritablePath
manifest android.WritablePath
manifest android.Path
assetsPackage android.WritablePath
rTxt android.WritablePath
rJar android.WritablePath
@@ -1166,7 +1169,15 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
jarName := ctx.ModuleName() + ".jar"
extractedAARDir := android.PathForModuleOut(ctx, "aar")
classpathFile := extractedAARDir.Join(ctx, jarName)
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
extractedManifest := extractedAARDir.Join(ctx, "AndroidManifest.xml")
providedManifest := android.OptionalPathForModuleSrc(ctx, a.properties.Manifest)
if providedManifest.Valid() {
a.manifest = providedManifest.Path()
} else {
a.manifest = extractedManifest
}
a.rTxt = extractedAARDir.Join(ctx, "R.txt")
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
@@ -1187,7 +1198,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.Build(pctx, android.BuildParams{
Rule: unzipAAR,
Input: a.aarPath,
Outputs: android.WritablePaths{classpathFile, a.proguardFlags, a.manifest, a.assetsPackage, a.rTxt},
Outputs: android.WritablePaths{classpathFile, a.proguardFlags, extractedManifest, a.assetsPackage, a.rTxt},
Description: "unzip AAR",
Args: map[string]string{
"outDir": extractedAARDir.String(),