From 0a3bb7dc5e242fda5ebfe9e8bc67464f0c1a7f55 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Thu, 1 Jun 2023 17:07:58 +0000 Subject: [PATCH] Change install name of privapp allowlists Use the APK's filename as the on-device filename for the allowlist. Previously the filename of the source xml file was used, which leads to a problem when the same source file is used for different apps (even if only one of those modules ends up being installed). Bug: 284500052 Test: app_test.go & presubmit boot tests (cherry picked from https://android-review.googlesource.com/q/commit:92d1f52790e83952bf305464f0083d8c05f4c557) Merged-In: I0b43a35e3a310464d79d7f37e0900d639f4a479c Change-Id: I0b43a35e3a310464d79d7f37e0900d639f4a479c --- java/app.go | 5 +++-- java/app_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/java/app.go b/java/app.go index cbdb50221..0eb37c889 100755 --- a/java/app.go +++ b/java/app.go @@ -795,8 +795,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { shouldInstallAppPackage := (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() && !a.appProperties.PreventInstall if shouldInstallAppPackage { if a.privAppAllowlist.Valid() { - installPath := android.PathForModuleInstall(ctx, "etc", "permissions") - ctx.InstallFile(installPath, a.privAppAllowlist.Path().Base(), a.privAppAllowlist.Path()) + allowlistInstallPath := android.PathForModuleInstall(ctx, "etc", "permissions") + allowlistInstallFilename := a.installApkName + ".xml" + ctx.InstallFile(allowlistInstallPath, allowlistInstallFilename, a.privAppAllowlist.Path()) } var extraInstalledPaths android.Paths diff --git a/java/app_test.go b/java/app_test.go index 71cd38c22..746ab75e7 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -3586,8 +3586,8 @@ func TestPrivappAllowlist(t *testing.T) { } // verify that permissions are copied to device - app.Output("out/soong/target/product/test_device/system/etc/permissions/privapp_allowlist_com.android.foo.xml") - overrideApp.Output("out/soong/target/product/test_device/system/etc/permissions/privapp_allowlist_com.google.android.foo.xml") + app.Output("out/soong/target/product/test_device/system/etc/permissions/foo.xml") + overrideApp.Output("out/soong/target/product/test_device/system/etc/permissions/bar.xml") } func TestPrivappAllowlistAndroidMk(t *testing.T) { @@ -3638,7 +3638,7 @@ func TestPrivappAllowlistAndroidMk(t *testing.T) { t, "androidmk has incorrect LOCAL_SOONG_INSTALL_PAIRS; expected to it to include privapp_allowlist", baseEntries.EntryMap["LOCAL_SOONG_INSTALL_PAIRS"][0], - "privapp_allowlist_com.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/privapp_allowlist_com.android.foo.xml", + "privapp_allowlist_com.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/foo.xml", ) overrideAndroidApp := overrideApp.Module().(*AndroidApp) @@ -3665,6 +3665,6 @@ func TestPrivappAllowlistAndroidMk(t *testing.T) { t, "androidmk has incorrect LOCAL_SOONG_INSTALL_PAIRS; expected to it to include privapp_allowlist", overrideEntries.EntryMap["LOCAL_SOONG_INSTALL_PAIRS"][0], - "\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/privapp_allowlist_com.google.android.foo.xml", + "\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/bar.xml", ) }