Fixes to Privacy Dialog

* Change new line into space for attribution
* Fix location icon
* Show all actives instead of the latest one

Test: manual
Test: atest PrivacyDialogControllerTest
Fixes: 178805176
Change-Id: I06336f65efd2db9d9cebca4a65017ead2b885511
This commit is contained in:
Fabian Kozynski
2021-01-29 13:11:18 -05:00
parent 467776a81b
commit 8cff86295e
4 changed files with 13 additions and 13 deletions

View File

@@ -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>

View File

@@ -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

View File

@@ -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()
}
}
}

View File

@@ -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