mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1077190 - Part 1: Correct the logic of audio state setting. r=hsinyi
This commit is contained in:
parent
2c01c6432c
commit
000d20852a
@ -1972,6 +1972,9 @@ RadioInterface.prototype = {
|
||||
handleUnsolicitedWorkerMessage: function(message) {
|
||||
let connHandler = gDataConnectionManager.getConnectionHandler(this.clientId);
|
||||
switch (message.rilMessageType) {
|
||||
case "audioStateChanged":
|
||||
gTelephonyService.notifyAudioStateChanged(this.clientId, message.state);
|
||||
break;
|
||||
case "callRing":
|
||||
gTelephonyService.notifyCallRing();
|
||||
break;
|
||||
|
@ -470,6 +470,11 @@ this.CELL_INFO_TYPE_CDMA = 2;
|
||||
this.CELL_INFO_TYPE_LTE = 3;
|
||||
this.CELL_INFO_TYPE_WCDMA = 4;
|
||||
|
||||
// Order matters.
|
||||
this.AUDIO_STATE_NO_CALL = 0;
|
||||
this.AUDIO_STATE_INCOMING = 1;
|
||||
this.AUDIO_STATE_IN_CALL = 2;
|
||||
|
||||
this.CALL_STATE_UNKNOWN = -1;
|
||||
this.CALL_STATE_ACTIVE = 0;
|
||||
this.CALL_STATE_HOLDING = 1;
|
||||
|
@ -3993,6 +3993,26 @@ RilObject.prototype = {
|
||||
if (conferenceChanged) {
|
||||
this._ensureConference();
|
||||
}
|
||||
|
||||
// Update audio state.
|
||||
let message = {rilMessageType: "audioStateChanged",
|
||||
state: this._detectAudioState()};
|
||||
this.sendChromeMessage(message);
|
||||
},
|
||||
|
||||
_detectAudioState: function() {
|
||||
let callNum = Object.keys(this.currentCalls).length;
|
||||
if (!callNum) {
|
||||
return AUDIO_STATE_NO_CALL;
|
||||
}
|
||||
|
||||
let firstIndex = Object.keys(this.currentCalls)[0];
|
||||
if (callNum == 1 &&
|
||||
this.currentCalls[firstIndex].state == CALL_STATE_INCOMING) {
|
||||
return AUDIO_STATE_INCOMING;
|
||||
}
|
||||
|
||||
return AUDIO_STATE_IN_CALL;
|
||||
},
|
||||
|
||||
_addNewVoiceCall: function(newCall) {
|
||||
|
@ -43,9 +43,6 @@ const DIAL_ERROR_INVALID_STATE_ERROR = "InvalidStateError";
|
||||
const DIAL_ERROR_OTHER_CONNECTION_IN_USE = "OtherConnectionInUse";
|
||||
const DIAL_ERROR_BAD_NUMBER = RIL.GECKO_CALL_ERROR_BAD_NUMBER;
|
||||
|
||||
const AUDIO_STATE_NO_CALL = 0;
|
||||
const AUDIO_STATE_INCOMING = 1;
|
||||
const AUDIO_STATE_IN_CALL = 2;
|
||||
const AUDIO_STATE_NAME = [
|
||||
"PHONE_STATE_NORMAL",
|
||||
"PHONE_STATE_RINGTONE",
|
||||
@ -156,6 +153,7 @@ function TelephonyService() {
|
||||
this._isDialing = false;
|
||||
this._cachedDialRequest = null;
|
||||
this._currentCalls = {};
|
||||
this._audioStates = {};
|
||||
|
||||
this._cdmaCallWaitingNumber = null;
|
||||
|
||||
@ -174,6 +172,7 @@ function TelephonyService() {
|
||||
for (let i = 0; i < this._numClients; ++i) {
|
||||
this._enumerateCallsForClient(i);
|
||||
this._isActiveCall[i] = {};
|
||||
this._audioStates[i] = RIL.AUDIO_STATE_NO_CALL;
|
||||
}
|
||||
}
|
||||
TelephonyService.prototype = {
|
||||
@ -277,28 +276,19 @@ TelephonyService.prototype = {
|
||||
this._numActiveCall--;
|
||||
}
|
||||
this._isActiveCall[aCall.clientId][aCall.callIndex] = active;
|
||||
|
||||
if (incoming && !this._numActiveCall) {
|
||||
// Change the phone state into RINGTONE only when there's no active call.
|
||||
this._updateCallAudioState(AUDIO_STATE_INCOMING);
|
||||
} else if (this._numActiveCall) {
|
||||
this._updateCallAudioState(AUDIO_STATE_IN_CALL);
|
||||
} else {
|
||||
this._updateCallAudioState(AUDIO_STATE_NO_CALL);
|
||||
}
|
||||
},
|
||||
|
||||
_updateCallAudioState: function(aAudioState) {
|
||||
_updateAudioState: function(aAudioState) {
|
||||
switch (aAudioState) {
|
||||
case AUDIO_STATE_NO_CALL:
|
||||
case RIL.AUDIO_STATE_NO_CALL:
|
||||
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
|
||||
break;
|
||||
|
||||
case AUDIO_STATE_INCOMING:
|
||||
case RIL.AUDIO_STATE_INCOMING:
|
||||
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_RINGTONE;
|
||||
break;
|
||||
|
||||
case AUDIO_STATE_IN_CALL:
|
||||
case RIL.AUDIO_STATE_IN_CALL:
|
||||
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_IN_CALL;
|
||||
if (this.speakerEnabled) {
|
||||
gAudioManager.setForceForUse(nsIAudioManager.USE_COMMUNICATION,
|
||||
@ -309,7 +299,7 @@ TelephonyService.prototype = {
|
||||
|
||||
if (DEBUG) {
|
||||
debug("Put audio system into " + AUDIO_STATE_NAME[aAudioState] + ": " +
|
||||
gAudioManager.phoneState);
|
||||
aAudioState + ", result is: " + gAudioManager.phoneState);
|
||||
}
|
||||
},
|
||||
|
||||
@ -1097,6 +1087,17 @@ TelephonyService.prototype = {
|
||||
* nsIGonkTelephonyService interface.
|
||||
*/
|
||||
|
||||
notifyAudioStateChanged: function(aClientId, aState) {
|
||||
this._audioStates[aClientId] = aState;
|
||||
|
||||
let audioState = aState;
|
||||
for (let i = 0; i < this._numClients; ++i) {
|
||||
audioState = Math.max(audioState, this._audioStates[i]);
|
||||
}
|
||||
|
||||
this._updateAudioState(audioState);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle call disconnects by updating our current state and the audio system.
|
||||
*/
|
||||
|
@ -10,9 +10,11 @@
|
||||
"@mozilla.org/telephony/gonktelephonyservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(79eec3c3-2dfc-4bbf-b106-af5457651ae0)]
|
||||
[scriptable, uuid(068d7bf2-1773-48ef-95f8-bd835115fed7)]
|
||||
interface nsIGonkTelephonyService : nsITelephonyService
|
||||
{
|
||||
void notifyAudioStateChanged(in unsigned long clientId, in short state);
|
||||
|
||||
void notifyCallDisconnected(in unsigned long clientId, in jsval call);
|
||||
|
||||
void notifyCallRing();
|
||||
|
Loading…
Reference in New Issue
Block a user