Bug 1137093 - Part 04: Refactor _switchActiveCall. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Tue, 24 Mar 2015 18:04:49 +0800
changeset 265889 dc09457ca4d1e05fa7b64ec51571c7d1c151625b
parent 265888 efc84fd8f3d2a5a627e79e2ebb0ac03bbb23af90
child 265890 51e35cce870b6dc6d329b4532f3f84cbdaf10585
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [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 04: Refactor _switchActiveCall. r=hsinyi
dom/telephony/gonk/TelephonyService.js
--- a/dom/telephony/gonk/TelephonyService.js
+++ b/dom/telephony/gonk/TelephonyService.js
@@ -669,38 +669,32 @@ TelephonyService.prototype = {
     if (DEBUG) debug("There is an active call. Hold it first before dial.");
 
     if (this._cachedDialRequest) {
       if (DEBUG) debug("Error: There already is a pending dial request.");
       aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);
       return;
     }
 
-    let autoHoldCallback = {
+    this._switchActiveCall(aClientId, {
       QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]),
 
       notifySuccess: () => {
         this._cachedDialRequest = {
           clientId: aClientId,
           options: options,
           callback: aCallback
         };
       },
 
       notifyError: (aErrorMsg) => {
         if (DEBUG) debug("Error: Fail to automatically hold the active call.");
         aCallback.notifyError(aErrorMsg);
       }
-    };
-
-    if (activeCall.isConference) {
-      this.holdConference(aClientId, autoHoldCallback);
-    } else {
-      this.holdCall(aClientId, activeCall.callIndex, autoHoldCallback);
-    }
+    });
   },
 
   _dialCdmaThreeWayCall: function(aClientId, aNumber, aCallback) {
     this._sendToRilWorker(aClientId, "cdmaFlash", { featureStr: aNumber },
                           response => {
       if (!response.success) {
         aCallback.notifyError(response.errorMsg);
         return;
@@ -1038,16 +1032,20 @@ TelephonyService.prototype = {
 
   _switchCallGsm: function(aClientId, aCallIndex, aCallback, aRequiredState) {
     let call = this._currentCalls[aClientId][aCallIndex];
     if (call.state != aRequiredState) {
       aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
       return;
     }
 
+    this._switchActiveCall(aClientId, aCallback);
+  },
+
+  _switchActiveCall: function(aClientId, aCallback) {
     this._sendToRilWorker(aClientId, "switchActiveCall", null,
                           this._defaultCallbackHandler.bind(this, aCallback));
   },
 
   _switchCallCdma: function(aClientId, aCallIndex, aCallback) {
     let call = this._currentCalls[aClientId][aCallIndex];
     if (!call.isSwitchable) {
       aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
@@ -1192,18 +1190,17 @@ TelephonyService.prototype = {
 
   _switchConference: function(aClientId, aCallback) {
     // Cannot hold/resume a conference in cdma.
     if (this._isCdmaClient(aClientId)) {
       aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
       return;
     }
 
-    this._sendToRilWorker(aClientId, "switchActiveCall", null,
-                          this._defaultCallbackHandler.bind(this, aCallback));
+    this._switchActiveCall(aClientId, aCallback);
   },
 
   holdConference: function(aClientId, aCallback) {
     this._switchConference(aClientId, aCallback);
   },
 
   resumeConference: function(aClientId, aCallback) {
     this._switchConference(aClientId, aCallback);