Bug 793192 - MMI Codes: support call forwarding. Part 2 - RIL. Query CF; r=marshall_law
authorFernando Jiménez <ferjmoreno@gmail.com>
Wed, 07 Nov 2012 14:13:48 -0800
changeset 112658 8ce4b53fb01505f20a9b4aef8b73e6a6597ca01a
parent 112657 c1feb6d4a8b59ba3ad5a376b76f0f8ab43c110f4
child 112659 85867b1963cff8a319e6848b1492e6a18f72b127
push id23833
push useremorley@mozilla.com
push dateThu, 08 Nov 2012 10:20:57 +0000
treeherdermozilla-central@e0d7b394462b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarshall_law
bugs793192
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 793192 - MMI Codes: support call forwarding. Part 2 - RIL. Query CF; r=marshall_law
dom/system/gonk/RILContentHelper.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -812,20 +812,17 @@ RILContentHelper.prototype = {
         break;
       case "RIL:USSDReceived":
         let res = JSON.stringify({message: msg.json.message,
                                   sessionEnded: msg.json.sessionEnded});
         Services.obs.notifyObservers(null, kUssdReceivedTopic, res);
         break;
       case "RIL:SendMMI:Return:OK":
       case "RIL:CancelMMI:Return:OK":
-        request = this.takeRequest(msg.json.requestId);
-        if (request) {
-          Services.DOMRequest.fireSuccess(request, msg.json.result);
-        }
+        this.handleSendCancelMMIOK(msg.json);
         break;
       case "RIL:SendMMI:Return:KO":
       case "RIL:CancelMMI:Return:KO":
         request = this.takeRequest(msg.json.requestId);
         if (request) {
           Services.DOMRequest.fireError(request, msg.json.errorMsg);
         }
         break;
@@ -940,57 +937,76 @@ RILContentHelper.prototype = {
 
     if (changed) {
       this._deliverCallback("_voicemailCallbacks",
                             "voicemailNotification",
                             [this.voicemailStatus]);
     }
   },
 
+  _cfRulesToMobileCfInfo: function _cfRulesToMobileCfInfo(rules) {
+    for (let i = 0; i < rules.length; i++) {
+      let rule = rules[i];
+      let info = new MobileCFInfo();
+
+      for (let key in rule) {
+        info[key] = rule[key];
+      }
+
+      rules[i] = info;
+    }
+  },
+
   handleGetCallForwardingOption: function handleGetCallForwardingOption(message) {
     let requestId = message.requestId;
     let request = this.takeRequest(requestId);
     if (!request) {
       return;
     }
 
     if (!message.success) {
       Services.DOMRequest.fireError(request, message.errorMsg);
       return;
     }
 
-    let rules = message.rules;
-    for (let i = 0; i < rules.length; i++) {
-      let rule = rules[i];
-      let info = new MobileCFInfo();
-
-      for (let key in rule) {
-        info[key] = rule[key];
-      }
-
-      rules[i] = info;
-    }
-
-    Services.DOMRequest.fireSuccess(request, rules);
+    this._cfRulesToMobileCfInfo(message.rules);
+    Services.DOMRequest.fireSuccess(request, message.rules);
   },
 
   handleSetCallForwardingOption: function handleSetCallForwardingOption(message) {
     let requestId = message.requestId;
     let request = this.takeRequest(requestId);
     if (!request) {
       return;
     }
 
     if (!message.success) {
       Services.DOMRequest.fireError(request, message.errorMsg);
       return;
     }
     Services.DOMRequest.fireSuccess(request, null);
   },
 
+  handleSendCancelMMIOK: function handleSendCancelMMIOK(message) {
+    let request = this.takeRequest(message.requestId);
+    if (!request) {
+      return;
+    }
+
+    // MMI query call forwarding options request returns a set of rules that
+    // will be exposed in the form of an array of nsIDOMMozMobileCFInfo
+    // instances.
+    if (message.success && message.rules) {
+      this._cfRulesToMobileCfInfo(message.rules);
+      message.result = message.rules;
+    }
+
+    Services.DOMRequest.fireSuccess(request, message.result);
+  },
+
   _getRandomId: function _getRandomId() {
     return gUUIDGenerator.generateUUID().toString();
   },
 
   _deliverCallback: function _deliverCallback(callbackType, name, args) {
     let thisCallbacks = this[callbackType];
     if (!thisCallbacks) {
       return;
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -2381,17 +2381,17 @@ let RIL = {
         // is no way that we get this far without a valid procedure or service
         // code.
         options.action = MMI_PROC_TO_CF_ACTION[mmi.procedure];
         options.rilMessageType = "sendMMI";
         options.reason = MMI_SC_TO_CF_REASON[sc];
         options.number = mmi.sia;
         options.serviceClass = mmi.sib;
         if (options.action == CALL_FORWARD_ACTION_QUERY_STATUS) {
-          _sendMMIError("CF_QUERY_STATUS_NOT_SUPPORTED");
+          this.queryCallForwardStatus(options);
           return;
         }
 
         options.timeSeconds = mmi.sic;
         this.setCallForward(options);
         return;
 
       // Change the current ICC PIN number.