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

Commit 5f067b4c authored by Matt Pietal's avatar Matt Pietal
Browse files

Reset keyguard/bouncer on sim NOT_READY

Add a failsafe when a SIM is moved to NOT_READY state
that will call reset() to the StatusBarKeyguardViewManager.
This can happen when an eSim is disabled.

Bug: 297461589
Test: atest KeyguardViewMediatorTest
Flag: com.android.systemui.sim_pin_bouncer_reset
Change-Id: I4459d6597864031d6f03c215a5e76909178dcfba
parent fa94f9b5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1312,6 +1312,16 @@ flag {
   }
}

flag {
   name: "sim_pin_bouncer_reset"
   namespace: "systemui"
   description: "The SIM PIN bouncer does not close after unlocking"
   bug: "297461589"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}

flag {
   name: "use_transitions_for_keyguard_occluded"
   namespace: "systemui"
+0 −1
Original line number Diff line number Diff line
@@ -28,5 +28,4 @@ public class KeyguardConstants {
     * be used temporarily for debugging.
     */
    public static final boolean DEBUG = Log.isLoggable("Keyguard", Log.DEBUG);
    public static final boolean DEBUG_SIM_STATES = true;
}
+9 −18
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ public class KeyguardSimPinViewController
        extends KeyguardPinBasedInputViewController<KeyguardSimPinView> {
    public static final String TAG = "KeyguardSimPinView";
    private static final String LOG_TAG = "KeyguardSimPinView";
    private static final boolean DEBUG = KeyguardConstants.DEBUG_SIM_STATES;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final TelephonyManager mTelephonyManager;

@@ -71,7 +70,7 @@ public class KeyguardSimPinViewController
    KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() {
        @Override
        public void onSimStateChanged(int subId, int slotId, int simState) {
            if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")");
            Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")");
            // If subId has gone to PUK required then we need to go to the PUK screen.
            if (subId == mSubId && simState == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
                getKeyguardSecurityCallback().showCurrentSecurityScreen();
@@ -129,7 +128,7 @@ public class KeyguardSimPinViewController
    @Override
    void resetState() {
        super.resetState();
        if (DEBUG) Log.v(TAG, "Resetting state");
        Log.v(TAG, "Resetting state");
        handleSubInfoChangeIfNeeded();
        mMessageAreaController.setMessage("");
        if (mShowDefaultMessage) {
@@ -216,12 +215,10 @@ public class KeyguardSimPinViewController
                                mMessageAreaController.setMessage(mView.getResources().getString(
                                        R.string.kg_password_pin_failed));
                            }
                            if (DEBUG) {
                            Log.d(LOG_TAG, "verifyPasswordAndUnlock "
                                    + " CheckSimPin.onSimCheckResponse: " + result
                                    + " attemptsRemaining=" + result.getAttemptsRemaining());
                        }
                        }
                        getKeyguardSecurityCallback().userActivity();
                        mCheckSimPinThread = null;
                    });
@@ -280,10 +277,8 @@ public class KeyguardSimPinViewController
            displayMessage = mView.getResources()
                    .getString(R.string.kg_sim_lock_esim_instructions, displayMessage);
        }
        if (DEBUG) {
        Log.d(LOG_TAG, "getPinPasswordErrorMessage: attemptsRemaining="
                + attemptsRemaining + " displayMessage=" + displayMessage);
        }
        return displayMessage;
    }

@@ -323,14 +318,10 @@ public class KeyguardSimPinViewController

        @Override
        public void run() {
            if (DEBUG) {
            Log.v(TAG, "call supplyIccLockPin(subid=" + mSubId + ")");
            }
            TelephonyManager telephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
            final PinResult result = telephonyManager.supplyIccLockPin(mPin);
            if (DEBUG) {
            Log.v(TAG, "supplyIccLockPin returned: " + result.toString());
            }
            mView.post(() -> onSimCheckResponse(result));
        }
    }
+11 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
import static com.android.systemui.Flags.simPinBouncerReset;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;

import android.annotation.AnyThread;
@@ -1703,6 +1704,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        intent.getStringExtra(Intent.EXTRA_SIM_STATE),
                        args.slotId,
                        args.subId);
                if (args.slotId == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
                    return;
                }
                mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, args.subId, args.slotId, args.simState)
                        .sendToTarget();
            } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
@@ -1940,7 +1944,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            }
            int state = TelephonyManager.SIM_STATE_UNKNOWN;
            String stateExtra = intent.getStringExtra(Intent.EXTRA_SIM_STATE);
            int slotId = intent.getIntExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0);

            int defaultSlotId = 0;
            if (simPinBouncerReset()) {
                defaultSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
            }
            int slotId = intent.getIntExtra(SubscriptionManager.EXTRA_SLOT_INDEX,
                    defaultSlotId);
            int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
                    SubscriptionManager.INVALID_SUBSCRIPTION_ID);
            if (Intent.SIM_STATE_ABSENT.equals(stateExtra)) {
+21 −14
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.Flags.notifyPowerManagerUserActivityBackground;
import static com.android.systemui.Flags.relockWithPowerButtonImmediately;
import static com.android.systemui.Flags.simPinBouncerReset;
import static com.android.systemui.Flags.translucentOccludingActivityFix;
import static com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel.DREAMING_ANIMATION_DURATION_MS;

@@ -238,7 +239,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
    private static final long KEYGUARD_DONE_PENDING_TIMEOUT_MS = 3000;

    private static final boolean DEBUG = KeyguardConstants.DEBUG;
    private static final boolean DEBUG_SIM_STATES = KeyguardConstants.DEBUG_SIM_STATES;

    private final static String TAG = "KeyguardViewMediator";

@@ -649,11 +649,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,

        @Override
        public void onSimStateChanged(int subId, int slotId, int simState) {

            if (DEBUG_SIM_STATES) {
            Log.d(TAG, "onSimStateChanged(subId=" + subId + ", slotId=" + slotId
                        + ",state=" + simState + ")");
            }
                    + ",state=" +  TelephonyManager.simStateToString(simState) + ")");

            int size = mKeyguardStateCallbacks.size();
            boolean simPinSecure = mUpdateMonitor.isSimPinSecure();
@@ -686,7 +683,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                    synchronized (KeyguardViewMediator.this) {
                        if (shouldWaitForProvisioning()) {
                            if (!mShowing) {
                                if (DEBUG_SIM_STATES) Log.d(TAG, "ICC_ABSENT isn't showing,"
                                Log.d(TAG, "ICC_ABSENT isn't showing,"
                                        + " we need to show the keyguard since the "
                                        + "device isn't provisioned yet.");
                                doKeyguardLocked(null);
@@ -698,11 +695,21 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                            // MVNO SIMs can become transiently NOT_READY when switching networks,
                            // so we should only lock when they are ABSENT.
                            if (lastSimStateWasLocked) {
                                if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to ABSENT when the "
                                Log.d(TAG, "SIM moved to ABSENT when the "
                                        + "previous state was locked. Reset the state.");
                                resetStateLocked();
                            }
                            mSimWasLocked.append(slotId, false);
                        } else if (simState == TelephonyManager.SIM_STATE_NOT_READY) {
                            if (simPinBouncerReset()) {
                                // Support eSIM disablement, and do not clear `mSimWasLocked`.
                                // NOT_READY could just be a temporary state
                                if (lastSimStateWasLocked) {
                                    Log.d(TAG, "SIM moved to NOT_READY when the "
                                            + "previous state was locked. Reset the state.");
                                    resetStateLocked();
                                }
                            }
                        }
                    }
                    break;
@@ -712,7 +719,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                        mSimWasLocked.append(slotId, true);
                        mPendingPinLock = true;
                        if (!mShowing) {
                            if (DEBUG_SIM_STATES) Log.d(TAG,
                            Log.d(TAG,
                                    "INTENT_VALUE_ICC_LOCKED and keygaurd isn't "
                                    + "showing; need to show keyguard so user can enter sim pin");
                            doKeyguardLocked(null);
@@ -724,11 +731,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                case TelephonyManager.SIM_STATE_PERM_DISABLED:
                    synchronized (KeyguardViewMediator.this) {
                        if (!mShowing) {
                            if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED and "
                            Log.d(TAG, "PERM_DISABLED and "
                                  + "keygaurd isn't showing.");
                            doKeyguardLocked(null);
                        } else {
                            if (DEBUG_SIM_STATES) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
                            Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
                                  + "show permanently disabled message in lockscreen.");
                            resetStateLocked();
                        }
@@ -736,9 +743,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                    break;
                case TelephonyManager.SIM_STATE_READY:
                    synchronized (KeyguardViewMediator.this) {
                        if (DEBUG_SIM_STATES) Log.d(TAG, "READY, reset state? " + mShowing);
                        Log.d(TAG, "READY, reset state? " + mShowing);
                        if (mShowing && mSimWasLocked.get(slotId, false)) {
                            if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to READY when the "
                            Log.d(TAG, "SIM moved to READY when the "
                                    + "previously was locked. Reset the state.");
                            mSimWasLocked.append(slotId, false);
                            resetStateLocked();
@@ -746,7 +753,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                    }
                    break;
                default:
                    if (DEBUG_SIM_STATES) Log.v(TAG, "Unspecific state: " + simState);
                    Log.v(TAG, "Unspecific state: " + simState);
                    break;
            }
        }
Loading