Bug 1124550 - Part 10: Refactoring holdCall, resumeCall. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2015-02-03 12:18:20 +08:00
parent 8f5ece4e0e
commit 3c6c9280ea
2 changed files with 30 additions and 42 deletions

View File

@ -1885,42 +1885,6 @@ RilObject.prototype = {
}
},
holdCall: function(options) {
let call = this.currentCalls[options.callIndex];
if (!call) {
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
options.success = false;
this.sendChromeMessage(options);
return;
}
let Buf = this.context.Buf;
if (this._isCdma) {
options.featureStr = "";
this.cdmaFlash(options);
} else if (call.state == CALL_STATE_ACTIVE) {
this.switchActiveCall(options);
}
},
resumeCall: function(options) {
let call = this.currentCalls[options.callIndex];
if (!call) {
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
options.success = false;
this.sendChromeMessage(options);
return;
}
let Buf = this.context.Buf;
if (this._isCdma) {
options.featureStr = "";
this.cdmaFlash(options);
} else if (call.state == CALL_STATE_HOLDING) {
this.switchActiveCall(options);
}
},
conferenceCall: function(options) {
this.telephonyRequestQueue.push(REQUEST_CONFERENCE, () => {
this.context.Buf.simpleRequest(REQUEST_CONFERENCE, options);

View File

@ -877,28 +877,52 @@ TelephonyService.prototype = {
this._defaultCallbackHandler.bind(this, aCallback));
},
holdCall: function(aClientId, aCallIndex, aCallback) {
_switchCall: function(aClientId, aCallIndex, aCallback, aRequiredState) {
let call = this._currentCalls[aClientId][aCallIndex];
if (!call || !call.isSwitchable) {
if (!call) {
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
return;
}
this._sendToRilWorker(aClientId, "holdCall", { callIndex: aCallIndex },
if (this._isCdmaClient(aClientId)) {
this._switchCallCdma(aClientId, aCallIndex, aCallback);
} else {
this._switchCallGsm(aClientId, aCallIndex, aCallback, aRequiredState);
}
},
_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._sendToRilWorker(aClientId, "switchActiveCall", null,
this._defaultCallbackHandler.bind(this, aCallback));
},
resumeCall: function(aClientId, aCallIndex, aCallback) {
_switchCallCdma: function(aClientId, aCallIndex, aCallback) {
let call = this._currentCalls[aClientId][aCallIndex];
if (!call || !call.isSwitchable) {
if (!call.isSwitchable) {
aCallback.notifyError(RIL.GECKO_ERROR_GENERIC_FAILURE);
return;
}
this._sendToRilWorker(aClientId, "resumeCall", { callIndex: aCallIndex },
this._sendToRilWorker(aClientId, "cdmaFlash", null,
this._defaultCallbackHandler.bind(this, aCallback));
},
holdCall: function(aClientId, aCallIndex, aCallback) {
this._switchCall(aClientId, aCallIndex, aCallback,
nsITelephonyService.CALL_STATE_CONNECTED);
},
resumeCall: function(aClientId, aCallIndex, aCallback) {
this._switchCall(aClientId, aCallIndex, aCallback,
nsITelephonyService.CALL_STATE_HELD);
},
_conferenceCallGsm: function(aClientId, aCallback) {
this._sendToRilWorker(aClientId, "conferenceCall", null, response => {
if (!response.success) {