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

Commit c13a5781 authored by Andreas Miko's avatar Andreas Miko
Browse files

Revert^2 "Show bouncer after user switch"

Caution: There is different behavior based on if you switch to or from the owner. Also there are various race conditions in the KeyguardViewMediator queue caused by waiting on async layouts to happen.

This CL tries to mitigate this issue by adding a delay, but more thorough investigation and cleanup of incoming signals and side effects is necessary to remove jank and make the queues order of execution predictable.

Test: Manually tested various user switch scenarios with different bouncers. PIN/SWIPE/NONE/FINGER.
Bug: b/266711330

5af2a119

Change-Id: I4143f9727e870074a5a3bddf9e2586781f10b637
parent 21f321e1
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -544,7 +544,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    public void setOnDismissAction(ActivityStarter.OnDismissAction action, Runnable cancelAction) {
        if (mCancelAction != null) {
            mCancelAction.run();
            mCancelAction = null;
        }
        mDismissAction = action;
        mCancelAction = cancelAction;
+24 −21
Original line number Diff line number Diff line
@@ -582,17 +582,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        @Override
        public void onUserSwitching(int userId) {
            if (DEBUG) Log.d(TAG, String.format("onUserSwitching %d", userId));
            // Note that the mLockPatternUtils user has already been updated from setCurrentUser.
            // We need to force a reset of the views, since lockNow (called by
            // ActivityManagerService) will not reconstruct the keyguard if it is already showing.
            synchronized (KeyguardViewMediator.this) {
                resetKeyguardDonePendingLocked();
                if (mLockPatternUtils.isLockScreenDisabled(userId)) {
                    // If we are switching to a user that has keyguard disabled, dismiss keyguard.
                dismiss(null /* callback */, null /* message */);
                } else {
                    resetStateLocked();
                }
                adjustStatusBarLocked();
            }
        }
@@ -600,16 +592,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        @Override
        public void onUserSwitchComplete(int userId) {
            if (DEBUG) Log.d(TAG, String.format("onUserSwitchComplete %d", userId));
            if (userId != UserHandle.USER_SYSTEM) {
                UserInfo info = UserManager.get(mContext).getUserInfo(userId);
                // Don't try to dismiss if the user has Pin/Pattern/Password set
                if (info == null || mLockPatternUtils.isSecure(userId)) {
                    return;
                } else if (info.isGuest() || info.isDemo()) {
                    // If we just switched to a guest, try to dismiss keyguard.
                    dismiss(null /* callback */, null /* message */);
                }
            }
            // We are calling dismiss again and with a delay as there are race conditions
            // in some scenarios caused by async layout listeners
            mHandler.postDelayed(() -> dismiss(null /* callback */, null /* message */), 500);
        }

        @Override
@@ -2383,58 +2368,72 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private Handler mHandler = new Handler(Looper.myLooper(), null, true /*async*/) {
        @Override
        public void handleMessage(Message msg) {
            String message = "";
            switch (msg.what) {
                case SHOW:
                    message = "SHOW";
                    handleShow((Bundle) msg.obj);
                    break;
                case HIDE:
                    message = "HIDE";
                    handleHide();
                    break;
                case RESET:
                    message = "RESET";
                    handleReset(msg.arg1 != 0);
                    break;
                case VERIFY_UNLOCK:
                    message = "VERIFY_UNLOCK";
                    Trace.beginSection("KeyguardViewMediator#handleMessage VERIFY_UNLOCK");
                    handleVerifyUnlock();
                    Trace.endSection();
                    break;
                case NOTIFY_STARTED_GOING_TO_SLEEP:
                    message = "NOTIFY_STARTED_GOING_TO_SLEEP";
                    handleNotifyStartedGoingToSleep();
                    break;
                case NOTIFY_FINISHED_GOING_TO_SLEEP:
                    message = "NOTIFY_FINISHED_GOING_TO_SLEEP";
                    handleNotifyFinishedGoingToSleep();
                    break;
                case NOTIFY_STARTED_WAKING_UP:
                    message = "NOTIFY_STARTED_WAKING_UP";
                    Trace.beginSection(
                            "KeyguardViewMediator#handleMessage NOTIFY_STARTED_WAKING_UP");
                    handleNotifyStartedWakingUp();
                    Trace.endSection();
                    break;
                case KEYGUARD_DONE:
                    message = "KEYGUARD_DONE";
                    Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE");
                    handleKeyguardDone();
                    Trace.endSection();
                    break;
                case KEYGUARD_DONE_DRAWING:
                    message = "KEYGUARD_DONE_DRAWING";
                    Trace.beginSection("KeyguardViewMediator#handleMessage KEYGUARD_DONE_DRAWING");
                    handleKeyguardDoneDrawing();
                    Trace.endSection();
                    break;
                case SET_OCCLUDED:
                    message = "SET_OCCLUDED";
                    Trace.beginSection("KeyguardViewMediator#handleMessage SET_OCCLUDED");
                    handleSetOccluded(msg.arg1 != 0, msg.arg2 != 0);
                    Trace.endSection();
                    break;
                case KEYGUARD_TIMEOUT:
                    message = "KEYGUARD_TIMEOUT";
                    synchronized (KeyguardViewMediator.this) {
                        doKeyguardLocked((Bundle) msg.obj);
                    }
                    break;
                case DISMISS:
                    final DismissMessage message = (DismissMessage) msg.obj;
                    handleDismiss(message.getCallback(), message.getMessage());
                    message = "DISMISS";
                    final DismissMessage dismissMsg = (DismissMessage) msg.obj;
                    handleDismiss(dismissMsg.getCallback(), dismissMsg.getMessage());
                    break;
                case START_KEYGUARD_EXIT_ANIM:
                    message = "START_KEYGUARD_EXIT_ANIM";
                    Trace.beginSection(
                            "KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM");
                    synchronized (KeyguardViewMediator.this) {
@@ -2452,21 +2451,25 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                    Trace.endSection();
                    break;
                case CANCEL_KEYGUARD_EXIT_ANIM:
                    message = "CANCEL_KEYGUARD_EXIT_ANIM";
                    Trace.beginSection(
                            "KeyguardViewMediator#handleMessage CANCEL_KEYGUARD_EXIT_ANIM");
                    handleCancelKeyguardExitAnimation();
                    Trace.endSection();
                    break;
                case KEYGUARD_DONE_PENDING_TIMEOUT:
                    message = "KEYGUARD_DONE_PENDING_TIMEOUT";
                    Trace.beginSection("KeyguardViewMediator#handleMessage"
                            + " KEYGUARD_DONE_PENDING_TIMEOUT");
                    Log.w(TAG, "Timeout while waiting for activity drawn!");
                    Trace.endSection();
                    break;
                case SYSTEM_READY:
                    message = "SYSTEM_READY";
                    handleSystemReady();
                    break;
            }
            Log.d(TAG, "KeyguardViewMediator queue processing message: " + message);
        }
    };