Loading packages/SystemUI/res/drawable/privacy_item_circle_location.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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 packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt +9 −10 Original line number Diff line number Diff line Loading @@ -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() } } } Loading packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
packages/SystemUI/res/drawable/privacy_item_circle_location.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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
packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogController.kt +9 −10 Original line number Diff line number Diff line Loading @@ -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() } } } Loading
packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyDialogControllerTest.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading