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

Commit f9d97401 authored by Bryce Lee's avatar Bryce Lee
Browse files

Set UMO state based on transitions between occluded and glanceable hub.

This changelist adds additional consideration for transitions between
occluded and glanceable hub for UMO presence.

Fixes: 338051457
Test: atest CommunalTransitionViewModelTest#testIsUmoOnCommunalDuringTransitionBetweenOccludedAndGlanceableHub
Flag: ACONFIG com.android.systemui.communal_hub TEAMFOOD
Change-Id: If35d7643d7e1d8b69b702745149ba16c42a199e5
parent f1908787
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -86,4 +86,26 @@ class CommunalTransitionViewModelTest : SysuiTestCase() {
            )
            assertThat(isUmoOnCommunal).isFalse()
        }

    @Test
    fun testIsUmoOnCommunalDuringTransitionBetweenOccludedAndGlanceableHub() =
        testScope.runTest {
            val isUmoOnCommunal by collectLastValue(underTest.isUmoOnCommunal)
            assertThat(isUmoOnCommunal).isNull()

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.OCCLUDED,
                to = KeyguardState.GLANCEABLE_HUB,
                testScope
            )
            assertThat(isUmoOnCommunal).isTrue()

            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.GLANCEABLE_HUB,
                to = KeyguardState.OCCLUDED,
                testScope
            )

            assertThat(isUmoOnCommunal).isFalse()
        }
}
+24 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge

/** View model for transitions related to the communal hub. */
@@ -49,6 +50,27 @@ constructor(
    communalInteractor: CommunalInteractor,
    keyguardTransitionInteractor: KeyguardTransitionInteractor,
) {
    // Show UMO on glanceable hub immediately on transition into glanceable hub
    private val showUmoFromOccludedToGlanceableHub: Flow<Boolean> =
        keyguardTransitionInteractor
            .transitionStepsFromState(KeyguardState.OCCLUDED)
            .filter {
                it.to == KeyguardState.GLANCEABLE_HUB &&
                    (it.transitionState == TransitionState.STARTED ||
                        it.transitionState == TransitionState.CANCELED)
            }
            .map { it.transitionState == TransitionState.STARTED }

    private val showUmoFromGlanceableHubToOccluded: Flow<Boolean> =
        keyguardTransitionInteractor
            .transitionStepsFromState(KeyguardState.GLANCEABLE_HUB)
            .filter {
                it.to == KeyguardState.OCCLUDED &&
                    (it.transitionState == TransitionState.FINISHED ||
                        it.transitionState == TransitionState.CANCELED)
            }
            .map { it.transitionState != TransitionState.FINISHED }

    /**
     * Whether UMO location should be on communal. This flow is responsive to transitions so that a
     * new value is emitted at the right step of a transition to/from communal hub that the location
@@ -60,6 +82,8 @@ constructor(
                glanceableHubToLockscreenTransitionViewModel.showUmo,
                dreamToGlanceableHubTransitionViewModel.showUmo,
                glanceableHubToDreamTransitionViewModel.showUmo,
                showUmoFromOccludedToGlanceableHub,
                showUmoFromGlanceableHubToOccluded,
            )
            .distinctUntilChanged()