Phone: Display message to indicate PIN/PUK status changes.
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.
PhoneApp: Add APIs that report actual error code on PIN/PUK operations
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.
Bug: 9928717
Change-Id: I73718c9e6a8aa7244097e0dd4593a6226ff0ac08
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 1ce46b2..82b5e9f 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -43,6 +43,7 @@
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.CallManager;
+import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.PhoneConstants;
import java.util.List;
@@ -423,13 +424,25 @@
}
public boolean supplyPin(String pin) {
+ int [] resultArray = supplyPinReportResult(pin);
+ return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
+ }
+
+ public boolean supplyPuk(String puk, String pin) {
+ int [] resultArray = supplyPukReportResult(puk, pin);
+ return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
+ }
+
+ /** {@hide} */
+ public int[] supplyPinReportResult(String pin) {
enforceModifyPermission();
final UnlockSim checkSimPin = new UnlockSim(mPhone.getIccCard());
checkSimPin.start();
return checkSimPin.unlockSim(null, pin);
}
- public boolean supplyPuk(String puk, String pin) {
+ /** {@hide} */
+ public int[] supplyPukReportResult(String puk, String pin) {
enforceModifyPermission();
final UnlockSim checkSimPuk = new UnlockSim(mPhone.getIccCard());
checkSimPuk.start();
@@ -437,7 +450,7 @@
}
/**
- * Helper thread to turn async call to {@link SimCard#supplyPin} into
+ * Helper thread to turn async call to SimCard#supplyPin into
* a synchronous one.
*/
private static class UnlockSim extends Thread {
@@ -445,7 +458,8 @@
private final IccCard mSimCard;
private boolean mDone = false;
- private boolean mResult = false;
+ private int mResult = PhoneConstants.PIN_GENERAL_FAILURE;
+ private int mRetryCount = -1;
// For replies from SimCard interface
private Handler mHandler;
@@ -469,7 +483,18 @@
case SUPPLY_PIN_COMPLETE:
Log.d(LOG_TAG, "SUPPLY_PIN_COMPLETE");
synchronized (UnlockSim.this) {
- mResult = (ar.exception == null);
+ mRetryCount = msg.arg1;
+ if (ar.exception != null) {
+ if (ar.exception instanceof CommandException &&
+ ((CommandException)(ar.exception)).getCommandError()
+ == CommandException.Error.PASSWORD_INCORRECT) {
+ mResult = PhoneConstants.PIN_PASSWORD_INCORRECT;
+ } else {
+ mResult = PhoneConstants.PIN_GENERAL_FAILURE;
+ }
+ } else {
+ mResult = PhoneConstants.PIN_RESULT_SUCCESS;
+ }
mDone = true;
UnlockSim.this.notifyAll();
}
@@ -489,7 +514,7 @@
*
* If PUK is not null, unlock SIM card with PUK and set PIN code
*/
- synchronized boolean unlockSim(String puk, String pin) {
+ synchronized int[] unlockSim(String puk, String pin) {
while (mHandler == null) {
try {
@@ -516,7 +541,10 @@
}
}
Log.d(LOG_TAG, "done");
- return mResult;
+ int[] resultArray = new int[2];
+ resultArray[0] = mResult;
+ resultArray[1] = mRetryCount;
+ return resultArray;
}
}