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

Commit 3d89cc5d authored by Matt Pietal's avatar Matt Pietal
Browse files

Do not dismiss keyguard after SIM PUK unlock

After PUK unlock, multiple calls to
KeyguardSecurityContainerController#dismiss() were being called from
the KeyguardSimPukViewController, which begins the transition to the
next security screen, if any. At the same time, other parts of the
system, also listening to SIM events, recognize the PUK unlock and
call KeyguardSecurityContainer#showSecurityScreen, which updates which
security method comes next. After boot, this should be one of PIN,
Password, Pattern, assuming they have a security method. If one of the
first dismiss() calls comes AFTER the security method changes, this is
incorrectly recognized by the code as a successful
PIN/pattern/password unlock. This causes the keyguard to be marked as
done, causing screen flickers and incorrect system state.

The solution: every call to dismiss() should include a new parameter
for the security method used. If there is a difference between this
parameter and the current value in KeyguardSecurityContainerCallback,
ignore the request, as the system state has changed.

Fixes: 238804980
Bug: 218500036
Test: atest KeyguardSecurityContainerTest
AdminSecondaryLockScreenControllerTest KeyguardHostViewControllerTest
KeyguardSecurityContainerControllerTest

Change-Id: I7c8714a177bc85fbce92f6e8fe911f74ca2ac243
Merged-In: I7c8714a177bc85fbce92f6e8fe911f74ca2ac243
(cherry picked from commit 37aeb26b)
parent 40739d53
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.view.SurfaceView;
import android.view.ViewGroup;

import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.keyguard.dagger.KeyguardBouncerScope;
import com.android.systemui.dagger.qualifiers.Main;

@@ -208,7 +209,7 @@ public class AdminSecondaryLockScreenController {
            hide();
            if (mKeyguardCallback != null) {
                mKeyguardCallback.dismiss(/* securityVerified= */ true, userId,
                        /* bypassSecondaryLockScreen= */true);
                        /* bypassSecondaryLockScreen= */true, SecurityMode.Invalid);
            }
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
            if (dismissKeyguard) {
                mDismissing = true;
                mLatencyTracker.onActionStart(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
                getKeyguardSecurityCallback().dismiss(true, userId);
                getKeyguardSecurityCallback().dismiss(true, userId, getSecurityMode());
            }
        } else {
            if (isValidPassword) {
+8 −7
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
                                Log.i(TAG, "TrustAgent dismissed Keyguard.");
                            }
                            mSecurityCallback.dismiss(false /* authenticated */, userId,
                                    /* bypassSecondaryLockScreen */ false);
                                    /* bypassSecondaryLockScreen */ false, SecurityMode.Invalid);
                        } else {
                            mViewMediatorCallback.playTrustedSound();
                        }
@@ -102,9 +102,9 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>

        @Override
        public boolean dismiss(boolean authenticated, int targetUserId,
                boolean bypassSecondaryLockScreen) {
                boolean bypassSecondaryLockScreen, SecurityMode expectedSecurityMode) {
            return mKeyguardSecurityContainerController.showNextSecurityScreenOrFinish(
                    authenticated, targetUserId, bypassSecondaryLockScreen);
                    authenticated, targetUserId, bypassSecondaryLockScreen, expectedSecurityMode);
        }

        @Override
@@ -212,7 +212,8 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
     * @return True if the keyguard is done.
     */
    public boolean dismiss(int targetUserId) {
        return mSecurityCallback.dismiss(false, targetUserId, false);
        return mSecurityCallback.dismiss(false, targetUserId, false,
                getCurrentSecurityMode());
    }

    /**
@@ -355,10 +356,10 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
    }

    public boolean handleBackKey() {
        if (mKeyguardSecurityContainerController.getCurrentSecurityMode()
                != SecurityMode.None) {
        SecurityMode securityMode = mKeyguardSecurityContainerController.getCurrentSecurityMode();
        if (securityMode != SecurityMode.None) {
            mKeyguardSecurityContainerController.dismiss(
                    false, KeyguardUpdateMonitor.getCurrentUser());
                    false, KeyguardUpdateMonitor.getCurrentUser(), securityMode);
            return true;
        }
        return false;
+3 −2
Original line number Diff line number Diff line
@@ -59,10 +59,11 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
            return false;
        }
        @Override
        public void dismiss(boolean securityVerified, int targetUserId) { }
        public void dismiss(boolean securityVerified, int targetUserId,
                SecurityMode expectedSecurityMode) { }
        @Override
        public void dismiss(boolean authenticated, int targetId,
                boolean bypassSecondaryLockScreen) { }
                boolean bypassSecondaryLockScreen, SecurityMode expectedSecurityMode) { }
        @Override
        public void onUserInput() { }
        @Override
+1 −1
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ public class KeyguardPatternViewController
                if (dismissKeyguard) {
                    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
                    mLatencyTracker.onActionStart(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
                    getKeyguardSecurityCallback().dismiss(true, userId);
                    getKeyguardSecurityCallback().dismiss(true, userId, SecurityMode.Pattern);
                }
            } else {
                mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
Loading