Grant split permissions if root permission is granted
- In the case of an upgrade
- When granting default permissions
Change-Id: I604223a00cbb9350718c6a293f979d5ce99e12c9
Fixes: 111325117
Test: Looked at location permissions after upgrade and after fresh install
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 1ae59cb..50e6f8d 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -1193,12 +1193,27 @@
}
}
- private void grantRuntimePermissions(PackageParser.Package pkg, Set<String> permissions,
- boolean systemFixed, boolean ignoreSystemPackage, int userId) {
+ private void grantRuntimePermissions(PackageParser.Package pkg,
+ Set<String> permissionsWithoutSplits, boolean systemFixed, boolean ignoreSystemPackage,
+ int userId) {
if (pkg.requestedPermissions.isEmpty()) {
return;
}
+ final ArraySet<String> permissions = new ArraySet<>(permissionsWithoutSplits);
+
+ // Automatically attempt to grant split permissions to older APKs
+ final int numSplitPerms = PackageParser.SPLIT_PERMISSIONS.length;
+ for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) {
+ final PackageParser.SplitPermissionInfo splitPerm =
+ PackageParser.SPLIT_PERMISSIONS[splitPermNum];
+
+ if (pkg.applicationInfo.targetSdkVersion < splitPerm.targetSdk
+ && permissionsWithoutSplits.contains(splitPerm.rootPerm)) {
+ Collections.addAll(permissions, splitPerm.newPerms);
+ }
+ }
+
List<String> requestedPermissions = pkg.requestedPermissions;
Set<String> grantablePermissions = null;