Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling via MMI codes. Part 1 - RIL; r=marshall_law
authorFernando Jiménez <ferjmoreno@gmail.com>
Fri, 19 Oct 2012 11:33:34 +0200
changeset 110750 c8eb7dfe86781bf76649691cc553d8255bad5502
parent 110749 445aca56acf68c6a2a51c439ea5c7e0329a275ad
child 110751 4807f1c1308ea664f334868bdd36dcf95da71630
push id16724
push userferjmoreno@gmail.com
push dateFri, 19 Oct 2012 10:34:32 +0000
treeherdermozilla-inbound@4807f1c1308e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarshall_law
bugs793187
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling via MMI codes. Part 1 - RIL; r=marshall_law
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -2323,16 +2323,38 @@ let RIL = {
     let mmi = this._parseMMI(mmiString);
 
     let _sendMMIError = (function _sendMMIError(errorMsg) {
       options.rilMessageType = "sendMMI";
       options.errorMsg = errorMsg;
       this.sendDOMMessage(options);
     }).bind(this);
 
+    function _isValidPINPUKRequest() {
+      // The only allowed MMI procedure for ICC PIN, PIN2, PUK and PUK2 handling
+      // is "Registration" (**).
+      if (!mmi.procedure || mmi.procedure != MMI_PROCEDURE_REGISTRATION ) {
+        _sendMMIError("WRONG_MMI_PROCEDURE");
+        return;
+      }
+
+      if (!mmi.sia || !mmi.sia.length || !mmi.sib || !mmi.sib.length ||
+          !mmi.sic || !mmi.sic.length) {
+        _sendMMIError("MISSING_SUPPLEMENTARY_INFORMATION");
+        return;
+      }
+
+      if (mmi.sib != mmi.sic) {
+        _sendMMIError("NEW_PIN_MISMATCH");
+        return;
+      }
+
+      return true;
+    }
+
     if (mmi == null) {
       if (this._ussdSession) {
         options.ussd = mmiString;
         this.sendUSSD(options);
         return;
       }
       _sendMMIError("NO_VALID_MMI_STRING");
       return;
@@ -2353,23 +2375,78 @@ let RIL = {
       case MMI_SC_CF_NO_REPLY:
       case MMI_SC_CF_NOT_REACHABLE:
       case MMI_SC_CF_ALL:
       case MMI_SC_CF_ALL_CONDITIONAL:
         // TODO: Bug 793192 - MMI Codes: support call forwarding.
         _sendMMIError("CALL_FORWARDING_NOT_SUPPORTED_VIA_MMI");
         return;
 
-      // PIN/PIN2/PUK/PUK2
+      // Change the current ICC PIN number.
       case MMI_SC_PIN:
+        // As defined in TS.122.030 6.6.2 to change the ICC PIN we should expect
+        // an MMI code of the form **04*OLD_PIN*NEW_PIN*NEW_PIN#, where old PIN
+        // should be entered as the SIA parameter and the new PIN as SIB and
+        // SIC.
+        if (!_isValidPINPUKRequest()) {
+          return;
+        }
+
+        options.rilRequestType = "sendMMI";
+        options.pin = mmi.sia;
+        options.newPin = mmi.sib;
+        this.changeICCPIN(options);
+        return;
+
+      // Change the current ICC PIN2 number.
       case MMI_SC_PIN2:
+        // As defined in TS.122.030 6.6.2 to change the ICC PIN2 we should
+        // enter and MMI code of the form **042*OLD_PIN2*NEW_PIN2*NEW_PIN2#,
+        // where the old PIN2 should be entered as the SIA parameter and the
+        // new PIN2 as SIB and SIC.
+        if (!_isValidPINPUKRequest()) {
+          return;
+        }
+
+        options.rilRequestType = "sendMMI";
+        options.pin = mmi.sia;
+        options.newPin = mmi.sib;
+        this.changeICCPIN2(options);
+        return;
+
+      // Unblock ICC PIN.
       case MMI_SC_PUK:
+        // As defined in TS.122.030 6.6.3 to unblock the ICC PIN we should
+        // enter an MMI code of the form **05*PUK*NEW_PIN*NEW_PIN#, where PUK
+        // should be entered as the SIA parameter and the new PIN as SIB and
+        // SIC.
+        if (!_isValidPINPUKRequest()) {
+          return;
+        }
+
+        options.rilRequestType = "sendMMI";
+        options.puk = mmi.sia;
+        options.newPin = mmi.sib;
+        this.enterICCPUK(options);
+        return;
+
+      // Unblock ICC PIN2.
       case MMI_SC_PUK2:
-        // TODO: Bug 793187 - MMI Codes: Support PIN/PIN2/PUK handling.
-        _sendMMIError("SIM_FUNCTION_NOT_SUPPORTED_VIA_MMI");
+        // As defined in TS.122.030 6.6.3 to unblock the ICC PIN2 we should
+        // enter an MMI code of the form **052*PUK2*NEW_PIN2*NEW_PIN2#, where
+        // PUK2 should be entered as the SIA parameter and the new PIN2 as SIB
+        // and SIC.
+        if (!_isValidPINPUKRequest()) {
+          return;
+        }
+
+        options.rilRequestType = "sendMMI";
+        options.puk = mmi.sia;
+        options.newPin = mmi.sib;
+        this.enterICCPUK2(options);
         return;
 
       // IMEI
       case MMI_SC_IMEI:
         // A device's IMEI can't change, so we only need to request it once.
         if (this.IMEI == null) {
           this.getIMEI({mmi: true});
           return;