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

Commit 411d016a authored by Rakesh Pallerla's avatar Rakesh Pallerla Committed by Linux Build Service Account
Browse files

Telephony: Few PIN/PUK fixes

Following changes have been made as part of this:
-> Changes done to display retry counter on wrong entry of
   PIN1,and message to indicate Code accepted/PIN1 blocked
   during PIN1 verification as per certain carrier requirements.
-> The current APIs that are used to verify the PIN and PUK only
   convey whether the operation succeeded or failed. As a result
   on ANY failure clients ask the user to re-enter the PIN.
   Add 2 new APIs that report the actual error code in case of
   failure.
-> Display the complete text including attempts remaining to
   unlock PIN on SimUnlockScreen if user entered incorrect PIN.
   On some devices the display text is ellipsized when trying to
   display on a single line.

Change-Id: I73718c9e6a8aa7244097e0dd4593a6226ff0ac08
CRs-Fixed: 184479, 260481, 181402, 181380, 181401, 326286, 441001,
479414, 479417
(cherry picked from commit 1cfe4cb95d29b792e40c6a89cf2fdb1a0b8371e7)
(cherry picked from commit a50adebc939f1ff6cb9633ba116f4e7d1ffe60e3)
(cherry picked from commit e29e99706ad4e8ddc06f157a9a56e5dcaf0e49e7)
parent 9fc8b91c
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@
         the SIM card. -->
    <string name="needPuk">Your SIM card is PUK-locked. Type the PUK code to unlock it.</string>
    <string name="needPuk2">Type PUK2 to unblock SIM card.</string>
    <!-- Displayed when user attempts to change SIM PIN1 without enabling PIN1. -->
    <string name="enablePin">Unsuccessful. Enable SIM/RUIM Lock.</string>
    <!-- Title for the dialog used to display the user's IMEI number [CHAR LIMIT=10] -->
    <string name="imei">IMEI</string>

@@ -2262,6 +2264,9 @@
         to unlock the keyguard.  Displayed in one line in a large font.  -->
    <string name="keyguard_password_wrong_pin_code">Incorrect PIN code.</string>

    <!-- Displayed when a SIM PIN/PUK is entered incorrectly. -->
    <string name="pinpuk_attempts">\nAttempts Remaining :</string>

    <!-- Instructions telling the user how to unlock the phone. -->
    <string name="keyguard_label_text">To unlock, press Menu then 0.</string>

@@ -2351,10 +2356,10 @@
         PUK locked (Pin Unlock Kode) -->
    <string name="lockscreen_sim_puk_locked_message">SIM card is PUK-locked.</string>
    <!-- Shown in the lock screen when the SIM has become PUK locked and the user must call customer care to unlock it. -->
    <string name="lockscreen_sim_puk_locked_instructions">See the User Guide or contact Customer Care.</string>
    <string name="lockscreen_sim_puk_locked_instructions">PIN1 Blocked. Enter PUK1\nor\nPlease see the User Guide or contact Customer Care.</string>

    <!-- Shown in the lock screen to tell the user that their SIM is locked and they must unlock it. -->
    <string name="lockscreen_sim_locked_message">SIM card is locked.</string>
    <!-- Shown in the lock screen to tell the user that their SIM/RUIM is locked and they must unlock it. -->
    <string name="lockscreen_sim_locked_message">SIM/RUIM card is locked.</string>

    <!-- For the unlock screen, When the user enters a sim unlock code, it takes a little while to check
         whether it is valid, and to unlock the sim if it is valid.  we display a
+2 −0
Original line number Diff line number Diff line
@@ -455,6 +455,7 @@
  <java-symbol type="string" name="autofill_zip_code_re" />
  <java-symbol type="string" name="badPin" />
  <java-symbol type="string" name="badPuk" />
  <java-symbol type="string" name="pinpuk_attempts" />
  <java-symbol type="string" name="byteShort" />
  <java-symbol type="string" name="capability_desc_canRequestEnhancedWebAccessibility" />
  <java-symbol type="string" name="capability_title_canRequestFilterKeyEvents" />
@@ -630,6 +631,7 @@
  <java-symbol type="string" name="orgTypeOther" />
  <java-symbol type="string" name="orgTypeWork" />
  <java-symbol type="string" name="passwordIncorrect" />
  <java-symbol type="string" name="enablePin" />
  <java-symbol type="string" name="perms_description_app" />
  <java-symbol type="string" name="perms_new_perm_prefix" />
  <java-symbol type="string" name="petabyteShort" />
+22 −0
Original line number Diff line number Diff line
@@ -46,6 +46,28 @@
         to unlock the keyguard.  Displayed in one line in a large font.  -->
    <string name="keyguard_password_wrong_pin_code">Incorrect PIN code.</string>

    <!-- Instructions telling the user that they entered the wrong puk while trying
         to unlock the keyguard.  Displayed in one line in a large font.  -->
    <string name="keyguard_password_wrong_puk_code">Incorrect PUK code!</string>

    <!-- Instructions telling the user that the operation to unlock the keyguard
         with PIN failed. Displayed in one line in a large font.  -->
    <string name="keyguard_password_pin_failed">PIN operation failed!</string>

    <!-- Instructions telling the user that the operation to unlock the keyguard
         with PUK failed. Displayed in one line in a large font.  -->
    <string name="keyguard_password_puk_failed">PUK operation failed!</string>


    <!-- Notification telling the user that the PIN1 they entered is valid -->
    <string name="keyguard_pin_accepted">Code Accepted!</string>

    <!-- Displayed when a SIM PIN/PUK is entered incorrectly. -->
    <string name="pinpuk_attempts">\nAttempts Remaining :</string>

    <!-- Shown in the lock screen when there is SIM card IO error. -->
    <string name="lockscreen_sim_error_message_short">Invalid Card.</string>

    <!-- Instructions telling the user how to unlock the phone. -->
    <string name="keyguard_label_text">To unlock, press Menu then 0.</string>

+10 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ public class CarrierText extends TextView {
        SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times
        SimLocked, // SIM card is currently locked
        SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
        SimNotReady; // SIM is not ready yet. May never be on devices w/o a SIM.
        SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
        SimIoError; //The sim card is faulty
    }

    public CarrierText(Context context) {
@@ -162,6 +163,12 @@ public class CarrierText extends TextView {
                        getContext().getText(R.string.keyguard_sim_puk_locked_message),
                        plmn);
                break;

            case SimIoError:
                carrierText = makeCarrierStringOnEmergencyCapable(
                        getContext().getText(R.string.lockscreen_sim_error_message_short),
                        plmn);
                break;
        }

        return carrierText;
@@ -211,6 +218,8 @@ public class CarrierText extends TextView {
                return StatusMode.SimPermDisabled;
            case UNKNOWN:
                return StatusMode.SimMissing;
            case CARD_IO_ERROR:
                return StatusMode.SimIoError;
        }
        return StatusMode.SimMissing;
    }
+29 −9
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.keyguard;

import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.PhoneConstants;

import android.content.Context;
import android.app.Activity;
@@ -30,6 +31,7 @@ import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.util.AttributeSet;
import android.view.View;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView.OnEditorActionListener;

@@ -51,7 +53,20 @@ public class KeyguardSimPinView extends KeyguardAbsKeyInputView
    }

    public void resetState() {
        mSecurityMessageDisplay.setMessage(R.string.kg_sim_pin_instructions, true);
        String  displayMessage = "";
        try {
            int attemptsRemaining = ITelephony.Stub.asInterface(ServiceManager
                    .checkService("phone")).getIccPin1RetryCount();
            if (attemptsRemaining >= 0) {
                displayMessage = getContext().getString(R.string.keyguard_password_wrong_pin_code)
                        + getContext().getString(R.string.pinpuk_attempts)
                        + attemptsRemaining + ". ";
            }
        } catch (RemoteException ex) {
            displayMessage = getContext().getString(R.string.keyguard_password_pin_failed);
        }
        displayMessage = displayMessage + getContext().getString(R.string.kg_sim_pin_instructions) ;
        mSecurityMessageDisplay.setMessage(displayMessage, true);
        mPasswordEntry.setEnabled(true);
    }

@@ -135,13 +150,13 @@ public class KeyguardSimPinView extends KeyguardAbsKeyInputView
            mPin = pin;
        }

        abstract void onSimCheckResponse(boolean success);
        abstract void onSimCheckResponse(final int result);

        @Override
        public void run() {
            try {
                final boolean result = ITelephony.Stub.asInterface(ServiceManager
                        .checkService("phone")).supplyPin(mPin);
                final int result = ITelephony.Stub.asInterface(ServiceManager
                        .checkService("phone")).supplyPinReportResult(mPin);
                post(new Runnable() {
                    public void run() {
                        onSimCheckResponse(result);
@@ -150,7 +165,7 @@ public class KeyguardSimPinView extends KeyguardAbsKeyInputView
            } catch (RemoteException e) {
                post(new Runnable() {
                    public void run() {
                        onSimCheckResponse(false);
                        onSimCheckResponse(PhoneConstants.PIN_GENERAL_FAILURE);
                    }
                });
            }
@@ -189,20 +204,25 @@ public class KeyguardSimPinView extends KeyguardAbsKeyInputView
        if (!mSimCheckInProgress) {
            mSimCheckInProgress = true; // there should be only one
            new CheckSimPin(mPasswordEntry.getText().toString()) {
                void onSimCheckResponse(final boolean success) {
                void onSimCheckResponse(final int result) {
                    post(new Runnable() {
                        public void run() {
                            if (mSimUnlockProgressDialog != null) {
                                mSimUnlockProgressDialog.hide();
                            }
                            if (success) {
                            if (result == PhoneConstants.PIN_RESULT_SUCCESS) {
                                // before closing the keyguard, report back that the sim is unlocked
                                // so it knows right away.
                                KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked();
                                mCallback.dismiss(true);
                            } else {
                                if (result == PhoneConstants.PIN_PASSWORD_INCORRECT) {
                                    mSecurityMessageDisplay.setMessage
                                            (R.string.kg_password_wrong_pin_code, true);
                                } else {
                                    mSecurityMessageDisplay.setMessage
                                            (R.string.keyguard_password_pin_failed, true);
                                }
                                mPasswordEntry.setText("");
                            }
                            mCallback.userActivity(0);
Loading