Bug 1013745 - Part 4: Refine dialling process and pending call mechanism. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-05-26 19:08:00 +02:00
Родитель f2fe96a740
Коммит ffa65aa310
2 изменённых файлов: 38 добавлений и 87 удалений

Просмотреть файл

@ -75,9 +75,6 @@ const MMI_MAX_LENGTH_SHORT_CODE = 2;
const MMI_END_OF_USSD = "#";
// Should match the value we set in dom/telephony/TelephonyCommon.h
const OUTGOING_PLACEHOLDER_CALL_INDEX = 0xffffffff;
let RILQUIRKS_CALLSTATE_EXTRA_UINT32;
// This may change at runtime since in RIL v6 and later, we get the version
// number via the UNSOLICITED_RIL_CONNECTED parcel.
@ -355,7 +352,7 @@ function RilObject(aContext) {
this.v5Legacy = RILQUIRKS_V5_LEGACY;
this.cellBroadcastDisabled = RIL_CELLBROADCAST_DISABLED;
this._hasHangUpPendingOutgoingCall = false;
this.pendingMO = null;
}
RilObject.prototype = {
context: null,
@ -541,9 +538,10 @@ RilObject.prototype = {
this.mergedCellBroadcastConfig = null;
/**
* True if the pending outgoing call is hung up by user.
* A successful dialing request.
* { options: options of the corresponding dialing request }
*/
this._hasHangUpPendingOutgoingCall = false;
this.pendingMO = null;
},
/**
@ -1645,11 +1643,6 @@ RilObject.prototype = {
},
sendRilRequestDial: function(options) {
// Always succeed.
options.success = true;
this.sendChromeMessage(options);
this._createPendingOutgoingCall(options);
let Buf = this.context.Buf;
Buf.newParcel(options.request, options);
Buf.writeString(options.number);
@ -1691,20 +1684,11 @@ RilObject.prototype = {
return;
}
let callIndex = call.callIndex;
if (callIndex === OUTGOING_PLACEHOLDER_CALL_INDEX) {
if (DEBUG) this.context.debug("Hang up pending outgoing call.");
this._hasHangUpPendingOutgoingCall = true;
this._removeVoiceCall(call, GECKO_CALL_ERROR_NORMAL_CALL_CLEARING);
return;
}
call.hangUpLocal = true;
if (call.state === CALL_STATE_HOLDING) {
this.sendHangUpBackgroundRequest();
} else {
this.sendHangUpRequest(callIndex);
this.sendHangUpRequest(call.callIndex);
}
},
@ -3937,17 +3921,11 @@ RilObject.prototype = {
_processCalls: function(newCalls) {
let conferenceChanged = false;
let clearConferenceRequest = false;
let pendingOutgoingCall = null;
// Go through the calls we currently have on file and see if any of them
// changed state. Remove them from the newCalls map as we deal with them
// so that only new calls remain in the map after we're done.
for each (let currentCall in this.currentCalls) {
if (currentCall.callIndex == OUTGOING_PLACEHOLDER_CALL_INDEX) {
pendingOutgoingCall = currentCall;
continue;
}
let newCall;
if (newCalls) {
newCall = newCalls[currentCall.callIndex];
@ -4051,14 +4029,30 @@ RilObject.prototype = {
}
}
if (pendingOutgoingCall) {
if (!newCalls || Object.keys(newCalls).length === 0) {
// We don't get a successful call for pendingOutgoingCall.
this._removePendingOutgoingCall(GECKO_CALL_ERROR_UNSPECIFIED);
// We have a successful dialing request. Check whether we could find a new
// call for it.
if (this.pendingMO) {
let options = this.pendingMO.options;
this.pendingMO = null;
// Find the callIndex of the new outgoing call.
let callIndex = -1;
for (let i in newCalls) {
if (newCalls[i].state !== CALL_STATE_INCOMING) {
callIndex = newCalls[i].callIndex;
break;
}
}
if (callIndex === -1) {
// The call doesn't exist.
options.success = false;
options.errorMsg = GECKO_CALL_ERROR_UNSPECIFIED;
this.sendChromeMessage(options);
} else {
// Only remove it from currentCalls map. Will use the new call to
// replace the placeholder.
delete this.currentCalls[OUTGOING_PLACEHOLDER_CALL_INDEX];
options.success = true;
options.callIndex = callIndex;
this.sendChromeMessage(options);
}
}
@ -4072,20 +4066,9 @@ RilObject.prototype = {
conferenceChanged = true;
}
if (this._hasHangUpPendingOutgoingCall &&
(newCall.state === CALL_STATE_DIALING ||
newCall.state === CALL_STATE_ALERTING)) {
// Receive a new outgoing call which is already hung up by user.
if (DEBUG) this.context.debug("Pending outgoing call is hung up by user.");
this._hasHangUpPendingOutgoingCall = false;
this.sendHangUpRequest(newCall.callIndex);
} else {
this._addNewVoiceCall(newCall);
}
this._addNewVoiceCall(newCall);
}
this._hasHangUpPendingOutgoingCall = false;
if (clearConferenceRequest) {
this._hasConferenceRequest = false;
}
@ -4145,25 +4128,6 @@ RilObject.prototype = {
}
},
_createPendingOutgoingCall: function(options) {
if (DEBUG) this.context.debug("Create a pending outgoing call.");
this._addNewVoiceCall({
number: options.number,
state: CALL_STATE_DIALING,
callIndex: OUTGOING_PLACEHOLDER_CALL_INDEX
});
},
_removePendingOutgoingCall: function(failCause) {
let call = this.currentCalls[OUTGOING_PLACEHOLDER_CALL_INDEX];
if (!call) {
return;
}
if (DEBUG) this.context.debug("Remove pending outgoing call.");
this._removeVoiceCall(call, failCause);
},
_ensureConference: function() {
let oldState = this.currentConference.state;
let remaining = Object.keys(this.currentConference.participants);
@ -5556,12 +5520,14 @@ RilObject.prototype[REQUEST_GET_CURRENT_CALLS] = function REQUEST_GET_CURRENT_CA
this._processCalls(calls);
};
RilObject.prototype[REQUEST_DIAL] = function REQUEST_DIAL(length, options) {
// We already return a successful response before. Don't respond it again!
if (options.rilRequestError) {
this.getFailCauseCode((function(failCause) {
this._removePendingOutgoingCall(failCause);
this._hasHangUpPendingOutgoingCall = false;
}).bind(this));
if (options.rilRequestError === 0) {
this.pendingMO = {options: options};
} else {
this.getFailCauseCode((function(options, failCause) {
options.success = false;
options.errorMsg = failCause;
this.sendChromeMessage(options);
}).bind(this, options));
}
};
RilObject.prototype[REQUEST_DIAL_EMERGENCY_CALL] = function REQUEST_DIAL_EMERGENCY_CALL(length, options) {

Просмотреть файл

@ -38,9 +38,6 @@ const CDMA_SECOND_CALL_INDEX = 2;
const DIAL_ERROR_INVALID_STATE_ERROR = "InvalidStateError";
const DIAL_ERROR_OTHER_CONNECTION_IN_USE = "OtherConnectionInUse";
// Should match the value we set in dom/telephony/TelephonyCommon.h
const OUTGOING_PLACEHOLDER_CALL_INDEX = 0xffffffff;
let DEBUG;
function debug(s) {
dump("TelephonyProvider: " + s + "\n");
@ -267,11 +264,6 @@ TelephonyProvider.prototype = {
},
_updateCallAudioState: function(aCall) {
// Ignore audio state setting if the call is a placeholder.
if (aCall && aCall.callIndex === OUTGOING_PLACEHOLDER_CALL_INDEX) {
return;
}
let active = (this._activeCall !== null);
let incoming = (aCall &&
aCall.state === nsITelephonyProvider.CALL_STATE_INCOMING);
@ -538,7 +530,7 @@ TelephonyProvider.prototype = {
if (response.isCdma) {
onCdmaDialSuccess.call(this);
} else {
aTelephonyCallback.notifyDialSuccess();
aTelephonyCallback.notifyDialSuccess(response.callIndex);
}
return false;
}).bind(this));
@ -848,13 +840,6 @@ TelephonyProvider.prototype = {
call.isMergeable = aCall.isMergeable != null ?
aCall.isMergeable : true;
// Get the actual call for pending outgoing call. Remove the original one.
if (this._currentCalls[aClientId][OUTGOING_PLACEHOLDER_CALL_INDEX] &&
call.callIndex != OUTGOING_PLACEHOLDER_CALL_INDEX &&
call.isOutgoing) {
delete this._currentCalls[aClientId][OUTGOING_PLACEHOLDER_CALL_INDEX];
}
this._currentCalls[aClientId][aCall.callIndex] = call;
}