Bug 1137093 - Part 01: Pass number instead of callIndex in notifySupplementaryService. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Tue, 24 Mar 2015 18:04:49 +0800
changeset 264424 e6bbb392c4004c1f50f18b3ef046d693c903c8bb
parent 264423 ce9d76dfb678a7ba73a98ec348180e9f8ac0ce72
child 264425 3998492533ff746413f302b24bc0543964b27e87
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1137093
milestone39.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 1137093 - Part 01: Pass number instead of callIndex in notifySupplementaryService. r=hsinyi
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/ril_worker.js
dom/telephony/gonk/TelephonyService.js
dom/telephony/nsIGonkTelephonyService.idl
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -1868,17 +1868,17 @@ RadioInterface.prototype = {
         gTelephonyService.notifyConferenceCallStateChanged(message.state);
         break;
       case "cdmaCallWaiting":
         gTelephonyService.notifyCdmaCallWaiting(this.clientId,
                                                 message.waitingCall);
         break;
       case "suppSvcNotification":
         gTelephonyService.notifySupplementaryService(this.clientId,
-                                                     message.callIndex,
+                                                     message.number,
                                                      message.notification);
         break;
       case "ussdreceived":
         gTelephonyService.notifyUssdReceived(this.clientId, message.message,
                                              message.sessionEnded);
         break;
       case "datacalllistchanged":
         connHandler.handleDataCallListChanged(message.datacalls);
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -3920,48 +3920,30 @@ RilObject.prototype = {
       // We haven't supported MO intermediate result code, i.e.
       // info.notificationType === 0, which refers to code1 defined in 3GPP
       // 27.007 7.17. We only support partial MT unsolicited result code,
       // referring to code2, for now.
       return;
     }
 
     let notification = null;
-    let callIndex = -1;
 
     switch (info.code) {
       case SUPP_SVC_NOTIFICATION_CODE2_PUT_ON_HOLD:
       case SUPP_SVC_NOTIFICATION_CODE2_RETRIEVED:
         notification = GECKO_SUPP_SVC_NOTIFICATION_FROM_CODE2[info.code];
         break;
       default:
         // Notification type not supported.
         return;
     }
 
-    // Get the target call object for this notification.
-    let currentCallIndexes = Object.keys(this.currentCalls);
-    if (currentCallIndexes.length === 1) {
-      // Only one call exists. This should be the target.
-      callIndex = currentCallIndexes[0];
-    } else {
-      // Find the call in |currentCalls| by the given number.
-      if (info.number) {
-        for each (let currentCall in this.currentCalls) {
-          if (currentCall.number == info.number) {
-            callIndex = currentCall.callIndex;
-            break;
-          }
-        }
-      }
-    }
-
     let message = {rilMessageType: "suppSvcNotification",
-                   notification: notification,
-                   callIndex: callIndex};
+                   number: info.number,  // could be empty.
+                   notification: notification};
     this.sendChromeMessage(message);
   },
 
   _cancelEmergencyCbModeTimeout: function() {
     if (this._exitEmergencyCbModeTimeoutID) {
       clearTimeout(this._exitEmergencyCbModeTimeoutID);
       this._exitEmergencyCbModeTimeoutID = null;
     }
--- a/dom/telephony/gonk/TelephonyService.js
+++ b/dom/telephony/gonk/TelephonyService.js
@@ -1328,20 +1328,41 @@ TelephonyService.prototype = {
 
     this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId,
                                                        aCall.number,
                                                        aCall.numberPresentation,
                                                        aCall.name,
                                                        aCall.namePresentation]);
   },
 
-  notifySupplementaryService: function(aClientId, aCallIndex, aNotification) {
+  notifySupplementaryService: function(aClientId, aNumber, aNotification) {
     let notification = this._convertRILSuppSvcNotification(aNotification);
+
+    // Get the target call object for this notification.
+    let callIndex = -1;
+
+    let indexes = Object.keys(this.currentCalls);
+    if (indexes.length === 1) {
+      // Only one call exists. This should be the target.
+      callIndex = indexes[0];
+    } else {
+      // Find the call in |currentCalls| by the given number.
+      if (aNumber) {
+        for (let i in this._currentCalls) {
+          let call = this._currentCalls[aClientId][i];
+          if (call.number === aNumber) {
+            callIndex = i;
+            break;
+          }
+        }
+      }
+    }
+
     this._notifyAllListeners("supplementaryServiceNotification",
-                             [aClientId, aCallIndex, notification]);
+                             [aClientId, callIndex, notification]);
   },
 
   notifyConferenceCallStateChanged: function(aState) {
     if (DEBUG) debug("handleConferenceCallStateChanged: " + aState);
     this._currentConferenceState = this._convertRILCallState(aState);
     this._notifyAllListeners("conferenceCallStateChanged",
                              [this._currentConferenceState]);
   },
--- a/dom/telephony/nsIGonkTelephonyService.idl
+++ b/dom/telephony/nsIGonkTelephonyService.idl
@@ -5,30 +5,30 @@
 
 #include "nsITelephonyService.idl"
 
 %{C++
 #define GONK_TELEPHONY_SERVICE_CONTRACTID \
         "@mozilla.org/telephony/gonktelephonyservice;1"
 %}
 
-[scriptable, uuid(eab4b7b4-bf78-4c44-8182-ca305e70f971)]
+[scriptable, uuid(bf1327e7-ce5f-4bc4-b8ba-101bbe57ff69)]
 interface nsIGonkTelephonyService : nsITelephonyService
 {
   void notifyAudioStateChanged(in unsigned long clientId, in short state);
 
   void notifyCallDisconnected(in unsigned long clientId, in jsval call);
 
   void notifyCallRing();
 
   void notifyCallStateChanged(in unsigned long clientId, in jsval call,
                               [optional] in boolean skipStateConversion);
 
   void notifyCdmaCallWaiting(in unsigned long clientId, in jsval waitingCall);
 
-  void notifySupplementaryService(in unsigned long clientId, in long callIndex,
+  void notifySupplementaryService(in unsigned long clientId, in AString number,
                                   in AString notification);
 
   void notifyConferenceCallStateChanged(in short state);
 
   void notifyUssdReceived(in unsigned long clientId, in DOMString message,
                           in boolean sessionEnded);
 };