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

Commit 71f6c4e8 authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Ensure that mixed permission policies return the right result

Currently, when a policy is fixed denied, but the profile / device
owner has set DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT,
requesting a permission returns the wrong result.

Bug: 22291565
Change-Id: I9c531faf89236f7e177ccd4b2c3e8f86308b263e
parent ac650147
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@ public class GrantPermissionsActivity extends Activity
                        mRequestGrantPermissionGroups.put(group.getName(), new GroupState(group));
                    } break;
                }
            } else {
                // if the permission is fixed, ensure that we return the right request result
                updateGrantResults(group);
            }
        }

@@ -232,12 +235,11 @@ public class GrantPermissionsActivity extends Activity

    private void updateGrantResults(AppPermissionGroup group) {
        for (Permission permission : group.getPermissions()) {
            if (permission.isGranted()) {
            final int index = ArrayUtils.getArrayIndex(
                    mRequestedPermissions, permission.getName());
            if (index >= 0) {
                    mGrantResults[index] = PackageManager.PERMISSION_GRANTED;
                }
                mGrantResults[index] = permission.isGranted() ? PackageManager.PERMISSION_GRANTED
                        : PackageManager.PERMISSION_DENIED;
            }
        }
    }