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

Commit 57bc312f authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix getAllPermissionWithProtectionLevel().

This method was only used by PermissionPolicyService, but the
implementation didn't take protection flag into account and thus
didn't watch a lot of runtime permissions (e.g. location
permissions). Tests were passing probably because most of the time app
op change is triggered at the same time.

Bug: 136503238
Test: presubmit
Change-Id: I7d88c26b07a117db33047d2987dd47344d155460
parent 4aa9de9b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4233,8 +4233,8 @@ public class PermissionManagerService extends IPermissionManager.Stub {
        }

        @Override
        public @NonNull ArrayList<PermissionInfo> getAllPermissionWithProtectionLevel(
                @PermissionInfo.Protection int protectionLevel) {
        public @NonNull ArrayList<PermissionInfo> getAllPermissionWithProtection(
                @PermissionInfo.Protection int protection) {
            ArrayList<PermissionInfo> matchingPermissions = new ArrayList<>();

            synchronized (PermissionManagerService.this.mLock) {
@@ -4244,7 +4244,7 @@ public class PermissionManagerService extends IPermissionManager.Stub {
                    BasePermission bp = mSettings.mPermissions.valueAt(i);

                    if (bp.perm != null && bp.perm.info != null
                            && bp.protectionLevel == protectionLevel) {
                            && bp.perm.info.getProtection() == protection) {
                        matchingPermissions.add(bp.perm.info);
                    }
                }
+2 −2
Original line number Diff line number Diff line
@@ -291,8 +291,8 @@ public abstract class PermissionManagerServiceInternal extends PermissionManager
    public abstract @Nullable BasePermission getPermissionTEMP(@NonNull String permName);

    /** Get all permission that have a certain protection level */
    public abstract @NonNull ArrayList<PermissionInfo> getAllPermissionWithProtectionLevel(
            @PermissionInfo.Protection int protectionLevel);
    public abstract @NonNull ArrayList<PermissionInfo> getAllPermissionWithProtection(
            @PermissionInfo.Protection int protection);

    /**
     * Returns the delegate used to influence permission checking.
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public final class PermissionPolicyService extends SystemService {
        };

        final ArrayList<PermissionInfo> dangerousPerms =
                permManagerInternal.getAllPermissionWithProtectionLevel(
                permManagerInternal.getAllPermissionWithProtection(
                        PermissionInfo.PROTECTION_DANGEROUS);

        try {