Bug 883048 - [MMI] Send a ussd code while in airplane mode is allowed and doesn't show any notification. r=vicamo, a=leo+
authorFernando Jiménez <ferjmoreno@gmail.com>
Fri, 12 Jul 2013 10:42:17 +0200
changeset 119736 282b5c37cf8d
parent 119735 8b39fe30acb8
child 119737 6107703a0cdc
push id962
push userryanvm@gmail.com
push date2013-07-12 13:50 +0000
reviewersvicamo, leo
bugs883048
milestone18.1
Bug 883048 - [MMI] Send a ussd code while in airplane mode is allowed and doesn't show any notification. r=vicamo, a=leo+
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -3167,22 +3167,35 @@ let RIL = {
           mmi.sic.length < 4 || mmi.sic.length > 8) {
         _sendMMIError(MMI_ERROR_KS_INVALID_PIN, mmiServiceCode);
         return;
       }
 
       return true;
     }
 
-    if (mmi == null) {
+    function _isRadioAvailable(mmiServiceCode) {
+      if (RIL.radioState !== GECKO_RADIOSTATE_READY) {
+        _sendMMIError(GECKO_ERROR_RADIO_NOT_AVAILABLE, mmiServiceCode);
+        return false;
+      }
+      return true;
+    }
+
+    // If we couldn't parse the MMI code, we'll send it as an USSD request.
+    if (mmi === null) {
       if (this._ussdSession) {
+        if (!_isRadioAvailable(MMI_KS_SC_USSD)) {
+          return;
+        }
         options.ussd = mmiString;
         this.sendUSSD(options);
         return;
       }
+
       _sendMMIError(MMI_ERROR_KS_ERROR);
       return;
     }
 
     if (DEBUG) {
       debug("MMI " + JSON.stringify(mmi));
     }
 
@@ -3194,16 +3207,19 @@ let RIL = {
     switch (sc) {
       // Call forwarding
       case MMI_SC_CFU:
       case MMI_SC_CF_BUSY:
       case MMI_SC_CF_NO_REPLY:
       case MMI_SC_CF_NOT_REACHABLE:
       case MMI_SC_CF_ALL:
       case MMI_SC_CF_ALL_CONDITIONAL:
+        if (!_isRadioAvailable(MMI_KS_SC_CALL_FORWARDING)) {
+          return;
+        }
         // Call forwarding requires at least an action, given by the MMI
         // procedure, and a reason, given by the MMI service code, but there
         // is no way that we get this far without a valid procedure or service
         // code.
         options.mmiServiceCode = MMI_KS_SC_CALL_FORWARDING;
         options.action = MMI_PROC_TO_CF_ACTION[mmi.procedure];
         options.reason = MMI_SC_TO_CF_REASON[sc];
         options.number = mmi.sia;
@@ -3220,65 +3236,69 @@ let RIL = {
         return;
 
       // 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(MMI_KS_SC_PIN)) {
+        if (!_isRadioAvailable(MMI_KS_SC_PIN) ||
+            !_isValidPINPUKRequest(MMI_KS_SC_PIN)) {
           return;
         }
 
         options.mmiServiceCode = MMI_KS_SC_PIN;
         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(MMI_KS_SC_PIN2)) {
+        if (!_isRadioAvailable(MMI_KS_SC_PIN2) ||
+            !_isValidPINPUKRequest(MMI_KS_SC_PIN2)) {
           return;
         }
 
         options.mmiServiceCode = MMI_KS_SC_PIN2;
         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(MMI_KS_SC_PUK)) {
+        if (!_isRadioAvailable(MMI_KS_SC_PUK) ||
+            !_isValidPINPUKRequest(MMI_KS_SC_PUK)) {
           return;
         }
 
         options.mmiServiceCode = MMI_KS_SC_PUK;
         options.puk = mmi.sia;
         options.newPin = mmi.sib;
         this.enterICCPUK(options);
         return;
 
       // Unblock ICC PIN2.
       case MMI_SC_PUK2:
         // 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(MMI_KS_SC_PUK2)) {
+        if (!_isRadioAvailable(MMI_KS_SC_PUK2) ||
+            !_isValidPINPUKRequest(MMI_KS_SC_PUK2)) {
           return;
         }
 
         options.mmiServiceCode = MMI_KS_SC_PUK2;
         options.puk = mmi.sia;
         options.newPin = mmi.sib;
         this.enterICCPUK2(options);
         return;
@@ -3315,16 +3335,20 @@ let RIL = {
         _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
         return;
     }
 
     // If the MMI code is not a known code and is a recognized USSD request or
     // a #-string, it shall still be sent as a USSD request.
     if (mmi.fullMMI &&
         (mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD)) {
+      if (!_isRadioAvailable(MMI_KS_SC_USSD)) {
+        return;
+      }
+
       options.ussd = mmi.fullMMI;
       options.mmiServiceCode = MMI_KS_SC_USSD;
       this.sendUSSD(options);
       return;
     }
 
     // At this point, the MMI string is considered as not valid MMI code and
     // not valid USSD code.