Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 511030f6 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "Use ActiveNotificationsInteractor in NotificationVisibilityProviderImpl" into main

parents 36bfc0d7 14eabcd6
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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 {
@@ -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
        }
}
+9 −0
Original line number Diff line number Diff line
@@ -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
+12 −0
Original line number Diff line number Diff line
@@ -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 {