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

Commit 9a8ecbc4 authored by Shashwat Razdan's avatar Shashwat Razdan Committed by Automerger Merge Worker
Browse files

Merge "Revert "Persist permission state for updated apps synchronously."" into...

Merge "Revert "Persist permission state for updated apps synchronously."" into tm-dev am: 90549066 am: 7b437f90 am: 27c7ea98 am: b94b8cd4

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



Change-Id: I13ecaa92b3bfcf8d21a4b4ccf04ca3157bf4eef2
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 996fc389 b94b8cd4
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -2521,7 +2521,6 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
        final int[] userIds = filterUserId == UserHandle.USER_ALL ? getAllUserIds()
                : new int[] { filterUserId };

        boolean installPermissionsChanged = false;
        boolean runtimePermissionsRevoked = false;
        int[] updatedUserIds = EMPTY_INT_ARRAY;

@@ -2640,7 +2639,7 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt

                UidPermissionState origState = uidState;

                boolean installPermissionsChangedForUser = false;
                boolean changedInstallPermission = false;

                if (replace) {
                    userState.setInstallPermissionsFixed(ps.getPackageName(), false);
@@ -2806,7 +2805,7 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                                                    && origState.isPermissionGranted(permName))))) {
                        // Grant an install permission.
                        if (uidState.grantPermission(bp)) {
                            installPermissionsChangedForUser = true;
                            changedInstallPermission = true;
                        }
                    } else if (bp.isRuntime()) {
                        boolean hardRestricted = bp.isHardRestricted();
@@ -2946,12 +2945,12 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                            }
                        }
                        if (uidState.removePermissionState(bp.getName())) {
                            installPermissionsChangedForUser = true;
                            changedInstallPermission = true;
                        }
                    }
                }

                if ((installPermissionsChangedForUser || replace)
                if ((changedInstallPermission || replace)
                        && !userState.areInstallPermissionsFixed(ps.getPackageName())
                        && !ps.isSystem() || ps.getTransientState().isUpdatedSystemApp()) {
                    // This is the first that we have heard about this package, so the
@@ -2960,12 +2959,6 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
                    userState.setInstallPermissionsFixed(ps.getPackageName(), true);
                }

                if (installPermissionsChangedForUser) {
                    installPermissionsChanged = true;
                    if (replace) {
                        updatedUserIds = ArrayUtils.appendInt(updatedUserIds, userId);
                    }
                }
                updatedUserIds = revokePermissionsNoLongerImplicitLocked(uidState,
                        pkg.getPackageName(), uidImplicitPermissions, uidTargetSdkVersion, userId,
                        updatedUserIds);
@@ -2982,12 +2975,8 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
        // Persist the runtime permissions state for users with changes. If permissions
        // were revoked because no app in the shared user declares them we have to
        // write synchronously to avoid losing runtime permissions state.
        // Also write synchronously if we changed any install permission for an updated app, because
        // the install permission state is likely already fixed before update, and if we lose the
        // changes here the app won't be reconsidered for newly-added install permissions.
        if (callback != null) {
            callback.onPermissionUpdated(updatedUserIds,
                    (replace && installPermissionsChanged) || runtimePermissionsRevoked);
            callback.onPermissionUpdated(updatedUserIds, runtimePermissionsRevoked);
        }

        for (int userId : updatedUserIds) {