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

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

[DO NOT MERGE] 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.

Bug: 218500036
Test: atest KeyguardSecurityContainerTest

Merged-In: I7c8714a177bc85fbce92f6e8fe911f74ca2ac243
Change-Id: I30226bc7b5eda9480d471b35fe81e106b0491ff8
parent f8f07e22
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 java.util.NoSuchElementException;

@@ -204,7 +205,7 @@ public class AdminSecondaryLockScreenController {
            hide();
            if (mKeyguardCallback != null) {
                mKeyguardCallback.dismiss(/* securityVerified= */ true, userId,
                        /* bypassSecondaryLockScreen= */true);
                        /* bypassSecondaryLockScreen= */true,  SecurityMode.Invalid);
            }
        }
    }
+3 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;

import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils;
@@ -99,6 +100,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout

    protected abstract int getPasswordTextViewId();
    protected abstract void resetState();
    protected abstract SecurityMode getSecurityMode();

    @Override
    protected void onFinishInflate() {
@@ -208,7 +210,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
            mCallback.reportUnlockAttempt(userId, true, 0);
            if (dismissKeyguard) {
                mDismissing = true;
                mCallback.dismiss(true, userId);
                mCallback.dismiss(true, userId, getSecurityMode());
            }
        } else {
            if (isValidPassword) {
+6 −5
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
                        Log.i(TAG, "TrustAgent dismissed Keyguard.");
                    }
                    dismiss(false /* authenticated */, userId,
                            /* bypassSecondaryLockScreen */ false);
                            /* bypassSecondaryLockScreen */ false, SecurityMode.Invalid);
                } else {
                    mViewMediatorCallback.playTrustedSound();
                }
@@ -193,12 +193,13 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {
     * @return True if the keyguard is done.
     */
    public boolean dismiss(int targetUserId) {
        return dismiss(false, targetUserId, false);
        return dismiss(false, targetUserId, false, getCurrentSecurityMode());
    }

    public boolean handleBackKey() {
        if (mSecurityContainer.getCurrentSecuritySelection() != SecurityMode.None) {
            mSecurityContainer.dismiss(false, KeyguardUpdateMonitor.getCurrentUser());
            mSecurityContainer.dismiss(false, KeyguardUpdateMonitor.getCurrentUser(),
                getCurrentSecurityMode());
            return true;
        }
        return false;
@@ -210,9 +211,9 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback {

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

    /**
+6 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;

import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.settingslib.animation.AppearAnimationUtils;
import com.android.settingslib.animation.DisappearAnimationUtils;
import com.android.systemui.Dependency;
@@ -183,4 +184,9 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    public boolean hasOverlappingRendering() {
        return false;
    }

    @Override
    public SecurityMode getSecurityMode() {
        return SecurityMode.PIN;
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.widget.TextView.OnEditorActionListener;

import com.android.internal.widget.LockscreenCredential;
import com.android.internal.widget.TextViewInputDisabler;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.R;

import java.util.List;
@@ -387,4 +388,9 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
        return getContext().getString(
                com.android.internal.R.string.keyguard_accessibility_password_unlock);
    }

    @Override
    public SecurityMode getSecurityMode() {
        return SecurityMode.Password;
    }
}
Loading