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

Commit 1b03d67e authored by Umashankar Godachi's avatar Umashankar Godachi Committed by Gerrit - the friendly Code Review server
Browse files

MSIM: Fix to show PUK view when two sims locked on PIN.

Currently when both sims are locked on PIN, upon exhausting
PIN attempts for SIM1 PIN, SIM1 PUK view is not displayed
and the user is not able to unlock the PUK.

This is due to while fetching the getSecurityMode in Key
-GuardSecurityModel, the ordering of checking the security
mode is PIN first and PUK later.So when one sim is locked
on PUK and the other is locked on PIN the ordering of checking
the PIN first is causing to return PIN as security mode in place
of PUK. This will lead to PUK lock screen not been shown to user.

Fix: In KeyGuardSecurityModel.java, while querying the security Mode
modify the order to check for security mode i.e PUK locked state first
and then PIN locked state.

In KeyGuardSimPinView and KeyGuardSimPukView, check for sim locked on
PIN and reset the flags to show the default message.

Change-Id: I97fb81c23a94c18a37c251337ef48f62d26240a7
CRs-Fixed: 1041754
parent 4404f4a2
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -57,16 +57,16 @@ public class KeyguardSecurityModel {
    SecurityMode getSecurityMode() {
        KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);

        if (SubscriptionManager.isValidSubscriptionId(
                monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED))) {
            return SecurityMode.SimPin;
        }

        if (mIsPukScreenAvailable && SubscriptionManager.isValidSubscriptionId(
                monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED))) {
            return SecurityMode.SimPuk;
        }

        if (SubscriptionManager.isValidSubscriptionId(
                monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED))) {
            return SecurityMode.SimPin;
        }

        final int security = mLockPatternUtils.getActivePasswordQuality(
                KeyguardUpdateMonitor.getCurrentUser());
        switch (security) {
+14 −7
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    private int mRemainingAttempts = -1;
    private int mResult = PhoneConstants.PIN_PASSWORD_INCORRECT;
    private AlertDialog mRemainingAttemptsDialog;
    private int mSubId;
    private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private int mSlotId;
    private ImageView mSimImageView;

@@ -78,11 +78,22 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    public void resetState() {
        super.resetState();
        if (DEBUG) Log.v(TAG, "Resetting state");
        handleSubInfoChangeIfNeeded();
        if (mShowDefaultMessage) {
            showDefaultMessage();
        }
    }

    private void handleSubInfoChangeIfNeeded() {
        KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
        int subId = monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED);
        if (subId != mSubId && SubscriptionManager.isValidSubscriptionId(subId)) {
            mSubId = subId;
            mShowDefaultMessage = true;
            mRemainingAttempts = -1;
        }
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
@@ -317,11 +328,6 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    }

    private void showDefaultMessage() {
        KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
        mSubId = monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED);
        if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
            return;
        }
        if (mRemainingAttempts >= 0) {
            if (mResult != PhoneConstants.PIN_RESULT_SUCCESS)
                mSecurityMessageDisplay.setMessage(
@@ -338,7 +344,8 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
        if (count < 2) {
            msg = rez.getString(R.string.kg_sim_pin_instructions);
        } else {
            SubscriptionInfo info = monitor.getSubscriptionInfoForSubId(mSubId);
            SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).
                    getSubscriptionInfoForSubId(mSubId);
            CharSequence displayName = info != null ? info.getDisplayName() : ""; // don't crash
            msg = rez.getString(R.string.kg_sim_pin_instructions_multi, displayName);
            if (info != null) {
+14 −7
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
    private String mPinText;
    private StateMachine mStateMachine = new StateMachine();
    private AlertDialog mRemainingAttemptsDialog;
    private int mSubId;
    private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private ImageView mSimImageView;

    KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() {
@@ -118,6 +118,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
            mPinText="";
            mPukText="";
            state = ENTER_PUK;
            handleSubInfoChangeIfNeeded();
            if (mShowDefaultMessage) {
                showDefaultMessage();
            }
@@ -125,6 +126,16 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
        }
    }

    private void handleSubInfoChangeIfNeeded() {
        KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
        int subId = monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED);
        if (subId != mSubId && SubscriptionManager.isValidSubscriptionId(subId)) {
            mSubId = subId;
            mShowDefaultMessage = true;
            mRemainingAttempts = -1;
        }
    }

    @Override
    protected int getPromtReasonStringRes(int reason) {
        // No message on SIM Puk
@@ -377,11 +388,6 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
    }

    private void showDefaultMessage() {
        KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
        mSubId = monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED);
        if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
            return;
        }
        if (mRemainingAttempts >= 0) {
            mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage(
                    mRemainingAttempts, true), true);
@@ -395,7 +401,8 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
        if (count < 2) {
            msg = rez.getString(R.string.kg_puk_enter_puk_hint);
        } else {
            SubscriptionInfo info = monitor.getSubscriptionInfoForSubId(mSubId);
            SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).
                    getSubscriptionInfoForSubId(mSubId);
            CharSequence displayName = info != null ? info.getDisplayName() : "";
            msg = rez.getString(R.string.kg_puk_enter_puk_hint_multi, displayName);
            if (info != null) {