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

Commit 6aad7f91 authored by Lucas Silva's avatar Lucas Silva
Browse files

Transition to GH from doze for all wake reasons

Currently we only do this for the power button wake reason. This change
updates this to always transition to GH. This fixes the case where we
were transitioning to the lockscreen instead of doze when the user taps
on the screen to wake the device.

Fixes: 361088370
Test: atest FromDozingTransitionInteractorTest
Flag: com.android.systemui.communal_hub
Change-Id: If72eb0a9ee2318674d841a429763b9dc2f067921
parent e252157b
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -150,13 +150,13 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
    @Test
    @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR)
    @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR)
    fun testTransitionToLockscreen_onPowerButtonPress_canDream_glanceableHubAvailable() =
    fun testTransitionToLockscreen_onWake_canDream_glanceableHubAvailable() =
        testScope.runTest {
            whenever(kosmos.dreamManager.canStartDreaming(anyBoolean())).thenReturn(true)
            kosmos.setCommunalAvailable(true)
            runCurrent()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            powerInteractor.setAwakeForTest()
            runCurrent()

            // If dreaming is possible and communal is available, then we should transition to
@@ -170,14 +170,14 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

    @Test
    @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR, FLAG_COMMUNAL_SCENE_KTF_REFACTOR)
    fun testTransitionToLockscreen_onPowerButtonPress_canDream_ktfRefactor() =
    fun testTransitionToLockscreen_onWake_canDream_ktfRefactor() =
        testScope.runTest {
            whenever(kosmos.dreamManager.canStartDreaming(anyBoolean())).thenReturn(true)
            kosmos.setCommunalAvailable(true)
            runCurrent()
            clearInvocations(kosmos.fakeCommunalSceneRepository)

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            powerInteractor.setAwakeForTest()
            runCurrent()

            // If dreaming is possible and communal is available, then we should transition to
@@ -188,13 +188,13 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

    @Test
    @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionToLockscreen_onPowerButtonPress_canNotDream_glanceableHubAvailable() =
    fun testTransitionToLockscreen_onWake_canNotDream_glanceableHubAvailable() =
        testScope.runTest {
            whenever(kosmos.dreamManager.canStartDreaming(anyBoolean())).thenReturn(false)
            kosmos.setCommunalAvailable(true)
            runCurrent()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            powerInteractor.setAwakeForTest()
            runCurrent()

            // If dreaming is NOT possible but communal is available, then we should transition to
@@ -208,13 +208,13 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

    @Test
    @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionToLockscreen_onPowerButtonPress_canNDream_glanceableHubNotAvailable() =
    fun testTransitionToLockscreen_onWake_canNDream_glanceableHubNotAvailable() =
        testScope.runTest {
            whenever(kosmos.dreamManager.canStartDreaming(anyBoolean())).thenReturn(true)
            kosmos.setCommunalAvailable(false)
            runCurrent()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            powerInteractor.setAwakeForTest()
            runCurrent()

            // If dreaming is possible but communal is NOT available, then we should transition to
+2 −15
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepositor
import com.android.systemui.keyguard.shared.model.BiometricUnlockMode.Companion.isWakeAndUnlock
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.util.kotlin.Utils.Companion.sample
import com.android.systemui.util.kotlin.sample
@@ -155,12 +154,7 @@ constructor(
                        if (!SceneContainerFlag.isEnabled) {
                            startTransitionTo(KeyguardState.GLANCEABLE_HUB)
                        }
                    } else if (
                        powerInteractor.detailedWakefulness.value.lastWakeReason ==
                            WakeSleepReason.POWER_BUTTON &&
                            isCommunalAvailable &&
                            dreamManager.canStartDreaming(true)
                    ) {
                    } else if (isCommunalAvailable && dreamManager.canStartDreaming(true)) {
                        // This case handles tapping the power button to transition through
                        // dream -> off -> hub.
                        if (!SceneContainerFlag.isEnabled) {
@@ -226,14 +220,7 @@ constructor(
                                    ownerReason = "waking from dozing"
                                )
                            }
                        } else if (
                            powerInteractor.detailedWakefulness.value.lastWakeReason ==
                                WakeSleepReason.POWER_BUTTON &&
                                isCommunalAvailable &&
                                dreamManager.canStartDreaming(true)
                        ) {
                            // This case handles tapping the power button to transition through
                            // dream -> off -> hub.
                        } else if (isCommunalAvailable && dreamManager.canStartDreaming(true)) {
                            if (!SceneContainerFlag.isEnabled) {
                                transitionToGlanceableHub()
                            }