Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +7 −24 Original line number Diff line number Diff line Loading @@ -296,7 +296,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test fun chips_twoChips_samePackage_differentUids_bothIncluded() = fun chips_twoChips_samePackage_differentUids_onlyLaterOneIncluded() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -322,8 +322,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) ) // Notif added later takes priority assertThat(latest!!.map { it.key }).containsExactly("notif2", "notif1").inOrder() // Notif added later takes priority and is the only one assertThat(latest!!.map { it.key }).containsExactly("notif2").inOrder() } @Test Loading Loading @@ -362,7 +362,6 @@ class NotifChipsViewModelTest : SysuiTestCase() { kosmos.runTest { val latest by collectLastValue(underTest.chips) val uid = 3 fakeSystemClock.setCurrentTimeMillis(1000) activeNotificationListRepository.addNotif( activeNotificationModel( Loading @@ -385,7 +384,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) ) // Notif added later takes priority // Notif added later takes priority and is the only one assertThat(latest!!.map { it.key }).containsExactly("notif2").inOrder() } Loading Loading @@ -434,7 +433,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { activeNotificationModel( key = "secondPackage.2", packageName = "secondPackage", uid = 2, uid = 20, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.2").build(), ) Loading @@ -445,31 +444,15 @@ class NotifChipsViewModelTest : SysuiTestCase() { activeNotificationModel( key = "secondPackage.3", packageName = "secondPackage", uid = 2, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.3").build(), ) ) fakeSystemClock.advanceTime(1000) activeNotificationListRepository.addNotif( activeNotificationModel( key = "secondPackage.andDifferentUid", packageName = "secondPackage", uid = 200, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.andDifferentUid").build(), promotedContent = PromotedNotificationContentBuilder("secondPackage.3").build(), ) ) // Notifs added later take priority assertThat(latest!!.map { it.key }) .containsExactly( "secondPackage.andDifferentUid", "secondPackage.3", "firstPackage.2", ) .containsExactly("secondPackage.3", "firstPackage.2") .inOrder() } Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt +0 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,6 @@ constructor( key = key, appName = appName, packageName = packageName, uid = uid, statusBarChipIconView = statusBarChipIconView, promotedContent = promotedContent, creationTime = creationTime, Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt +0 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ data class NotificationChipModel( val appName: String, /** The notifying app's package name. */ val packageName: String, /** The notifying app's [packageName]'s uid. */ val uid: Int, val statusBarChipIconView: StatusBarIconView?, val promotedContent: PromotedNotificationContentModels, /** The time when the notification first appeared as promoted. */ Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +5 −5 Original line number Diff line number Diff line Loading @@ -64,15 +64,15 @@ constructor( */ private val notificationChipsWithPrunedContent: Flow<List<PrunedNotificationChipModel>> = notifChipsInteractor.allNotificationChips .map { chips -> chips.filterByPackagePerUser().map { it.toPrunedModel() } } .map { chips -> chips.filterByPackage().map { it.toPrunedModel() } } .distinctUntilChanged() /** * Filters all the chips down to just the most important chip per package per user so we don't * show multiple chips for the same app. * Filters all the chips down to just the most important chip per package so we don't show * multiple chips for the same app. */ private fun List<NotificationChipModel>.filterByPackagePerUser(): List<NotificationChipModel> { return this.groupBy { Pair(it.packageName, it.uid) }.map { (_, chips) -> chips[0] } private fun List<NotificationChipModel>.filterByPackage(): List<NotificationChipModel> { return this.groupBy { it.packageName }.map { (_, chips) -> chips[0] } } private fun NotificationChipModel.toPrunedModel(): PrunedNotificationChipModel { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +7 −24 Original line number Diff line number Diff line Loading @@ -296,7 +296,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test fun chips_twoChips_samePackage_differentUids_bothIncluded() = fun chips_twoChips_samePackage_differentUids_onlyLaterOneIncluded() = kosmos.runTest { val latest by collectLastValue(underTest.chips) Loading @@ -322,8 +322,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) ) // Notif added later takes priority assertThat(latest!!.map { it.key }).containsExactly("notif2", "notif1").inOrder() // Notif added later takes priority and is the only one assertThat(latest!!.map { it.key }).containsExactly("notif2").inOrder() } @Test Loading Loading @@ -362,7 +362,6 @@ class NotifChipsViewModelTest : SysuiTestCase() { kosmos.runTest { val latest by collectLastValue(underTest.chips) val uid = 3 fakeSystemClock.setCurrentTimeMillis(1000) activeNotificationListRepository.addNotif( activeNotificationModel( Loading @@ -385,7 +384,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) ) // Notif added later takes priority // Notif added later takes priority and is the only one assertThat(latest!!.map { it.key }).containsExactly("notif2").inOrder() } Loading Loading @@ -434,7 +433,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { activeNotificationModel( key = "secondPackage.2", packageName = "secondPackage", uid = 2, uid = 20, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.2").build(), ) Loading @@ -445,31 +444,15 @@ class NotifChipsViewModelTest : SysuiTestCase() { activeNotificationModel( key = "secondPackage.3", packageName = "secondPackage", uid = 2, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.3").build(), ) ) fakeSystemClock.advanceTime(1000) activeNotificationListRepository.addNotif( activeNotificationModel( key = "secondPackage.andDifferentUid", packageName = "secondPackage", uid = 200, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentBuilder("secondPackage.andDifferentUid").build(), promotedContent = PromotedNotificationContentBuilder("secondPackage.3").build(), ) ) // Notifs added later take priority assertThat(latest!!.map { it.key }) .containsExactly( "secondPackage.andDifferentUid", "secondPackage.3", "firstPackage.2", ) .containsExactly("secondPackage.3", "firstPackage.2") .inOrder() } Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt +0 −1 Original line number Diff line number Diff line Loading @@ -145,7 +145,6 @@ constructor( key = key, appName = appName, packageName = packageName, uid = uid, statusBarChipIconView = statusBarChipIconView, promotedContent = promotedContent, creationTime = creationTime, Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt +0 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ data class NotificationChipModel( val appName: String, /** The notifying app's package name. */ val packageName: String, /** The notifying app's [packageName]'s uid. */ val uid: Int, val statusBarChipIconView: StatusBarIconView?, val promotedContent: PromotedNotificationContentModels, /** The time when the notification first appeared as promoted. */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +5 −5 Original line number Diff line number Diff line Loading @@ -64,15 +64,15 @@ constructor( */ private val notificationChipsWithPrunedContent: Flow<List<PrunedNotificationChipModel>> = notifChipsInteractor.allNotificationChips .map { chips -> chips.filterByPackagePerUser().map { it.toPrunedModel() } } .map { chips -> chips.filterByPackage().map { it.toPrunedModel() } } .distinctUntilChanged() /** * Filters all the chips down to just the most important chip per package per user so we don't * show multiple chips for the same app. * Filters all the chips down to just the most important chip per package so we don't show * multiple chips for the same app. */ private fun List<NotificationChipModel>.filterByPackagePerUser(): List<NotificationChipModel> { return this.groupBy { Pair(it.packageName, it.uid) }.map { (_, chips) -> chips[0] } private fun List<NotificationChipModel>.filterByPackage(): List<NotificationChipModel> { return this.groupBy { it.packageName }.map { (_, chips) -> chips[0] } } private fun NotificationChipModel.toPrunedModel(): PrunedNotificationChipModel { Loading