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

Commit 9d9f12b4 authored by Lucas Silva's avatar Lucas Silva
Browse files

Implement transition from alternate bouncer -> dreaming

Currently the transition doesn't exist, so if user opens alternate
bouncer but then lets the device timeout to dream, the device ends up in
a bad state.

Bug: 396153527
Test: atest FromAlternateBouncerTransitionInteractorTest
Flag: com.android.systemui.glanceable_hub_v2
Change-Id: I9bda3d5e82f393f71d7a7daaa256cbf40c6d3e29
parent 828c910e
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -228,6 +228,39 @@ class FromAlternateBouncerTransitionInteractorTest(flags: FlagsParameterization)
            Truth.assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
        }

    @Test
    @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
    fun transitionToDreaming() =
        kosmos.runTest {
            fakePowerRepository.updateWakefulness(
                WakefulnessState.AWAKE,
                WakeSleepReason.POWER_BUTTON,
                WakeSleepReason.POWER_BUTTON,
                false,
            )
            fakeKeyguardRepository.setKeyguardOccluded(false)
            fakeKeyguardBouncerRepository.setAlternateVisible(true)
            runCurrent()

            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.ALTERNATE_BOUNCER,
                testScope,
            )
            reset(transitionRepository)

            fakeKeyguardRepository.setKeyguardOccluded(true)
            fakeKeyguardRepository.setDreaming(true)
            fakeKeyguardBouncerRepository.setAlternateVisible(false)
            testScope.advanceTimeBy(200) // advance past delay

            assertThat(transitionRepository)
                .startedTransition(
                    from = KeyguardState.ALTERNATE_BOUNCER,
                    to = KeyguardState.DREAMING,
                )
        }

    @Test
    @DisableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun transitionToGone_whenOpeningGlanceableHubEditMode() =
+8 −13
Original line number Diff line number Diff line
@@ -118,26 +118,19 @@ constructor(
                    powerInteractor.isAwake,
                    keyguardInteractor.isAodAvailable,
                    communalSceneInteractor.isIdleOnCommunal,
                    communalInteractor.editModeOpen,
                    keyguardInteractor.isDreaming,
                    keyguardInteractor.isKeyguardOccluded,
                )
                .filterRelevantKeyguardStateAnd {
                    (isAlternateBouncerShowing, isPrimaryBouncerShowing, _, _, _) ->
                    (isAlternateBouncerShowing, isPrimaryBouncerShowing, _, _, _, _) ->
                    !isAlternateBouncerShowing && !isPrimaryBouncerShowing
                }
                .collect {
                    (
                        _,
                        _,
                        isAwake,
                        isAodAvailable,
                        isIdleOnCommunal,
                        isCommunalEditMode,
                        isOccluded) ->
                .collect { (_, _, isAwake, isAodAvailable, isIdleOnCommunal, isDreaming, isOccluded)
                    ->
                    // When unlocking over glanceable hub to enter edit mode, transitioning directly
                    // to GONE prevents the lockscreen flash. Let listenForAlternateBouncerToGone
                    // handle it.
                    if (isCommunalEditMode) return@collect
                    if (communalInteractor.editModeOpen.value) return@collect
                    val hubV2 = communalSettingsInteractor.isV2FlagEnabled()
                    val to =
                        if (!isAwake) {
@@ -150,8 +143,10 @@ constructor(
                            if (!hubV2 && isIdleOnCommunal) {
                                if (SceneContainerFlag.isEnabled) return@collect
                                KeyguardState.GLANCEABLE_HUB
                            } else if (isOccluded) {
                            } else if (isOccluded && !isDreaming) {
                                KeyguardState.OCCLUDED
                            } else if (hubV2 && isDreaming) {
                                KeyguardState.DREAMING
                            } else if (hubV2 && isIdleOnCommunal) {
                                if (SceneContainerFlag.isEnabled) return@collect
                                KeyguardState.GLANCEABLE_HUB