diff options
author | Jay Thomas Sullivan <jaysullivan@google.com> | 2022-05-18 21:45:43 +0000 |
---|---|---|
committer | Jay Thomas Sullivan <jaysullivan@google.com> | 2022-05-31 15:23:02 -0700 |
commit | 9bb7c28936fcaa201d889ce79d11c68709bbe6b5 (patch) | |
tree | d3b81ae2be2755bf994f03cc38510b37aa0feb24 | |
parent | b211d3e69cf1c1149e1a0e6d291f8dc09a46f81c (diff) | |
download | Permission-9bb7c28936fcaa201d889ce79d11c68709bbe6b5.tar.gz |
Fix auto-grant for groups with solely R_W_R perms
Recently, we added code to consider a group granted only if it has at
least one non-REVOKE_WHEN_REQUESTED permission granted.
But, there is another case where a group should be considered granted:
when all of its permissions are granted and all have
REVOKE_WHEN_REQUESTED. (This is the case for groups auto-granted by
split permission.)
Bug: 223907044
Fixes: 231839805
Test: atest SplitPermissionAutoGrantTest
Test: Manually as described in b/231839805#comment7
Change-Id: I48195875b3a19b6621279d54d5c8974c549c158e
Merged-In: I48195875b3a19b6621279d54d5c8974c549c158e
2 files changed, 11 insertions, 7 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt b/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt index 356f4e52f..64d63bd1a 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt @@ -189,11 +189,15 @@ data class LightAppPermGroup( val isGranted = specialLocationGrant ?: permissions.any { it.value.isGrantedIncludingAppOp } /** - * Whether any of this App Permission SubGroup's permissions are granted excluding - * auto granted permissions during install time with flag RevokeWhenRequested + * Whether this App Permission SubGroup should be treated as granted. This means either: + * 1) At least one permission was granted excluding auto-granted permissions (i.e., granted + * during install time with flag RevokeWhenRequested.) Or, + * 2) All permissions were auto-granted (all permissions are all granted and all + * RevokeWhenRequested.) */ - val isGrantedExcludeRevokeWhenRequestedPermissions = specialLocationGrant ?: permissions - .any { it.value.isGrantedIncludingAppOp && !it.value.isRevokeWhenRequested } + val isGrantedExcludingRWROrAllRWR = specialLocationGrant ?: (permissions + .any { it.value.isGrantedIncludingAppOp && !it.value.isRevokeWhenRequested } || + permissions.all { it.value.isGrantedIncludingAppOp && it.value.isRevokeWhenRequested }) /** * Whether any of this App Permission SubGroup's permissions are granted by default diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt index a27bd5bba..2f0921f09 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt @@ -710,7 +710,7 @@ class GrantPermissionsViewModel( // Do not attempt to grant background access if foreground access is not either already // granted or requested - if (isBackground && !group.foreground.isGrantedExcludeRevokeWhenRequestedPermissions && + if (isBackground && !group.foreground.isGrantedExcludingRWROrAllRWR && !hasForegroundRequest) { Log.w(LOG_TAG, "Cannot grant $perm as the matching foreground permission is not " + "already granted.") @@ -724,8 +724,8 @@ class GrantPermissionsViewModel( // TODO(b/205888750): remove isRuntimePermReview line once confident in // REVIEW_REQUIRED flag setting - if ((isBackground && group.background.isGrantedExcludeRevokeWhenRequestedPermissions || - !isBackground && group.foreground.isGrantedExcludeRevokeWhenRequestedPermissions) && + if ((isBackground && group.background.isGrantedExcludingRWROrAllRWR || + !isBackground && group.foreground.isGrantedExcludingRWROrAllRWR) && !group.isRuntimePermReviewRequired) { // If FINE location is not granted, do not grant it automatically when COARSE // location is already granted. |