Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1537dc7 authored by Zimuzo's avatar Zimuzo
Browse files

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
parent 7e0404f1
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -1242,6 +1242,9 @@ public class PermissionManagerService {
                        && ps.getRuntimePermissionState(sourcePerm, userId).isGranted()) {
                    isGranted = true;
                    break;
                } else if (ps.hasInstallPermission(sourcePerm)) {
                    isGranted = true;
                    break;
                }
            }

@@ -1348,8 +1351,18 @@ public class PermissionManagerService {
                                }
                            }
                        } 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 @@ public class PermissionManagerService {

                                break;
                            } else {
                                // Inherit from new install or existing runtime permissions
                                inheritPermissionStateToNewImplicitPermissionLocked(sourcePerms,
                                        newPerm, ps, pkg, userId);
                            }