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

Commit 28aa66d2 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Hide redundant AOD RON icon from shelf

Bug: 369151941
Flag: com.android.systemui.aod_ui_rich_ongoing
Test: manual
Change-Id: Ida892d3265a2d558b63bb20a16797702094ed255
parent f1826687
Loading
Loading
Loading
Loading
+30 −0
Original line number Original line Diff line number Diff line
@@ -32,8 +32,12 @@ import com.android.systemui.statusbar.notification.data.repository.activeNotific
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.headsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.domain.interactor.headsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.promoted.domain.interactor.aodPromotedNotificationInteractor
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style.Base
import com.android.systemui.statusbar.notification.shared.byIsAmbient
import com.android.systemui.statusbar.notification.shared.byIsAmbient
import com.android.systemui.statusbar.notification.shared.byIsLastMessageFromReply
import com.android.systemui.statusbar.notification.shared.byIsLastMessageFromReply
import com.android.systemui.statusbar.notification.shared.byIsPromoted
import com.android.systemui.statusbar.notification.shared.byIsPulsing
import com.android.systemui.statusbar.notification.shared.byIsPulsing
import com.android.systemui.statusbar.notification.shared.byIsRowDismissed
import com.android.systemui.statusbar.notification.shared.byIsRowDismissed
import com.android.systemui.statusbar.notification.shared.byIsSilent
import com.android.systemui.statusbar.notification.shared.byIsSilent
@@ -58,12 +62,14 @@ class NotificationIconsInteractorTest : SysuiTestCase() {
    private val testScope = kosmos.testScope
    private val testScope = kosmos.testScope
    private val activeNotificationListRepository = kosmos.activeNotificationListRepository
    private val activeNotificationListRepository = kosmos.activeNotificationListRepository
    private val notificationsKeyguardInteractor = kosmos.notificationsKeyguardInteractor
    private val notificationsKeyguardInteractor = kosmos.notificationsKeyguardInteractor
    private val aodPromotedNotificationInteractor = kosmos.aodPromotedNotificationInteractor


    private val underTest =
    private val underTest =
        NotificationIconsInteractor(
        NotificationIconsInteractor(
            kosmos.activeNotificationsInteractor,
            kosmos.activeNotificationsInteractor,
            kosmos.bubblesOptional,
            kosmos.bubblesOptional,
            kosmos.headsUpNotificationIconInteractor,
            kosmos.headsUpNotificationIconInteractor,
            kosmos.aodPromotedNotificationInteractor,
            kosmos.notificationsKeyguardViewStateRepository,
            kosmos.notificationsKeyguardViewStateRepository,
        )
        )


@@ -141,6 +147,22 @@ class NotificationIconsInteractorTest : SysuiTestCase() {
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true)
            assertThat(filteredSet).comparingElementsUsing(byIsPulsing).contains(true)
        }
        }

    @Test
    fun filteredEntrySet_showAodPromoted() {
        testScope.runTest {
            val filteredSet by collectLastValue(underTest.filteredNotifSet(showAodPromoted = true))
            assertThat(filteredSet).comparingElementsUsing(byIsPromoted).contains(true)
        }
    }

    @Test
    fun filteredEntrySet_noAodPromoted() {
        testScope.runTest {
            val filteredSet by collectLastValue(underTest.filteredNotifSet(showAodPromoted = false))
            assertThat(filteredSet).comparingElementsUsing(byIsPromoted).doesNotContain(true)
        }
    }
}
}


@SmallTest
@SmallTest
@@ -326,4 +348,12 @@ private val testIcons =
        activeNotificationModel(key = "notif5", isLastMessageFromReply = true),
        activeNotificationModel(key = "notif5", isLastMessageFromReply = true),
        activeNotificationModel(key = "notif6", isSuppressedFromStatusBar = true),
        activeNotificationModel(key = "notif6", isSuppressedFromStatusBar = true),
        activeNotificationModel(key = "notif7", isPulsing = true),
        activeNotificationModel(key = "notif7", isPulsing = true),
        activeNotificationModel(key = "notif8", promotedContent = promotedContent("notif8", Base)),
    )
    )

private fun promotedContent(
    key: String,
    style: PromotedNotificationContentModel.Style,
): PromotedNotificationContentModel {
    return PromotedNotificationContentModel.Builder(key).apply { this.style = style }.build()
}
+6 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,12 @@ val byIsRowDismissed: Correspondence<ActiveNotificationModel, Boolean> =
val byIsLastMessageFromReply: Correspondence<ActiveNotificationModel, Boolean> =
val byIsLastMessageFromReply: Correspondence<ActiveNotificationModel, Boolean> =
    Correspondence.transforming(
    Correspondence.transforming(
        { it?.isLastMessageFromReply },
        { it?.isLastMessageFromReply },
        "has an isLastMessageFromReply value of"
        "has an isLastMessageFromReply value of",
    )
    )
val byIsPulsing: Correspondence<ActiveNotificationModel, Boolean> =
val byIsPulsing: Correspondence<ActiveNotificationModel, Boolean> =
    Correspondence.transforming({ it?.isPulsing }, "has an isPulsing value of")
    Correspondence.transforming({ it?.isPulsing }, "has an isPulsing value of")
val byIsPromoted: Correspondence<ActiveNotificationModel, Boolean> =
    Correspondence.transforming(
        { it?.promotedContent != null },
        "has (or doesn't have) a promoted content model",
    )
+22 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.systemui.statusbar.data.repository.NotificationListenerSettin
import com.android.systemui.statusbar.notification.data.repository.NotificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.data.repository.NotificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.promoted.domain.interactor.AODPromotedNotificationInteractor
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel
import com.android.wm.shell.bubbles.Bubbles
import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
import java.util.Optional
@@ -30,6 +31,7 @@ import kotlin.jvm.optionals.getOrNull
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.flowOn


/** Domain logic related to notification icons. */
/** Domain logic related to notification icons. */
@@ -39,8 +41,21 @@ constructor(
    private val activeNotificationsInteractor: ActiveNotificationsInteractor,
    private val activeNotificationsInteractor: ActiveNotificationsInteractor,
    private val bubbles: Optional<Bubbles>,
    private val bubbles: Optional<Bubbles>,
    private val headsUpNotificationIconInteractor: HeadsUpNotificationIconInteractor,
    private val headsUpNotificationIconInteractor: HeadsUpNotificationIconInteractor,
    private val aodPromotedNotificationInteractor: AODPromotedNotificationInteractor,
    private val keyguardViewStateRepository: NotificationsKeyguardViewStateRepository,
    private val keyguardViewStateRepository: NotificationsKeyguardViewStateRepository,
) {
) {
    private val aodPromotedKeyToHide: Flow<String?> =
        combine(
            aodPromotedNotificationInteractor.content,
            aodPromotedNotificationInteractor.isPresent,
        ) { content, isPresent ->
            when {
                !isPresent -> null
                content == null -> null
                else -> content.identity.key
            }
        }

    /** Returns a subset of all active notifications based on the supplied filtration parameters. */
    /** Returns a subset of all active notifications based on the supplied filtration parameters. */
    fun filteredNotifSet(
    fun filteredNotifSet(
        forceShowHeadsUp: Boolean = false,
        forceShowHeadsUp: Boolean = false,
@@ -49,12 +64,14 @@ constructor(
        showDismissed: Boolean = true,
        showDismissed: Boolean = true,
        showRepliedMessages: Boolean = true,
        showRepliedMessages: Boolean = true,
        showPulsing: Boolean = true,
        showPulsing: Boolean = true,
        showAodPromoted: Boolean = true,
    ): Flow<Set<ActiveNotificationModel>> {
    ): Flow<Set<ActiveNotificationModel>> {
        return combine(
        return combine(
            activeNotificationsInteractor.topLevelRepresentativeNotifications,
            activeNotificationsInteractor.topLevelRepresentativeNotifications,
            headsUpNotificationIconInteractor.isolatedNotification,
            headsUpNotificationIconInteractor.isolatedNotification,
            if (showAodPromoted) flowOf(null) else aodPromotedKeyToHide,
            keyguardViewStateRepository.areNotificationsFullyHidden,
            keyguardViewStateRepository.areNotificationsFullyHidden,
        ) { notifications, isolatedNotifKey, notifsFullyHidden ->
        ) { notifications, isolatedNotifKey, aodPromotedKeyToHide, notifsFullyHidden ->
            notifications
            notifications
                .asSequence()
                .asSequence()
                .filter { model: ActiveNotificationModel ->
                .filter { model: ActiveNotificationModel ->
@@ -67,6 +84,7 @@ constructor(
                        showRepliedMessages = showRepliedMessages,
                        showRepliedMessages = showRepliedMessages,
                        showPulsing = showPulsing,
                        showPulsing = showPulsing,
                        isolatedNotifKey = isolatedNotifKey,
                        isolatedNotifKey = isolatedNotifKey,
                        aodPromotedKeyToHide = aodPromotedKeyToHide,
                        notifsFullyHidden = notifsFullyHidden,
                        notifsFullyHidden = notifsFullyHidden,
                    )
                    )
                }
                }
@@ -83,6 +101,7 @@ constructor(
        showRepliedMessages: Boolean,
        showRepliedMessages: Boolean,
        showPulsing: Boolean,
        showPulsing: Boolean,
        isolatedNotifKey: String?,
        isolatedNotifKey: String?,
        aodPromotedKeyToHide: String?,
        notifsFullyHidden: Boolean,
        notifsFullyHidden: Boolean,
    ): Boolean {
    ): Boolean {
        return when {
        return when {
@@ -93,6 +112,7 @@ constructor(
            !showRepliedMessages && model.isLastMessageFromReply -> false
            !showRepliedMessages && model.isLastMessageFromReply -> false
            !showAmbient && model.isSuppressedFromStatusBar -> false
            !showAmbient && model.isSuppressedFromStatusBar -> false
            !showPulsing && model.isPulsing && !notifsFullyHidden -> false
            !showPulsing && model.isPulsing && !notifsFullyHidden -> false
            model.key == aodPromotedKeyToHide -> false
            bubbles.getOrNull()?.isBubbleExpanded(model.key) == true -> false
            bubbles.getOrNull()?.isBubbleExpanded(model.key) == true -> false
            else -> true
            else -> true
        }
        }
@@ -115,6 +135,7 @@ constructor(
                    showDismissed = false,
                    showDismissed = false,
                    showRepliedMessages = false,
                    showRepliedMessages = false,
                    showPulsing = !isBypassEnabled,
                    showPulsing = !isBypassEnabled,
                    showAodPromoted = false,
                )
                )
            }
            }
            .flowOn(bgContext)
            .flowOn(bgContext)
+2 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.statusbar.data.repository.notificationListenerSettin
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.data.repository.notificationsKeyguardViewStateRepository
import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.activeNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.headsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.domain.interactor.headsUpNotificationIconInteractor
import com.android.systemui.statusbar.notification.promoted.domain.interactor.aodPromotedNotificationInteractor
import com.android.wm.shell.bubbles.bubblesOptional
import com.android.wm.shell.bubbles.bubblesOptional


val Kosmos.alwaysOnDisplayNotificationIconsInteractor by Fixture {
val Kosmos.alwaysOnDisplayNotificationIconsInteractor by Fixture {
@@ -47,6 +48,7 @@ val Kosmos.notificationIconsInteractor by Fixture {
        activeNotificationsInteractor = activeNotificationsInteractor,
        activeNotificationsInteractor = activeNotificationsInteractor,
        bubbles = bubblesOptional,
        bubbles = bubblesOptional,
        headsUpNotificationIconInteractor = headsUpNotificationIconInteractor,
        headsUpNotificationIconInteractor = headsUpNotificationIconInteractor,
        aodPromotedNotificationInteractor = aodPromotedNotificationInteractor,
        keyguardViewStateRepository = notificationsKeyguardViewStateRepository,
        keyguardViewStateRepository = notificationsKeyguardViewStateRepository,
    )
    )
}
}