Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationVisibilityProviderImpl.kt +12 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,17 @@ import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor import com.android.systemui.statusbar.notification.logging.NotificationLogger import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor import javax.inject.Inject /** pipeline-agnostic implementation for getting [NotificationVisibility]. */ @SysUISingleton class NotificationVisibilityProviderImpl @Inject constructor( class NotificationVisibilityProviderImpl @Inject constructor( private val activeNotificationsInteractor: ActiveNotificationsInteractor, private val notifDataStore: NotifLiveDataStore, private val notifCollection: CommonNotifCollection ) : NotificationVisibilityProvider { Loading @@ -47,5 +52,10 @@ class NotificationVisibilityProviderImpl @Inject constructor( override fun getLocation(key: String): NotificationVisibility.NotificationLocation = NotificationLogger.getNotificationLocation(notifCollection.getEntry(key)) private fun getCount() = notifDataStore.activeNotifCount.value private fun getCount() = if (NotificationsLiveDataStoreRefactor.isEnabled) { activeNotificationsInteractor.allNotificationsCountValue } else { notifDataStore.activeNotifCount.value } } packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt +9 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,15 @@ constructor( val allRepresentativeNotifications: Flow<Map<String, ActiveNotificationModel>> = repository.activeNotifications.map { store -> store.individuals } /** Size of the flattened list of Notifications actively presented in the stack. */ val allNotificationsCount: Flow<Int> = repository.activeNotifications.map { store -> store.individuals.size } /** * The same as [allNotificationsCount], but without flows, for easy access in synchronous code. */ val allNotificationsCountValue: Int = repository.activeNotifications.value.individuals.size /** Are any notifications being actively presented in the notification stack? */ val areAnyNotificationsPresent: Flow<Boolean> = repository.activeNotifications Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractorTest.kt +12 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,18 @@ class ActiveNotificationsInteractorTest : SysuiTestCase() { private val testComponent: TestComponent = DaggerActiveNotificationsInteractorTest_TestComponent.factory().create(test = this) @Test fun testAllNotificationsCount() = testComponent.runTest { val count by collectLastValue(underTest.allNotificationsCount) activeNotificationListRepository.setActiveNotifs(5) runCurrent() assertThat(count).isEqualTo(5) assertThat(underTest.allNotificationsCountValue).isEqualTo(5) } @Test fun testAreAnyNotificationsPresent_isTrue() = testComponent.runTest { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/NotificationVisibilityProviderImpl.kt +12 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,17 @@ import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor import com.android.systemui.statusbar.notification.logging.NotificationLogger import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor import javax.inject.Inject /** pipeline-agnostic implementation for getting [NotificationVisibility]. */ @SysUISingleton class NotificationVisibilityProviderImpl @Inject constructor( class NotificationVisibilityProviderImpl @Inject constructor( private val activeNotificationsInteractor: ActiveNotificationsInteractor, private val notifDataStore: NotifLiveDataStore, private val notifCollection: CommonNotifCollection ) : NotificationVisibilityProvider { Loading @@ -47,5 +52,10 @@ class NotificationVisibilityProviderImpl @Inject constructor( override fun getLocation(key: String): NotificationVisibility.NotificationLocation = NotificationLogger.getNotificationLocation(notifCollection.getEntry(key)) private fun getCount() = notifDataStore.activeNotifCount.value private fun getCount() = if (NotificationsLiveDataStoreRefactor.isEnabled) { activeNotificationsInteractor.allNotificationsCountValue } else { notifDataStore.activeNotifCount.value } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractor.kt +9 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,15 @@ constructor( val allRepresentativeNotifications: Flow<Map<String, ActiveNotificationModel>> = repository.activeNotifications.map { store -> store.individuals } /** Size of the flattened list of Notifications actively presented in the stack. */ val allNotificationsCount: Flow<Int> = repository.activeNotifications.map { store -> store.individuals.size } /** * The same as [allNotificationsCount], but without flows, for easy access in synchronous code. */ val allNotificationsCountValue: Int = repository.activeNotifications.value.individuals.size /** Are any notifications being actively presented in the notification stack? */ val areAnyNotificationsPresent: Flow<Boolean> = repository.activeNotifications Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/domain/interactor/ActiveNotificationsInteractorTest.kt +12 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,18 @@ class ActiveNotificationsInteractorTest : SysuiTestCase() { private val testComponent: TestComponent = DaggerActiveNotificationsInteractorTest_TestComponent.factory().create(test = this) @Test fun testAllNotificationsCount() = testComponent.runTest { val count by collectLastValue(underTest.allNotificationsCount) activeNotificationListRepository.setActiveNotifs(5) runCurrent() assertThat(count).isEqualTo(5) assertThat(underTest.allNotificationsCountValue).isEqualTo(5) } @Test fun testAreAnyNotificationsPresent_isTrue() = testComponent.runTest { Loading