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

Commit 54b1f377 authored by Matt Pietal's avatar Matt Pietal
Browse files

Don't attempt dismiss while user switch is in progress

This may rely on values from the prior user, resulting in the
incorrect bouncer being shown. Wait until the user switch
is complete before attempting to dismiss keyguard, or show
bouncer.

Fixes: 368017647
Test: atest KeyguardViewMediatorTest
Flag: EXEMPT bugfix
Change-Id: Ic8c2cc62ac0528762245b212ed0bf63969c86668
parent 95b0e20b
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -346,6 +346,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private boolean mShuttingDown;
    private boolean mDozing;
    private boolean mAnimatingScreenOff;
    private boolean mIgnoreDismiss;
    private final Context mContext;
    private final FalsingCollector mFalsingCollector;

@@ -627,18 +628,20 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        public void onUserSwitching(int userId) {
            Log.d(TAG, String.format("onUserSwitching %d", userId));
            synchronized (KeyguardViewMediator.this) {
                mIgnoreDismiss = true;
                notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(userId));
                resetKeyguardDonePendingLocked();
                dismiss(null /* callback */, null /* message */);
                resetStateLocked();
                adjustStatusBarLocked();
            }
        }

        @Override
        public void onUserSwitchComplete(int userId) {
            mIgnoreDismiss = false;
            Log.d(TAG, String.format("onUserSwitchComplete %d", userId));
            // We are calling dismiss again and with a delay as there are race conditions
            // in some scenarios caused by async layout listeners
            // We are calling dismiss with a delay as there are race conditions in some scenarios
            // caused by async layout listeners
            mHandler.postDelayed(() -> dismiss(null /* callback */, null /* message */), 500);
        }

@@ -2442,6 +2445,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    }

    public void dismiss(IKeyguardDismissCallback callback, CharSequence message) {
        if (mIgnoreDismiss) {
            android.util.Log.i(TAG, "Ignoring request to dismiss (user switch in progress?)");
            return;
        }
        mHandler.obtainMessage(DISMISS, new DismissMessage(callback, message)).sendToTarget();
    }