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

Commit 39be21e1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Attempt device entry when WM unilaterally starts the going away animation." into main

parents 8f6b95ca 8c4571bf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.SysuiTestCase
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.keyguard.WindowManagerLockscreenVisibilityManager
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransitionInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardShowWhileAwakeInteractor
@@ -36,6 +37,7 @@ import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import com.android.window.flags.Flags
import com.android.wm.shell.keyguard.KeyguardTransitions
import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -74,6 +76,7 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
    @Mock private lateinit var lockPatternUtils: LockPatternUtils
    @Mock private lateinit var keyguardShowWhileAwakeInteractor: KeyguardShowWhileAwakeInteractor
    @Mock private lateinit var selectedUserInteractor: SelectedUserInteractor
    @Mock private lateinit var deviceEntryInteractor: DeviceEntryInteractor

    @Before
    fun setUp() {
@@ -93,6 +96,7 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
                selectedUserInteractor = selectedUserInteractor,
                lockPatternUtils = lockPatternUtils,
                keyguardShowWhileAwakeInteractor = keyguardShowWhileAwakeInteractor,
                deviceEntryInteractor = { deviceEntryInteractor },
            )
    }

@@ -287,6 +291,10 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
            .whenever(keyguardDismissTransitionInteractor)
            .startDismissKeyguardTransition(any(), any())

        // Or, if flexiglass is enabled, return that the device is already entered so that we call
        // the callback immediately.
        whenever(deviceEntryInteractor.isDeviceEntered).thenReturn(MutableStateFlow(true))

        whenever(selectedUserInteractor.getSelectedUserId()).thenReturn(-1)

        underTest.onKeyguardGoingAwayRemoteAnimationStart(
+31 −18
Original line number Diff line number Diff line
@@ -26,9 +26,11 @@ import com.android.internal.widget.LockPatternUtils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dagger.qualifiers.UiBackground
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransitionInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardShowWhileAwakeInteractor
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.window.flags.Flags
@@ -54,6 +56,7 @@ constructor(
    private val selectedUserInteractor: SelectedUserInteractor,
    private val lockPatternUtils: LockPatternUtils,
    private val keyguardShowWhileAwakeInteractor: KeyguardShowWhileAwakeInteractor,
    private val deviceEntryInteractor: dagger.Lazy<DeviceEntryInteractor>,
) {

    /**
@@ -204,16 +207,12 @@ constructor(

        // If we weren't expecting the keyguard to be going away, WM triggered this transition.
        if (!isKeyguardGoingAway) {
            // Since WM triggered this, we're likely not transitioning to GONE yet. See if we can
            // start that transition.
            keyguardDismissTransitionInteractor.startDismissKeyguardTransition(
                reason = "Going away remote animation started",
                onAlreadyGone = {
                    // Called if we're already GONE by the time the dismiss transition would have
                    // started. This can happen due to timing issues, where the remote animation
                    // took a long time to start, and something else caused us to unlock in the
                    // meantime. Since we're already GONE, simply end the remote animation
                    // immediately.
            val alreadyGoneCallback = {
                // Called if we're already GONE by the time the dismiss transition would
                // have started. This can happen due to timing issues, where the remote
                // animation took a long time to start, and something else caused us to
                // unlock in the meantime. Since we're already GONE, simply end the remote
                // animation immediately.
                Log.d(
                    TAG,
                    "onKeyguardGoingAwayRemoteAnimationStart: " +
@@ -222,8 +221,22 @@ constructor(
                )
                finishedCallback.onAnimationFinished()
                isKeyguardGoingAway = false
                },
            }

            // Since WM triggered this, we're likely not transitioning to GONE yet. See if we can
            // start that transition.
            if (SceneContainerFlag.isEnabled) {
                if (deviceEntryInteractor.get().isDeviceEntered.value) {
                    alreadyGoneCallback.invoke()
                } else {
                    deviceEntryInteractor.get().attemptDeviceEntry()
                }
            } else {
                keyguardDismissTransitionInteractor.startDismissKeyguardTransition(
                    reason = "Going away remote animation started",
                    onAlreadyGone = alreadyGoneCallback,
                )
            }

            isKeyguardGoingAway = true
        }