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

Commit 96018586 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Check isInteractive after traversal before hiding keyguard.

The Runnable passed to postAfterTraversal is capable of
unilaterally hiding the keyguard, but it's run at an
indeterminate time due to the postAfterTraversal. To be
safe, check the earliest source of truth (PowerManager)
to see if we're still interactive before proceeding.

Fixes: 296886973
Test: lock the device during the unlock animation from bouncer to an app
Test: atest SystemUITests
Change-Id: Iaef7cff8366015c3e66aac4d740f6240e7c183db
parent 18b2a9bf
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3107,7 +3107,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
     *                        visible
     */
    public void exitKeyguardAndFinishSurfaceBehindRemoteAnimation(boolean showKeyguard) {
        Log.d(TAG, "onKeyguardExitRemoteAnimationFinished");
        Log.d(TAG, "exitKeyguardAndFinishSurfaceBehindRemoteAnimation");
        if (!mSurfaceBehindRemoteAnimationRunning && !mSurfaceBehindRemoteAnimationRequested) {
            Log.d(TAG, "skip onKeyguardExitRemoteAnimationFinished showKeyguard=" + showKeyguard
                    + " surfaceAnimationRunning=" + mSurfaceBehindRemoteAnimationRunning
@@ -3122,6 +3122,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

        // Post layout changes to the next frame, so we don't hang at the end of the animation.
        DejankUtils.postAfterTraversal(() -> {
            if (!mPM.isInteractive()) {
                Log.e(TAG, "exitKeyguardAndFinishSurfaceBehindRemoteAnimation#postAfterTraversal" +
                        "Not interactive after traversal. Don't hide the keyguard. This means we " +
                        "re-locked the device during unlock.");
                return;
            }

            onKeyguardExitFinished();

            if (mKeyguardStateController.isDismissingFromSwipe() || wasShowing) {
+1 −2
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {

        when(mLockPatternUtils.getDevicePolicyManager()).thenReturn(mDevicePolicyManager);
        when(mPowerManager.newWakeLock(anyInt(), any())).thenReturn(mock(WakeLock.class));
        when(mPowerManager.isInteractive()).thenReturn(true);
        when(mInteractionJankMonitor.begin(any(), anyInt())).thenReturn(true);
        when(mInteractionJankMonitor.end(anyInt())).thenReturn(true);
        final ViewRootImpl testViewRoot = mock(ViewRootImpl.class);
@@ -708,8 +709,6 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        when(mKeyguardStateController.isShowing()).thenReturn(true);
        TestableLooper.get(this).processAllMessages();

        when(mPowerManager.isInteractive()).thenReturn(true);

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