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

Commit b8c444b9 authored by Matt Pietal's avatar Matt Pietal
Browse files

Prevent UnlockAnimationController from dismissing keyguard...

... on exit animation cancel. When the animators are canceled,
they will still call exitKeyguardAndFinishSurfaceBehindRemoteAnimation()
which can then continue to dismiss the keyguard even though it
decided to just relock. Short circuit this call.

Seems to happen during a race condition with SIM PIN/PUK screens.

Fixes: 370748717
Test: atest KeyguardViewMediatorTest
Flag: com.android.systemui.relock_with_power_button_immediately
Change-Id: I42a0aaa221ed2120ad2cf8b2a4ab88c4685f692b
parent c6ac402e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3428,6 +3428,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            return;
        }

        if (mIsKeyguardExitAnimationCanceled) {
            Log.d(TAG, "Ignoring exitKeyguardAndFinishSurfaceBehindRemoteAnimation. "
                    + "mIsKeyguardExitAnimationCanceled==true");
            return;
        }

        // Block the panel from expanding, in case we were doing a swipe to dismiss gesture.
        mKeyguardViewControllerLazy.get().blockPanelExpansionFromCurrentTouch();
        final boolean wasShowing = mShowing;
+28 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
import static com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR;
import static com.android.systemui.Flags.FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY;
import static com.android.systemui.Flags.FLAG_SIM_PIN_BOUNCER_RESET;
import static com.android.systemui.keyguard.KeyguardViewMediator.DELAYED_KEYGUARD_ACTION;
import static com.android.systemui.keyguard.KeyguardViewMediator.KEYGUARD_LOCK_AFTER_DELAY_DEFAULT;
@@ -63,6 +64,7 @@ import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.RemoteException;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.telephony.TelephonyManager;
import android.testing.AndroidTestingRunner;
@@ -841,6 +843,32 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    @EnableFlags(FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY)
    public void testCancelKeyguardExitAnimationDueToSleep_withPendingLockAndRelockFlag_keyguardWillBeShowing() {
        startMockKeyguardExitAnimation();

        mViewMediator.onStartedGoingToSleep(PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON);
        mViewMediator.onFinishedGoingToSleep(PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, false);

        cancelMockKeyguardExitAnimation();

        mViewMediator.maybeHandlePendingLock();
        TestableLooper.get(this).processAllMessages();

        assertTrue(mViewMediator.isShowingAndNotOccluded());

        verify(mKeyguardUnlockAnimationController).notifyFinishedKeyguardExitAnimation(true);

        // Unlock animators call `exitKeyguardAndFinishSurfaceBehindRemoteAnimation` when canceled
        mViewMediator.exitKeyguardAndFinishSurfaceBehindRemoteAnimation(false);
        TestableLooper.get(this).processAllMessages();

        verify(mUpdateMonitor, never()).dispatchKeyguardDismissAnimationFinished();
    }

    @Test
    @TestableLooper.RunWithLooper(setAsMainLooper = true)
    @DisableFlags(FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY)
    public void testCancelKeyguardExitAnimationDueToSleep_withPendingLock_keyguardWillBeShowing() {
        startMockKeyguardExitAnimation();