diff options
author | Nate Myren <ntmyren@google.com> | 2023-05-16 15:31:07 -0700 |
---|---|---|
committer | Nate Myren <ntmyren@google.com> | 2023-05-30 20:39:23 +0000 |
commit | da9397b984d0e9d5a1e071756fe3d0845f81fe05 (patch) | |
tree | d075f20315245db05900d2d641afb07aab636245 /PermissionController/src/com/android/permissioncontroller/permission | |
parent | aa588a87e98d6016fa364119a223d562919aafa8 (diff) | |
download | Permission-da9397b984d0e9d5a1e071756fe3d0845f81fe05.tar.gz |
Auto grant full location group if device or app SDK < R
Due to an oversight, parts of the the fine/coarse location split behavior which happened in S was being extended back to R- devices and apps
Bug: 283002814
Relnote: Fix bug affecting grant dialog behavior on R- apps and devices
Test: atest LocationAccuracyTest
Change-Id: I96f319df42896e19b4e3cc68e7457c70a968413c
Diffstat (limited to 'PermissionController/src/com/android/permissioncontroller/permission')
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt | 13 |
1 files changed, 9 insertions, 4 deletions
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 24dc51bdf..2378909b9 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/GrantPermissionsViewModel.kt @@ -516,8 +516,8 @@ class GrantPermissionsViewModel( // Show location permission dialogs based on location permissions val locationVisibilities = MutableList(NEXT_LOCATION_DIALOG) { false } - if (groupState.group.permGroupName == LOCATION && isLocationAccuracyEnabled() && - packageInfo.targetSdkVersion >= Build.VERSION_CODES.S) { + if (groupState.group.permGroupName == LOCATION && + isLocationAccuracyEnabledForApp(groupState.group)) { if (needFgPermissions) { locationVisibilities[LOCATION_ACCURACY_LAYOUT] = true if (fgState != null && @@ -764,7 +764,7 @@ class GrantPermissionsViewModel( // Skip showing groups that we know cannot be granted. return false } else if (subGroup.isUserFixed) { - if (perm == ACCESS_COARSE_LOCATION) { + if (perm == ACCESS_COARSE_LOCATION && isLocationAccuracyEnabledForApp(group)) { val coarsePerm = group.permissions[perm] if (coarsePerm != null && !coarsePerm.isUserFixed) { // If the location group is user fixed but ACCESS_COARSE_LOCATION is not, then @@ -868,7 +868,7 @@ class GrantPermissionsViewModel( private fun canAutoGrantWholeGroup(group: LightAppPermGroup): Boolean { // If FINE location is not granted, do not grant it automatically when COARSE // location is already granted. - if (group.permGroupName == LOCATION && + if (group.permGroupName == LOCATION && isLocationAccuracyEnabledForApp(group) && group.allPermissions[ACCESS_FINE_LOCATION]?.isGrantedIncludingAppOp == false) { return false } @@ -1473,6 +1473,11 @@ class GrantPermissionsViewModel( } } + private fun isLocationAccuracyEnabledForApp(group: LightAppPermGroup): Boolean { + return isLocationAccuracyEnabled() && + group.packageInfo.targetSdkVersion >= Build.VERSION_CODES.S + } + /** * Log all permission groups which were requested */ |