Bug 894871 - [User Story] [Suplementary Services] Temporary MMI codes: support calling line identification restriction (+CLIR). r=hsinyi
authorJose Antonio Olivera Ortega <josea.olivera@gmail.com>
Thu, 08 Aug 2013 00:47:34 +0200
changeset 141656 400f307a949054072e5a2e9c88e8b5152963e7ec
parent 141655 62b360071b885639bf6e2a82658eb91d9e3a2f3d
child 141676 d2c0f6d0fea58462baaa75f0cf61ba2fb0965397
push id102
push userjosea.olivera@gmail.com
push dateWed, 07 Aug 2013 22:50:14 +0000
treeherderb2g-inbound@400f307a9490 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs894871
milestone26.0a1
Bug 894871 - [User Story] [Suplementary Services] Temporary MMI codes: support calling line identification restriction (+CLIR). r=hsinyi
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1493,16 +1493,35 @@ let RIL = {
    * Queries current CLIR status.
    *
    */
   getCLIR: function getCLIR(options) {
     Buf.simpleRequest(REQUEST_GET_CLIR, options);
   },
 
   /**
+   * Returns when to hide or show the caller id in the call.
+   *
+   * @param mmi
+   *        The MMI code.
+   * @return One of the CLIR_* constants.
+   */
+  _getCLIRMode: function _getCLIRMode(mmi) {
+    if (!mmi ||
+        (mmi.serviceCode != MMI_SC_CLIR) ||
+        (mmi.procedure != MMI_PROCEDURE_ACTIVATION &&
+         mmi.procedure != MMI_PROCEDURE_DEACTIVATION)) {
+      return CLIR_DEFAULT;
+    }
+
+    return mmi.procedure == MMI_PROCEDURE_ACTIVATION ? CLIR_INVOCATION :
+                                                       CLIR_SUPPRESSION;
+  },
+
+  /**
    * Enables or disables the presentation of the calling line identity (CLI) to
    * the called party when originating a call.
    *
    * @param options.clirMode
    *        Is one of the CLIR_* constants in
    *        nsIDOMMozMobileConnection interface.
    */
   setCLIR: function setCLIR(options) {
@@ -1750,31 +1769,39 @@ let RIL = {
   cachedDialRequest : null,
 
   /**
    * Dial the phone.
    *
    * @param number
    *        String containing the number to dial.
    * @param clirMode
-   *        Integer doing something XXX TODO
+   *        Integer for showing/hidding the caller Id to the called party.
    * @param uusInfo
    *        Integer doing something XXX TODO
    */
   dial: function dial(options) {
     let onerror = (function onerror(errorMsg) {
       options.callIndex = -1;
       options.rilMessageType = "callError";
       options.errorMsg = errorMsg;
       this.sendChromeMessage(options);
     }).bind(this);
 
     if (this._isEmergencyNumber(options.number)) {
       this.dialEmergencyNumber(options, onerror);
     } else {
+      // TODO: Both dial() and sendMMI() functions should be unified at some
+      // point in the future. In the mean time we handle temporary CLIR MMI
+      // commands through the dial() function. Please see bug 889737.
+      let mmi = this._parseMMI(options.number);
+      if (mmi && this._isTemporaryModeCLIR(mmi)) {
+        options.number = mmi.dialNumber;
+        options.clirMode = this._getCLIRMode(mmi);
+      }
       this.dialNonEmergencyNumber(options, onerror);
     }
   },
 
   dialNonEmergencyNumber: function dialNonEmergencyNumber(options, onerror) {
     if (this.radioState == GECKO_RADIOSTATE_OFF) {
       // Notify error in establishing the call without radio.
       onerror(GECKO_ERROR_RADIO_NOT_AVAILABLE);
@@ -2534,16 +2561,19 @@ let RIL = {
         if (options.procedure === MMI_PROCEDURE_INTERROGATION) {
           this.queryCLIP(options);
         } else {
           _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED, MMI_KS_SC_CLIP);
         }
         return;
 
       // CLIR (non-temporary ones)
+      // TODO: Both dial() and sendMMI() functions should be unified at some
+      // point in the future. In the mean time we handle temporary CLIR MMI
+      // commands through the dial() function. Please see bug 889737.
       case MMI_SC_CLIR:
         options.mmiServiceCode = MMI_KS_SC_CLIR;
         options.procedure = mmi.procedure;
         switch (options.procedure) {
           case MMI_PROCEDURE_INTERROGATION:
             this.getCLIR(options);
             return;
           case MMI_PROCEDURE_ACTIVATION:
@@ -3150,16 +3180,30 @@ let RIL = {
      } else {
        // No ecclist system property, so use our own list.
        numbers = DEFAULT_EMERGENCY_NUMBERS;
      }
 
      return numbers.indexOf(number) != -1;
    },
 
+   /**
+    * Checks whether to temporarily suppress caller id for the call.
+    *
+    * @param mmi
+    *        MMI full object.
+    */
+   _isTemporaryModeCLIR: function _isTemporaryModeCLIR(mmi) {
+     return (mmi &&
+             mmi.serviceCode == MMI_SC_CLIR &&
+             mmi.dialNumber &&
+             (mmi.procedure == MMI_PROCEDURE_ACTIVATION ||
+              mmi.procedure == MMI_PROCEDURE_DEACTIVATION));
+   },
+
   /**
    * Report STK Service is running.
    */
   reportStkServiceIsRunning: function reportStkServiceIsRunning() {
     Buf.simpleRequest(REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
   },
 
   /**