Fix AudioManager mode.

It shall be set to MODE_RINGTONE when playing the local ring, and MODE_IN_COMMUNICATION in Connected state.
Before this commit MODE_IN_COMMUNICATION was only set for outgoing calls, not incoming, which is bad.
This commit is contained in:
Simon Morlat 2017-02-02 21:23:43 +01:00
parent 43fdbed648
commit e45e8b8229

View file

@ -1204,6 +1204,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
if (state == State.Connected) {
if (mLc.getCallsNb() == 1) {
//It is for incoming calls, because outgoing calls enter MODE_IN_COMMUNICATION immediately when they start.
//However, incoming call first use the MODE_RINGING to play the local ring.
setAudioManagerInCallMode();
mAudioManager.abandonAudioFocus(null);
requestAudioFocus(STREAM_VOICE_CALL);
}
@ -1214,10 +1217,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
}
}
if (state == State.OutgoingEarlyMedia) {
setAudioManagerInCallMode();
}
if (state == State.CallEnd || state == State.Error) {
if (mLc.getCallsNb() == 0) {
Context activity = getContext();
@ -1257,6 +1256,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
}
}
if (state == State.OutgoingInit) {
//Enter the MODE_IN_COMMUNICATION mode as soon as possible, so that ringback
//is heard normally in earpiece or bluetooth receiver.
setAudioManagerInCallMode();
requestAudioFocus(STREAM_VOICE_CALL);
startBluetooth();
@ -1375,8 +1376,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
routeAudioToSpeaker(); // Need to be able to ear the ringtone during the early media
}
if (Hacks.needGalaxySAudioHack())
mAudioManager.setMode(MODE_RINGTONE);
//if (Hacks.needGalaxySAudioHack())
mAudioManager.setMode(MODE_RINGTONE);
try {
if ((mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE || mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) && mVibrator != null) {