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

Commit f4749dfc authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Preserve flags for non-runtime permissions upon package update." into...

Merge "Preserve flags for non-runtime permissions upon package update." into udc-dev am: b4bec96d am: 397ff21d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23284303



Change-Id: I1843469691df6990933a4f15d7c76862979c4ca8
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 71983fa1 397ff21d
Loading
Loading
Loading
Loading
+50 −38
Original line number Diff line number Diff line
@@ -2810,6 +2810,7 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                                + pkg.getPackageName());
                    }

                    if (bp.isNormal() || bp.isSignature() || bp.isInternal()) {
                        if ((bp.isNormal() && shouldGrantNormalPermission)
                                || (bp.isSignature()
                                        && (!bp.isPrivileged() || CollectionUtils.contains(
@@ -2818,8 +2819,10 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                                                permName)
                                                || (((bp.isPrivileged() && CollectionUtils.contains(
                                                        shouldGrantPrivilegedPermissionIfWasGranted,
                                                    permName)) || bp.isDevelopment() || bp.isRole())
                                                    && origState.isPermissionGranted(permName))))
                                                        permName)) || bp.isDevelopment()
                                                                || bp.isRole())
                                                        && origState.isPermissionGranted(
                                                                permName))))
                                || (bp.isInternal()
                                        && (!bp.isPrivileged() || CollectionUtils.contains(
                                                isPrivilegedPermissionAllowlisted, permName))
@@ -2827,12 +2830,35 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                                                permName)
                                                || (((bp.isPrivileged() && CollectionUtils.contains(
                                                        shouldGrantPrivilegedPermissionIfWasGranted,
                                                    permName)) || bp.isDevelopment() || bp.isRole())
                                                    && origState.isPermissionGranted(permName))))) {
                                                        permName)) || bp.isDevelopment()
                                                                || bp.isRole())
                                                        && origState.isPermissionGranted(
                                                                permName))))) {
                            // Grant an install permission.
                            if (uidState.grantPermission(bp)) {
                                installPermissionsChangedForUser = true;
                            }
                        } else {
                            if (DEBUG_PERMISSIONS) {
                                boolean wasGranted = uidState.isPermissionGranted(bp.getName());
                                if (wasGranted || bp.isAppOp()) {
                                    Slog.i(TAG, (wasGranted ? "Un-granting" : "Not granting")
                                            + " permission " + perm
                                            + " from package " + friendlyName
                                            + " (protectionLevel=" + bp.getProtectionLevel()
                                            + " flags=0x"
                                            + Integer.toHexString(PackageInfoUtils.appInfoFlags(pkg,
                                            ps))
                                            + ")");
                                }
                            }
                            if (uidState.revokePermission(bp)) {
                                installPermissionsChangedForUser = true;
                            }
                        }
                        PermissionState origPermState = origState.getPermissionState(perm);
                        int flags = origPermState != null ? origPermState.getFlags() : 0;
                        uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL, flags);
                    } else if (bp.isRuntime()) {
                        boolean hardRestricted = bp.isHardRestricted();
                        boolean softRestricted = bp.isSoftRestricted();
@@ -2956,22 +2982,8 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                        uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL,
                                flags);
                    } else {
                        if (DEBUG_PERMISSIONS) {
                            boolean wasGranted = uidState.isPermissionGranted(bp.getName());
                            if (wasGranted || bp.isAppOp()) {
                                Slog.i(TAG, (wasGranted ? "Un-granting" : "Not granting")
                                        + " permission " + perm
                                        + " from package " + friendlyName
                                        + " (protectionLevel=" + bp.getProtectionLevel()
                                        + " flags=0x"
                                        + Integer.toHexString(PackageInfoUtils.appInfoFlags(pkg,
                                                ps))
                                        + ")");
                            }
                        }
                        if (uidState.removePermissionState(bp.getName())) {
                            installPermissionsChangedForUser = true;
                        }
                        Slog.wtf(LOG_TAG, "Unknown permission protection " + bp.getProtection()
                                + " for permission " + bp.getName());
                    }
                }