Pre-grant permissions split from install permissions
When runtime permissions are split, by default, they inherit the grant states from their source permissions.
We now support the same inheritance for install time permission splits.
This supports activity recognition permission that is being split from install time in gmscore to runtime in the platform.
Bug: 111411340
Test: App requesting old install activity recognition is granted new runtime permission on install
Change-Id: I2a77e27f7d821d1b15ba8f0310735b51d6e80323
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index b788935..c5d38db 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -1242,6 +1242,9 @@
&& ps.getRuntimePermissionState(sourcePerm, userId).isGranted()) {
isGranted = true;
break;
+ } else if (ps.hasInstallPermission(sourcePerm)) {
+ isGranted = true;
+ break;
}
}
@@ -1348,8 +1351,18 @@
}
}
} else {
- if (!origPs.hasRequestedPermission(sourcePerms)) {
- // Both permissions are new, do nothing
+ boolean inheritsFromInstallPerm = false;
+ for (int sourcePermNum = 0; sourcePermNum < sourcePerms.size();
+ sourcePermNum++) {
+ if (ps.hasInstallPermission(sourcePerms.valueAt(sourcePermNum))) {
+ inheritsFromInstallPerm = true;
+ break;
+ }
+ }
+
+ if (!origPs.hasRequestedPermission(sourcePerms)
+ && !inheritsFromInstallPerm) {
+ // Both permissions are new so nothing to inherit.
if (DEBUG_PERMISSIONS) {
Slog.i(TAG, newPerm + " does not inherit from " + sourcePerms
+ " for " + pkgName
@@ -1358,6 +1371,7 @@
break;
} else {
+ // Inherit from new install or existing runtime permissions
inheritPermissionStateToNewImplicitPermissionLocked(sourcePerms,
newPerm, ps, pkg, userId);
}