Bug 1021550 - Removed the check to set the PHONE_STATE_NORMAL for speaker/mic when there are no active calls. Added test. r=hsinyi.

This commit is contained in:
Tamara Hills 2014-07-08 11:02:51 +08:00
parent c49880a819
commit b06f3ef347
4 changed files with 68 additions and 13 deletions

View File

@ -693,10 +693,6 @@ TelephonyService.prototype = {
return;
}
gAudioManager.microphoneMuted = aMuted;
if (!this._numActiveCall) {
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
}
},
get speakerEnabled() {
@ -711,10 +707,6 @@ TelephonyService.prototype = {
let force = aEnabled ? nsIAudioManager.FORCE_SPEAKER :
nsIAudioManager.FORCE_NONE;
gAudioManager.setForceForUse(nsIAudioManager.USE_COMMUNICATION, force);
if (!this._numActiveCall) {
gAudioManager.phoneState = nsIAudioManager.PHONE_STATE_NORMAL;
}
},
/**

View File

@ -58,3 +58,4 @@ disabled = Bug 821958
[test_conference_three_remove_one.js]
[test_outgoing_when_two_calls_on_line.js]
[test_call_presentation.js]
[test_incomingcall_phonestate_speaker.js]

View File

@ -60,11 +60,7 @@ startTest(function() {
// Dial in
.then(() => gRemoteDial(inNumber))
.then(call => { inCall = call; })
// TODO - Bug 948860: should this be {RINGTONE, RINGTONE, RINGTONE}?
// From current UX spec, there is no chance that an user may enable speaker
// during alerting, so basically this 'set speaker enable' action can't
// happen in B2G.
.then(() => check(PHONE_STATE_RINGTONE, PHONE_STATE_NORMAL, PHONE_STATE_NORMAL))
.then(() => check(PHONE_STATE_RINGTONE, PHONE_STATE_RINGTONE, PHONE_STATE_RINGTONE))
.then(() => gAnswer(inCall))
.then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
// Hang up all

View File

@ -0,0 +1,66 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const AUDIO_MANAGER_CONTRACT_ID = "@mozilla.org/telephony/audiomanager;1";
// See nsIAudioManager
const PHONE_STATE_INVALID = -2;
const PHONE_STATE_CURRENT = -1;
const PHONE_STATE_NORMAL = 0;
const PHONE_STATE_RINGTONE = 1;
const PHONE_STATE_IN_CALL = 2;
const PHONE_STATE_IN_COMMUNICATION = 3;
let audioManager;
function checkSpeakerEnabled(phoneStatePrev, phoneStateNew, toggle, setSpeaker) {
if (!audioManager) {
audioManager = SpecialPowers.Cc[AUDIO_MANAGER_CONTRACT_ID]
.getService(SpecialPowers.Ci.nsIAudioManager);
ok(audioManager, "nsIAudioManager instance");
}
is(audioManager.phoneState, phoneStatePrev, "audioManager.phoneState");
if (toggle) {
telephony.speakerEnabled = setSpeaker;
}
is(audioManager.phoneState, phoneStateNew, "audioManager.phoneState");
}
// Start the test
startTest(function() {
let inNumber = "5555550201";
let inCall;
Promise.resolve()
.then(() => checkSpeakerEnabled(PHONE_STATE_NORMAL, PHONE_STATE_NORMAL, false, false))
// Dial in
.then(() => gRemoteDial(inNumber))
.then(call => { inCall = call; })
.then(() => checkSpeakerEnabled(PHONE_STATE_RINGTONE, PHONE_STATE_RINGTONE, false, false))
.then(() => gAnswer(inCall))
.then(() => checkSpeakerEnabled(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL, false, false))
// Go on Speaker (Don't go off speaker before hanging up. This is to check
// the condition for bug 1021550)
.then(() => checkSpeakerEnabled(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL, true, true))
// Hang up all
.then(() => gRemoteHangUp(inCall))
.then(() => checkSpeakerEnabled(PHONE_STATE_NORMAL, PHONE_STATE_NORMAL, false, false))
// Make a second inbound call
.then(() => gRemoteDial(inNumber))
.then(call => { inCall = call; })
.then(() => checkSpeakerEnabled(PHONE_STATE_RINGTONE, PHONE_STATE_RINGTONE, false, false))
.then(() => gAnswer(inCall))
.then(() => checkSpeakerEnabled(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL, false, false))
// Hang up the call
.then(() => gRemoteHangUp(inCall))
.then(() => checkSpeakerEnabled(PHONE_STATE_NORMAL, PHONE_STATE_NORMAL, false, false))
// End
.then(null, error => {
ok(false, 'promise rejects during test.');
})
.then(finish);
});