summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt12
-rw-r--r--PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt6
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.