Grant SharedStorageBackup storage access.
Shared storage backup had been relying on the WRITE_MEDIA_STORAGE permission to access
files on external storage, but that permission has been locked down,
and we need to use the real WRITE_EXTERNAL_STORAGE permission now.
Bug: 78938482
Test: build && boot && 'adb backup -shared' && 'adb restore backup.ab'
Test: make gts -j32 && gts-tradefed run gts -m GtsPermissionTestCases
Change-Id: Id244a1178936e8ffcccc7f95bcb120809a4b4607
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index 4055a47..c9aa1ef 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -841,6 +841,14 @@
}
}
+ // There is no real "marker" interface to identify the shared storage backup, it is
+ // hardcoded in BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE.
+ PackageParser.Package sharedStorageBackupPackage = getSystemPackage(
+ "com.android.sharedstoragebackup");
+ if (sharedStorageBackupPackage != null) {
+ grantRuntimePermissions(sharedStorageBackupPackage, STORAGE_PERMISSIONS, true, userId);
+ }
+
if (mPermissionGrantedCallback != null) {
mPermissionGrantedCallback.onDefaultRuntimePermissionsGranted(userId);
}