Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/PromotedNotificationsInteractorTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { ) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN the ron is first because the call has no content assertThat(topPromotedNotificationContent?.identity?.key) Loading @@ -131,7 +131,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { ) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN the call is the top notification assertThat(topPromotedNotificationContent?.identity?.key) Loading @@ -148,7 +148,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { renderNotificationListInteractor.setRenderedList(listOf(callEntry, otherEntry)) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN there is no top promoted notification assertThat(topPromotedNotificationContent).isNull() Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/AODPromotedNotificationInteractor.kt +2 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.notification.promoted.domain.interactor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style import com.android.systemui.util.kotlin.FlowDumperImpl import javax.inject.Inject import kotlinx.coroutines.flow.Flow Loading @@ -34,10 +33,7 @@ constructor( ) : FlowDumperImpl(dumpManager) { /** The content to show as the promoted notification on AOD */ val content: Flow<PromotedNotificationContentModel?> = promotedNotificationsInteractor.topPromotedNotificationContent promotedNotificationsInteractor.aodPromotedNotification val isPresent: Flow<Boolean> = content .map { (it != null) && (it.style != Style.Ineligible) } .dumpWhileCollecting("isPresent") val isPresent: Flow<Boolean> = content.map { it != null }.dumpWhileCollecting("isPresent") } packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/PromotedNotificationsInteractor.kt +15 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import com.android.systemui.statusbar.chips.call.domain.interactor.CallChipInter import com.android.systemui.statusbar.chips.notification.domain.interactor.StatusBarNotificationChipsInteractor import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style.Ineligible import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher Loading Loading @@ -83,13 +85,13 @@ constructor( .map { list -> list.firstNotNullOfOrNull { it.promotedContent } } .distinctUntilNewInstance() /** This is the top-most promoted notification, which should avoid regular changing. */ val topPromotedNotificationContent: Flow<PromotedNotificationContentModel?> = /** This is the AOD promoted notification, which should avoid regular changing. */ val aodPromotedNotification: Flow<PromotedNotificationContentModel?> = combine( topPromotedChipNotification, activeNotificationsInteractor.topLevelRepresentativeNotifications, ) { topChipNotif, topLevelNotifs -> topChipNotif ?: topLevelNotifs.firstNotNullOfOrNull { it.promotedContent } topChipNotif?.takeIfAodEligible() ?: topLevelNotifs.firstAodEligibleOrNull() } // #equals() can be a bit expensive on this object, but this flow will regularly try to // emit the same immutable instance over and over, so just prevent that. Loading @@ -105,6 +107,16 @@ constructor( .distinctUntilChanged() .flowOn(backgroundDispatcher) private fun List<ActiveNotificationModel>.firstAodEligibleOrNull(): PromotedNotificationContentModel? { return this.firstNotNullOfOrNull { it.promotedContent?.takeIfAodEligible() } } private fun PromotedNotificationContentModel.takeIfAodEligible(): PromotedNotificationContentModel? { return this.takeUnless { it.style == Ineligible } } /** * Returns flow where all subsequent repetitions of the same object instance are filtered out. */ Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/PromotedNotificationsInteractorTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { ) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN the ron is first because the call has no content assertThat(topPromotedNotificationContent?.identity?.key) Loading @@ -131,7 +131,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { ) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN the call is the top notification assertThat(topPromotedNotificationContent?.identity?.key) Loading @@ -148,7 +148,7 @@ class PromotedNotificationsInteractorTest : SysuiTestCase() { renderNotificationListInteractor.setRenderedList(listOf(callEntry, otherEntry)) val topPromotedNotificationContent by collectLastValue(underTest.topPromotedNotificationContent) collectLastValue(underTest.aodPromotedNotification) // THEN there is no top promoted notification assertThat(topPromotedNotificationContent).isNull() Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/AODPromotedNotificationInteractor.kt +2 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.notification.promoted.domain.interactor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style import com.android.systemui.util.kotlin.FlowDumperImpl import javax.inject.Inject import kotlinx.coroutines.flow.Flow Loading @@ -34,10 +33,7 @@ constructor( ) : FlowDumperImpl(dumpManager) { /** The content to show as the promoted notification on AOD */ val content: Flow<PromotedNotificationContentModel?> = promotedNotificationsInteractor.topPromotedNotificationContent promotedNotificationsInteractor.aodPromotedNotification val isPresent: Flow<Boolean> = content .map { (it != null) && (it.style != Style.Ineligible) } .dumpWhileCollecting("isPresent") val isPresent: Flow<Boolean> = content.map { it != null }.dumpWhileCollecting("isPresent") }
packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/domain/interactor/PromotedNotificationsInteractor.kt +15 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import com.android.systemui.statusbar.chips.call.domain.interactor.CallChipInter import com.android.systemui.statusbar.chips.notification.domain.interactor.StatusBarNotificationChipsInteractor import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style.Ineligible import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher Loading Loading @@ -83,13 +85,13 @@ constructor( .map { list -> list.firstNotNullOfOrNull { it.promotedContent } } .distinctUntilNewInstance() /** This is the top-most promoted notification, which should avoid regular changing. */ val topPromotedNotificationContent: Flow<PromotedNotificationContentModel?> = /** This is the AOD promoted notification, which should avoid regular changing. */ val aodPromotedNotification: Flow<PromotedNotificationContentModel?> = combine( topPromotedChipNotification, activeNotificationsInteractor.topLevelRepresentativeNotifications, ) { topChipNotif, topLevelNotifs -> topChipNotif ?: topLevelNotifs.firstNotNullOfOrNull { it.promotedContent } topChipNotif?.takeIfAodEligible() ?: topLevelNotifs.firstAodEligibleOrNull() } // #equals() can be a bit expensive on this object, but this flow will regularly try to // emit the same immutable instance over and over, so just prevent that. Loading @@ -105,6 +107,16 @@ constructor( .distinctUntilChanged() .flowOn(backgroundDispatcher) private fun List<ActiveNotificationModel>.firstAodEligibleOrNull(): PromotedNotificationContentModel? { return this.firstNotNullOfOrNull { it.promotedContent?.takeIfAodEligible() } } private fun PromotedNotificationContentModel.takeIfAodEligible(): PromotedNotificationContentModel? { return this.takeUnless { it.style == Ineligible } } /** * Returns flow where all subsequent repetitions of the same object instance are filtered out. */ Loading