diff options
author | 2021-05-10 21:57:35 +0000 | |
---|---|---|
committer | 2021-05-10 21:57:35 +0000 | |
commit | f3ab17da088fe5c4253abe202dc36a9db0e3fc99 (patch) | |
tree | fc3b2277a9f3f83185c3414ef086934cde7dce36 | |
parent | 90d2ca262ffdfdb4537a7430bc97c93377d96847 (diff) | |
parent | 019d2fe0a28550a6ab7c6db16cddef3e5496c428 (diff) |
Merge "Fix a bug and add background access summary text" into sc-dev
3 files changed, 26 insertions, 13 deletions
diff --git a/PermissionController/res/values/strings.xml b/PermissionController/res/values/strings.xml index cfb434fa5..b021ebacf 100644 --- a/PermissionController/res/values/strings.xml +++ b/PermissionController/res/values/strings.xml @@ -849,6 +849,9 @@ <!-- Subtitle for a storage preference that is currently granted for all files. [CHAR LIMIT=60] --> <string name="permission_subtitle_all_files">All Files</string> + <!-- Subtitle for the preference that the permission is currently always granted. [CHAR LIMIT=60] --> + <string name="permission_subtitle_background">Allowed all the time</string> + <!-- Summary for showing the last access text for sensor data permissions for today [CHAR LIMIT=70] --> <string name="app_perms_24h_access">Last accessed <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g></string> @@ -858,14 +861,14 @@ <!-- Summary for showing the last access text for content provider permissions [CHAR LIMIT=70] --> <string name="app_perms_content_provider">Accessed in past 24 hours</string> - <!-- Subtitle for the preference that is currently granted only when the app is in the foreground. [CHAR LIMIT=70] --> - <string name="app_perms_24h_access_only_in_foreground">Last accessed <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g> \u2022 Only while app is in use</string> + <!-- Subtitle for the preference that the permission is currently always granted. [CHAR LIMIT=70] --> + <string name="app_perms_24h_access_background">Last accessed <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g> \u2022 Allowed all the time</string> - <!-- Subtitle for the preference that is currently granted only when the app is in the foreground. [CHAR LIMIT=70] --> - <string name="app_perms_24h_access_yest_only_in_foreground">Last accessed yesterday at <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g> \u2022 Only while app is in use</string> + <!-- Subtitle for the preference that the permission is currently always granted. [CHAR LIMIT=70] --> + <string name="app_perms_24h_access_yest_background">Last accessed yesterday at <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g> \u2022 Allowed all the time</string> - <!-- Subtitle for the preference that is currently granted only when the app is in the foreground. [CHAR LIMIT=70] --> - <string name="app_perms_content_provider_only_in_foreground">Accessed in past 24 hours \u2022 Only while app is in use</string> + <!-- Subtitle for the preference that the permission is currently always granted. [CHAR LIMIT=70] --> + <string name="app_perms_content_provider_background">Accessed in past 24 hours \u2022 Allowed all the time</string> <!-- Subtitle for a storage preference that is currently granted for Media files only. [CHAR LIMIT=70] --> <string name="app_perms_24h_access_media_only">Last accessed <xliff:g id="time_date" example="12:42 PM">%1$s</xliff:g> \u2022 Media</string> diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionGroupsFragment.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionGroupsFragment.java index 67f3dcb6d..49aee7e08 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionGroupsFragment.java +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/AppPermissionGroupsFragment.java @@ -296,6 +296,12 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader i continue; } + // We might have another AppPermissionUsage entry that's of the same packageName + // but with a different uid. In that case, we want to grab the max lastAccessTime + // as the last usage to show. + lastAccessTime = Math.max( + accessTime.getOrDefault(groupName, Instant.EPOCH.toEpochMilli()), + lastAccessTime); accessTime.put(groupName, lastAccessTime); } } @@ -375,27 +381,27 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader i preference.setIcon(KotlinUtils.INSTANCE.getPermGroupIcon(context, groupName)); preference.setKey(groupName); switch (groupInfo.getSubtitle()) { - case FOREGROUND_ONLY: + case BACKGROUND: switch (lastAccessType) { case LAST_24H_CONTENT_PROVIDER: preference.setSummary( - R.string.app_perms_content_provider_only_in_foreground); + R.string.app_perms_content_provider_background); break; case LAST_24H_SENSOR_TODAY: preference.setSummary( getString( - R.string.app_perms_24h_access_only_in_foreground, + R.string.app_perms_24h_access_background, lastAccessTimeFormatted)); break; case LAST_24H_SENSOR_YESTERDAY: preference.setSummary(getString( - R.string.app_perms_24h_access_yest_only_in_foreground, + R.string.app_perms_24h_access_yest_background, lastAccessTimeFormatted)); break; case NOT_IN_LAST_24H: default: preference.setSummary( - R.string.permission_subtitle_only_in_foreground); + R.string.permission_subtitle_background); } break; @@ -447,6 +453,8 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader i } break; + case FOREGROUND_ONLY: + // We don't want to note the foreground access default: switch (lastAccessType) { case LAST_24H_CONTENT_PROVIDER: diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/AppPermissionGroupsViewModel.kt b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/AppPermissionGroupsViewModel.kt index f6e6814b9..afedeca5c 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/model/AppPermissionGroupsViewModel.kt +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/model/AppPermissionGroupsViewModel.kt @@ -74,6 +74,7 @@ class AppPermissionGroupsViewModel( MEDIA_ONLY(1), ALL_FILES(2), FOREGROUND_ONLY(3), + BACKGROUND(4), } data class GroupUiInfo( @@ -168,10 +169,11 @@ class AppPermissionGroupsViewModel( GroupUiInfo(groupName, isSystem, subtitle)) } PermGrantState.PERMS_ALLOWED_ALWAYS -> groupGrantStates[ - Category.ALLOWED]!!.add(GroupUiInfo(groupName, isSystem)) + Category.ALLOWED]!!.add(GroupUiInfo(groupName, isSystem, + PermSubtitle.BACKGROUND)) PermGrantState.PERMS_ALLOWED_FOREGROUND_ONLY -> groupGrantStates[ Category.ALLOWED]!!.add(GroupUiInfo(groupName, isSystem, - PermSubtitle.FOREGROUND_ONLY)) + PermSubtitle.FOREGROUND_ONLY)) PermGrantState.PERMS_DENIED -> groupGrantStates[Category.DENIED]!!.add( GroupUiInfo(groupName, isSystem)) PermGrantState.PERMS_ASK -> groupGrantStates[Category.ASK]!!.add( |