Bug 816101 - Send a system message when a call is complete. r=hsinyi

This commit is contained in:
Dale Harvey 2012-12-18 14:54:18 +01:00
parent 93962b8c5e
commit 3a7959bd4a
3 changed files with 19 additions and 0 deletions

View File

@ -79,6 +79,9 @@ this.SystemMessagePermissionsTable = {
"telephony-new-call": {
"telephony": []
},
"telephony-call-ended": {
"telephony": []
},
"ussd-received": {
"mobileconnection": []
}

View File

@ -1242,6 +1242,14 @@ RadioInterfaceLayer.prototype = {
handleCallDisconnected: function handleCallDisconnected(call) {
debug("handleCallDisconnected: " + JSON.stringify(call));
call.state = nsIRadioInterfaceLayer.CALL_STATE_DISCONNECTED;
let duration = ("started" in call && typeof call.started == "number") ?
new Date().getTime() - call.started : 0;
let data = {
number: call.number,
duration: duration,
direction: call.direction
};
gSystemMessenger.broadcastMessage("telephony-call-ended", data);
this.updateCallAudioState(call);
this._sendTargetMessage("telephony", "RIL:CallStateChanged", call);
},

View File

@ -4302,6 +4302,9 @@ let RIL = {
// Call is still valid.
if (newCall.state != currentCall.state) {
// State has changed.
if (!currentCall.started && newCall.state == CALL_STATE_ACTIVE) {
currentCall.started = new Date().getTime();
}
currentCall.state = newCall.state;
this._handleChangedCallState(currentCall);
}
@ -4322,6 +4325,11 @@ let RIL = {
newCall.number[0] != "+") {
newCall.number = "+" + newCall.number;
}
if (newCall.state == CALL_STATE_INCOMING) {
newCall.direction = 'incoming';
} else if (newCall.state == CALL_STATE_DIALING) {
newCall.direction = 'outgoing';
}
// Add to our map.
this.currentCalls[newCall.callIndex] = newCall;
this._handleChangedCallState(newCall);