Bug 984919 - Part 1: Cannot place a new call if other sim is in use. r=hsinyi, a=1.4+
☠☠ backed out by 528ad21d6492 ☠ ☠
authorSzu-Yu Chen (Aknow) <szchen@mozilla.com>
Fri, 21 Mar 2014 02:44:00 +0100
changeset 185120 39ba48e7ce21b67ecb63031437317a9ddd22ac61
parent 185119 8aad11bd420113366084b36145ae87e2976a48c2
child 185121 8d28dc13950340d96a8881055b5dc8a30f13d612
push id5517
push userryanvm@gmail.com
push dateWed, 26 Mar 2014 20:54:18 +0000
treeherdermozilla-aurora@e4e9fa607b78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi, 1
bugs984919
milestone30.0a2
Bug 984919 - Part 1: Cannot place a new call if other sim is in use. r=hsinyi, a=1.4+
dom/telephony/gonk/TelephonyProvider.js
--- a/dom/telephony/gonk/TelephonyProvider.js
+++ b/dom/telephony/gonk/TelephonyProvider.js
@@ -30,16 +30,19 @@ const kPrefDefaultServiceId = "dom.telep
 const nsIAudioManager = Ci.nsIAudioManager;
 const nsITelephonyProvider = Ci.nsITelephonyProvider;
 
 const CALL_WAKELOCK_TIMEOUT = 5000;
 
 // Index of the CDMA second call which isn't held in RIL but only in TelephoyProvider.
 const CDMA_SECOND_CALL_INDEX = 2;
 
+const DIAL_ERROR_INVALID_STATE_ERROR = "InvalidStateError";
+const DIAL_ERROR_OTHER_CONNECTION_IN_USE = "OtherConnectionInUse";
+
 let DEBUG;
 function debug(s) {
   dump("TelephonyProvider: " + s + "\n");
 }
 
 XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() {
   try {
     return Cc["@mozilla.org/telephony/audiomanager;1"]
@@ -415,17 +418,35 @@ TelephonyProvider.prototype = {
   },
 
   isDialing: false,
   dial: function(aClientId, aNumber, aIsEmergency, aTelephonyCallback) {
     if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber);
 
     if (this.isDialing) {
       if (DEBUG) debug("Already has a dialing call. Drop.");
-      aTelephonyCallback.notifyDialError("InvalidStateError");
+      aTelephonyCallback.notifyDialError(DIAL_ERROR_INVALID_STATE_ERROR);
+      return;
+    }
+
+    // For DSDS, if there is aleady a call on SIM X, we cannot place any new
+    // call on other SIM.
+    let callOnOtherSim = false;
+    for (let cid = 0; cid < this._numClients; ++cid) {
+      if (cid === aClientId) {
+        continue;
+      }
+      if (Object.keys(this._currentCalls[cid]).length !== 0) {
+        callOnOtherSim = true;
+        break;
+      }
+    }
+    if (callOnOtherSim) {
+      if (DEBUG) debug("Already has a call on other sim. Drop.");
+      aTelephonyCallback.notifyDialError(DIAL_ERROR_OTHER_CONNECTION_IN_USE);
       return;
     }
 
     // we don't try to be too clever here, as the phone is probably in the
     // locked state. Let's just check if it's a number without normalizing
     if (!aIsEmergency) {
       aNumber = gPhoneNumberUtils.normalize(aNumber);
     }