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

Commit 587512a0 authored by Svet Ganov's avatar Svet Ganov
Browse files

Don't reset review state until no permission requires a review.

In a permission review mode we have a per user flag whether a
permission review is required for an app to avoid iteration
over all permissions on an activity start. This state was
incorrectly cleared if a permission review flag is cleared
despite the fact that there may me other permissions requiring
a review.

Test: manual

bug:63720758

Change-Id: I3391c9d7e419e2e22f7b053de8e6ed977b6eba91
parent 183f9ac2
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ public final class PermissionsState {
                mPermissionReviewRequired.put(userId, true);
            } else if ((oldFlags & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) != 0
                    && (newFlags & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) == 0) {
                if (mPermissionReviewRequired != null) {
                if (mPermissionReviewRequired != null && !hasPermissionRequiringReview(userId)) {
                    mPermissionReviewRequired.delete(userId);
                    if (mPermissionReviewRequired.size() <= 0) {
                        mPermissionReviewRequired = null;
@@ -438,6 +438,18 @@ public final class PermissionsState {
        return updated;
    }

    private boolean hasPermissionRequiringReview(int userId) {
        final int permissionCount = mPermissions.size();
        for (int i = 0; i < permissionCount; i++) {
            final PermissionData permission = mPermissions.valueAt(i);
            if ((permission.getFlags(userId)
                    & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) != 0) {
                return true;
            }
        }
        return false;
    }

    public boolean updatePermissionFlagsForAllPermissions(
            int userId, int flagMask, int flagValues) {
        enforceValidUserId(userId);