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

Commit f5748468 authored by Coco Duan's avatar Coco Duan
Browse files

Fix transition stuck in AOD and keyguard clock visible after unlock

It happens when rapidly switching between AOD and Hub, and transition
interruption not handled as expected. During Blank(AOD)->Communal(Hub)
scene transition, if we press the power button to interrupt it, the
CommunalSceneInteractor requests a Communal->Blank transition but STL
will start a reversed Blank->Communal transition (currentScene=Blank).
It causes keyguard state not updated correctly and finally stuck in AOD.

Fix is to update ktf state when a reversed transition is detected due
to interruption in handleTransition and handleIdle.

Fixes: b/395041829
Test: rapidly switch between AOD<->Hub by power button then unlock
Test: atest CommunalSceneTransitionInteractorTest
Flag: EXEMPT bugfix
Change-Id: Ib177e33a77db1157613db5e89cf279b26c4ee468
parent a453f06d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.systemui.communal.ui.compose.Dimensions.Companion.SlideOffset
import com.android.systemui.communal.ui.compose.extensions.allowGestures
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.util.CommunalColors
import com.android.systemui.keyguard.domain.interactor.FromAodTransitionInteractor
import com.android.systemui.keyguard.domain.interactor.FromGlanceableHubTransitionInteractor.Companion.TO_LOCKSCREEN_DURATION
import com.android.systemui.keyguard.domain.interactor.FromPrimaryBouncerTransitionInteractor.Companion.TO_GONE_DURATION
import com.android.systemui.scene.shared.model.SceneDataSourceDelegator
@@ -97,6 +98,16 @@ val sceneTransitionsV2 = transitions {
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        timestampRange(startMillis = 250) { fade(AllElements) }
    }
    to(CommunalScenes.Communal, key = CommunalTransitionKeys.FromAod) {
        spec =
            tween(
                durationMillis =
                    FromAodTransitionInteractor.TO_GLANCEABLE_HUB_DURATION.toInt(
                        DurationUnit.MILLISECONDS
                    )
            )
        timestampRange(startMillis = 167) { fade(AllElements) }
    }
    to(CommunalScenes.Communal, key = CommunalTransitionKeys.Swipe) {
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        translate(Communal.Elements.Grid, Edge.End)
+23 −1
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import com.android.systemui.communal.domain.model.CommunalTransitionProgressMode
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.initialSceneKey
import com.android.systemui.scene.shared.model.Scenes
@@ -109,7 +111,7 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase(

    @DisableFlags(FLAG_SCENE_CONTAINER)
    @Test
    fun changeScene_doesNotCallSceneStateProcessorForDuplicateState() =
    fun changeScene_doesNotCallSceneStateProcessorForDuplicateState_ifKeyguardStateIsNull() =
        testScope.runTest {
            val callback: OnSceneAboutToChangeListener = mock()
            underTest.registerSceneStateProcessor(callback)
@@ -123,6 +125,26 @@ class CommunalSceneInteractorTest(flags: FlagsParameterization) : SysuiTestCase(
            verify(callback, never()).onSceneAboutToChange(any(), anyOrNull())
        }

    @DisableFlags(FLAG_SCENE_CONTAINER)
    @Test
    fun changeScene_callSceneStateProcessorForDuplicateScene_ifBlankSceneWithKeyguardState() =
        testScope.runTest {
            val callback: OnSceneAboutToChangeListener = mock()
            underTest.registerSceneStateProcessor(callback)

            val currentScene by collectLastValue(underTest.currentScene)
            underTest.changeScene(CommunalScenes.Communal, "test")
            assertThat(currentScene).isEqualTo(CommunalScenes.Communal)

            underTest.changeScene(CommunalScenes.Blank, "test", keyguardState = KeyguardState.AOD)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            verify(callback).onSceneAboutToChange(CommunalScenes.Blank, KeyguardState.AOD)

            underTest.changeScene(CommunalScenes.Blank, "test", keyguardState = KeyguardState.GONE)
            assertThat(currentScene).isEqualTo(CommunalScenes.Blank)
            verify(callback).onSceneAboutToChange(CommunalScenes.Blank, KeyguardState.GONE)
        }

    @DisableFlags(FLAG_SCENE_CONTAINER)
    @Test
    fun snapToScene() =
Loading