diff options
| author | 2021-02-02 17:20:08 +0000 | |
|---|---|---|
| committer | 2021-02-02 17:20:08 +0000 | |
| commit | 31653b08ecf0faeda9c7eaca5282df9d54b5bd6e (patch) | |
| tree | d40236ac55c45522572cd8b1ae6c5f197249087f | |
| parent | 14edd62216032f8756e7d7327328bdb96ed18b5b (diff) | |
| parent | 8cff86295e0b8bf93c5c97c075efa505ac3a976a (diff) | |
Merge "Fixes to Privacy Dialog" into sc-dev
4 files changed, 13 insertions, 13 deletions
diff --git a/packages/SystemUI/res/drawable/privacy_item_circle_location.xml b/packages/SystemUI/res/drawable/privacy_item_circle_location.xml index 28466c8a29b3..bff9b4b48b86 100644 --- a/packages/SystemUI/res/drawable/privacy_item_circle_location.xml +++ b/packages/SystemUI/res/drawable/privacy_item_circle_location.xml @@ -31,6 +31,6 @@ android:gravity="center" android:width="@dimen/ongoing_appops_dialog_icon_size" android:height="@dimen/ongoing_appops_dialog_icon_size" - android:drawable="@*android:drawable/perm_group_microphone" + android:drawable="@*android:drawable/perm_group_location" /> </layer-list>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt index c3d6a848202f..3f79be8fcdd4 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt @@ -123,7 +123,7 @@ class PrivacyDialog( val finalText = element.attribution?.let { TextUtils.concat( firstLine, - "\n", + " ", context.getString(R.string.ongoing_privacy_dialog_attribution_text, it) ) } ?: firstLine diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt index 99e9bfc24e1d..8b6c04fb3b01 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt @@ -227,21 +227,20 @@ class PrivacyDialogController( /** * Filters the list of elements to show. * - * * Return at most one element per [PrivacyType], sorted by the natural order of the - * [PrivacyType]. - * * If there are no active usages for a type, return the most recent - * * If there are multiple active usages for a type, return the most active recent. + * For each privacy type, it'll return all active elements. If there are no active elements, + * it'll return the most recent access */ private fun filterAndSelect( list: List<PrivacyDialog.PrivacyElement> ): List<PrivacyDialog.PrivacyElement> { - return list.groupBy { it.type }.toSortedMap().mapNotNull { entry -> - if (entry.value.isEmpty()) { - null + return list.groupBy { it.type }.toSortedMap().flatMap { (_, elements) -> + val actives = elements.filter { it.active } + if (actives.isNotEmpty()) { + actives.sortedByDescending { it.lastActiveTimestamp } } else { - val actives = entry.value.filter { it.active } - val out = if (actives.isNotEmpty()) actives else entry.value - out.maxByOrNull { it.lastActiveTimestamp } + elements.maxByOrNull { it.lastActiveTimestamp }?.let { + listOf(it) + } ?: emptyList() } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt index 25468130ed5c..f86b4651056b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt @@ -295,8 +295,9 @@ class PrivacyDialogControllerTest : SysuiTestCase() { ) controller.showDialog(context) exhaustExecutors() - assertThat(dialogProvider.list).hasSize(1) + assertThat(dialogProvider.list).hasSize(2) assertThat(dialogProvider.list?.get(0)?.lastActiveTimestamp).isEqualTo(1L) + assertThat(dialogProvider.list?.get(1)?.lastActiveTimestamp).isEqualTo(0L) } @Test |