From a867c34ed0c52d8f7b53c725bfc55d88950918be Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 30 Jul 2015 11:36:27 +0800 Subject: [PATCH] Bug 1185156 - Fix bug in resuming held call. r=hsinyi --- dom/telephony/gonk/TelephonyService.js | 30 +++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/dom/telephony/gonk/TelephonyService.js b/dom/telephony/gonk/TelephonyService.js index 9b5b33ecc98..f2a75e506b9 100644 --- a/dom/telephony/gonk/TelephonyService.js +++ b/dom/telephony/gonk/TelephonyService.js @@ -1883,13 +1883,37 @@ TelephonyService.prototype = { return; } - // It's a foreground call. + // After hangup a single call, gecko has to resume the held call or conference. if (!call.isConference) { let heldCalls = this._getCallsWithState(aClientId, nsITelephonyService.CALL_STATE_HELD); - // Automatic resume another held call. if (heldCalls.length) { - this._hangUpForeground(aClientId, aCallback); + if (call.state === nsITelephonyService.CALL_STATE_CONNECTED) { + // For a foreground call, ril has a request to do two actions together. + this._hangUpForeground(aClientId, aCallback); + } else { + // Otherwise, gecko should send out two consecutive requests by itself. + this._sendToRilWorker(aClientId, "hangUpCall", { callIndex: aCallIndex }, response => { + if (response.errorMsg) { + aCallback.notifyError(response.errorMsg); + } else { + aCallback.notifySuccess(); + + let emptyCallback = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsITelephonyCallback]), + notifySuccess: () => {}, + notifyError: () => {} + }; + + if (heldCalls.length === 1) { + this.resumeCall(aClientId, heldCalls[0].callIndex, emptyCallback); + } else { + this.resumeConference(aClientId, emptyCallback); + } + } + }); + } + return; } }