OSDN Git Service

Fix error message shown when SIM PIN enable/disable fails
authorSandeep Gutta <sangutta@codeaurora.org>
Tue, 18 Sep 2018 06:51:27 +0000 (12:21 +0530)
committerSandeep Gutta <sangutta@codeaurora.org>
Tue, 18 Sep 2018 06:51:51 +0000 (12:21 +0530)
Current code fails to pass the 3GPP spec test case 27.14.3
'Disabling the PIN'.

An Incorrect toast error message is displayed, when enable/disable
SIM PIN operation fails without checking the error code.

Fix: Display appropriate toast error message based on the SIM PIN
enable/disable error code.

Bug: 73080305
Change-Id: I4219c68c7ebcf450a2f779b2d1f1ce881440753b

res/values/strings.xml
src/com/android/settings/IccLockSettings.java

index 1f06276..f5447e5 100644 (file)
     <string name="sim_change_succeeded">SIM PIN changed successfully</string>
     <!-- SIM card lock settings screen, toast after not entering correct SIM PIN [CHAR LIMIT=40] -->
     <string name="sim_lock_failed">Can\u2019t change SIM card lock state.\nPossibly incorrect PIN.</string>
+    <!-- SIM card lock settings screen, toast after disabling PIN failed from modem -->
+    <string name="sim_pin_disable_failed">Can\'t disable PIN.</string>
+    <!-- SIM card lock settings screen, toast after enabling PIN failed from modem -->
+    <string name="sim_pin_enable_failed">Can\'t enable PIN.</string>
     <!-- SIM card lock settings screen, SIM PIN dialog button labels: [CHAR LIMIT=40] -->
     <string name="sim_enter_ok">OK</string>
     <!-- SIM card lock settings screen, SIM PIN dialog button labels: [CHAR LIMIT=40] -->
index 7d493eb..2ff6931 100644 (file)
@@ -44,6 +44,7 @@ import android.widget.TabHost.TabSpec;
 import android.widget.TabWidget;
 import android.widget.Toast;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.telephony.CommandException;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.TelephonyIntents;
@@ -121,7 +122,7 @@ public class IccLockSettings extends SettingsPreferenceFragment
             AsyncResult ar = (AsyncResult) msg.obj;
             switch (msg.what) {
                 case MSG_ENABLE_ICC_PIN_COMPLETE:
-                    iccLockChanged(ar.exception == null, msg.arg1);
+                    iccLockChanged(ar.exception == null, msg.arg1, ar.exception);
                     break;
                 case MSG_CHANGE_ICC_PIN_COMPLETE:
                     iccPinChanged(ar.exception == null, msg.arg1);
@@ -451,12 +452,25 @@ public class IccLockSettings extends SettingsPreferenceFragment
         mPinToggle.setEnabled(false);
     }
 
-    private void iccLockChanged(boolean success, int attemptsRemaining) {
+    private void iccLockChanged(boolean success, int attemptsRemaining, Throwable exception) {
         if (success) {
             mPinToggle.setChecked(mToState);
         } else {
-            Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
-                    Toast.LENGTH_LONG).show();
+            if (exception instanceof CommandException) {
+                CommandException.Error err = ((CommandException)(exception)).getCommandError();
+                if (err == CommandException.Error.PASSWORD_INCORRECT) {
+                    Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
+                            Toast.LENGTH_LONG).show();
+                } else {
+                    if (mToState) {
+                        Toast.makeText(getContext(), mRes.getString
+                               (R.string.sim_pin_enable_failed), Toast.LENGTH_LONG).show();
+                    } else {
+                        Toast.makeText(getContext(), mRes.getString
+                               (R.string.sim_pin_disable_failed), Toast.LENGTH_LONG).show();
+                    }
+                }
+            }
         }
         mPinToggle.setEnabled(true);
         resetDialogState();