don't require package_name for non-override android_apps

For a non-override android_app, we can assume that the privapp_allowlist
already contains the correct package_name, and so we don't need to
overwrite it in this case.

Bug: 242509786
Test: go test
Ignore-AOSP-First: need to submit here to update PermissionController in sync with internal version
Merged-In: I0f137e34cae3478dc8b9178d138121ff1d936f07
Change-Id: I0f137e34cae3478dc8b9178d138121ff1d936f07
This commit is contained in:
Sam Delmerico
2023-05-15 17:21:47 -04:00
committed by Anton Hansson
parent c53cfd54d9
commit 502d807ae9
3 changed files with 16 additions and 15 deletions

View File

@@ -621,13 +621,21 @@ func (a *AndroidApp) InstallApkName() string {
return a.installApkName
}
func (a *AndroidApp) createPrivappAllowlist(ctx android.ModuleContext) *android.OutputPath {
func (a *AndroidApp) createPrivappAllowlist(ctx android.ModuleContext) android.Path {
if a.appProperties.Privapp_allowlist == nil {
return nil
}
isOverrideApp := a.GetOverriddenBy() != ""
if !isOverrideApp {
// if this is not an override, we don't need to rewrite the existing privapp allowlist
return android.PathForModuleSrc(ctx, *a.appProperties.Privapp_allowlist)
}
if a.overridableAppProperties.Package_name == nil {
ctx.PropertyErrorf("privapp_allowlist", "package_name must be set to use privapp_allowlist")
}
packageName := *a.overridableAppProperties.Package_name
fileName := "privapp_allowlist_" + packageName + ".xml"
outPath := android.PathForModuleOut(ctx, fileName).OutputPath