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

Commit 1868149e authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Safety check for OCCLUDED on wakeup" into main

parents 84051e9e 32295ed2
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.keyguard.domain.interactor

import android.app.ActivityManager
import android.app.WindowConfiguration
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -29,7 +27,6 @@ import com.android.systemui.flags.DisableSceneContainer
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.keyguardOcclusionRepository
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.keyguard.shared.model.StatusBarState.KEYGUARD
@@ -69,6 +66,38 @@ class FromLockscreenTransitionInteractorTest : SysuiTestCase() {
        transitionRepository = kosmos.fakeKeyguardTransitionRepository
    }

    @Test
    @DisableSceneContainer
    fun testOccludedFailsafe() =
        testScope.runTest {
            underTest.start()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.OFF,
                to = KeyguardState.AOD,
                testScope,
            )

            // Simulate the device being put into OCCLUDED state, but was somehow missed by the
            // FromAodTransitionInteractor
            keyguardRepository.setKeyguardOccluded(true)
            runCurrent()
            reset(transitionRepository)

            transitionRepository.sendTransitionStep(
                TransitionStep(
                    transitionState = TransitionState.STARTED,
                    from = KeyguardState.AOD,
                    to = KeyguardState.LOCKSCREEN,
                )
            )
            runCurrent()

            // After the above step was STARTED, the transition should be corrected to go to
            // OCCLUDED
            assertThatRepository(transitionRepository)
                .startedTransition(from = KeyguardState.LOCKSCREEN, to = KeyguardState.OCCLUDED)
        }

    @Test
    @DisableSceneContainer
    fun testSurfaceBehindVisibility() =
+20 −0
Original line number Diff line number Diff line
@@ -332,6 +332,26 @@ constructor(
                    .filterRelevantKeyguardStateAnd { isOccluded -> isOccluded }
                    .collect { startTransitionTo(KeyguardState.OCCLUDED) }
            }
            // Safety check added for incoming phone calls while on AOD/DOZING. If a transition has
            // begun to LOCKSCREEN but keyguard is occluded then make sure we change the transition
            // to go to OCCLUDED. This intentionally uses the [startedKeyguardTransitionStep] to
            // ensure that the transition has really begun
            scope.launch("$TAG#listenForLockscreenToOccludedOrDreamingFailSafe") {
                transitionInteractor.startedKeyguardTransitionStep
                    .filter {
                        it.from != KeyguardState.OCCLUDED &&
                            it.from != KeyguardState.DREAMING &&
                            it.to == KeyguardState.LOCKSCREEN
                    }
                    .collect {
                        if (keyguardInteractor.isKeyguardOccluded.value) {
                            startTransitionTo(
                                KeyguardState.OCCLUDED,
                                ownerReason = "occluded failsafe",
                            )
                        }
                    }
            }
        }
    }