diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-16 21:13:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-16 21:13:31 +0000 |
commit | 619eadc55e6811ef72ba1443fba7267b2bc9c548 (patch) | |
tree | b18abc4c77ddbd7923e77607369f62e3fb6c3eb8 | |
parent | 6ca58fd518c36bb3a93871a8dd5700b0766c7129 (diff) | |
parent | c789aa38c3398311aebe9409e51b97c2fc7b8ec8 (diff) | |
download | Permission-619eadc55e6811ef72ba1443fba7267b2bc9c548.tar.gz |
Merge cherrypicks of [17829592] into sc-qpr3-release.android-12.1.0_r9android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r11android-12.1.0_r10android12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-release
Change-Id: I79f547b4c1e1ad1540afafe8503f6482d6d06fec
3 files changed, 14 insertions, 4 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 3fb09607b..cbfac4b24 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightAppPermGroup.kt @@ -165,6 +165,13 @@ 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 + */ + val isGrantedExcludeRevokeWhenRequestedPermissions = specialLocationGrant ?: permissions + .any { it.value.isGrantedIncludingAppOp && !it.value.isRevokeWhenRequested } + + /** * Whether any of this App Permission SubGroup's permissions are granted by default */ val isGrantedByDefault = permissions.any { it.value.isGrantedByDefault } diff --git a/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightPermission.kt b/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightPermission.kt index 745c5c2fd..c3d087fd2 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightPermission.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/model/livedatatypes/LightPermission.kt @@ -113,6 +113,7 @@ data class LightPermission( if (isSystemFixed) append(", SystemFixed") if (isUserFixed) append(", UserFixed") if (isUserSet) append(", UserSet") + if (isRevokeWhenRequested) append(", RevokeWhenRequested") if (isCompatRevoked) append(", CompatRevoked") if (isReviewRequired) append(", ReviewRequired") if (isOneTime) append(", OneTime") 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 64549703f..9749a814c 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt @@ -237,7 +237,8 @@ class GrantPermissionsViewModel( // some requests might have been granted, check for that for ((key, state) in states) { val allAffectedGranted = state.affectedPermissions.all { perm -> - appPermGroup.permissions[perm]?.isGrantedIncludingAppOp == true + appPermGroup.permissions[perm]?.isGrantedIncludingAppOp == true && + appPermGroup.permissions[perm]?.isRevokeWhenRequested == false } if (allAffectedGranted) { groupStates[key]!!.state = STATE_ALLOWED @@ -654,7 +655,8 @@ class GrantPermissionsViewModel( // Do not attempt to grant background access if foreground access is not either already // granted or requested - if (isBackground && !group.foreground.isGranted && !hasForegroundRequest) { + if (isBackground && !group.foreground.isGrantedExcludeRevokeWhenRequestedPermissions && + !hasForegroundRequest) { Log.w(LOG_TAG, "Cannot grant $perm as the matching foreground permission is not " + "already granted.") val affectedPermissions = groupRequestedPermissions.filter { @@ -665,8 +667,8 @@ class GrantPermissionsViewModel( return STATE_SKIPPED } - if (isBackground && group.background.isGranted || - !isBackground && group.foreground.isGranted) { + if (isBackground && group.background.isGrantedExcludeRevokeWhenRequestedPermissions || + !isBackground && group.foreground.isGrantedExcludeRevokeWhenRequestedPermissions) { // If FINE location is not granted, do not grant it automatically when COARSE // location is already granted. if (group.permGroupName == LOCATION && |