Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/android-audio-mode-without-focus
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="fixed" "Android: the audio mode is set when manageAudioFocus is false, so calls keep the communication mode without taking audio focus. Apps that pass manageAudioFocus: false without an audioMode now get the default inCommunication mode."
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal class LKAudioSwitchManager(private val context: Context) {
if (isActive && sessionConfigChanged) {
switch.deactivate()
switch.activate()
setModeWithoutFocus(sessionConfig)
applySpeakerRouting(switch, speakerRouting)
}
}
Expand Down Expand Up @@ -119,6 +120,7 @@ internal class LKAudioSwitchManager(private val context: Context) {
val switch = audioSwitch ?: createSwitch(sessionConfig, speakerRouting).also { audioSwitch = it }
if (!isActive) {
switch.activate()
setModeWithoutFocus(sessionConfig)
applySpeakerRouting(switch, speakerRouting)
isActive = true
}
Expand Down Expand Up @@ -184,6 +186,16 @@ internal class LKAudioSwitchManager(private val context: Context) {
return switch
}

// audioswitch sets the audio mode only as it takes audio focus, so a session without focus
// would stay in MODE_NORMAL, without the call mode that echo cancelling and routing need. Set
// it here instead; deactivate() still restores the mode activate() saved.
private fun setModeWithoutFocus(sessionConfig: SessionConfig) {
if (!sessionConfig.manageAudioFocus) {
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.mode = sessionConfig.audioMode
}
}

private fun applyConfiguration(switch: AbstractAudioSwitch, sessionConfig: SessionConfig) {
switch.manageAudioFocus = sessionConfig.manageAudioFocus
switch.audioMode = sessionConfig.audioMode
Expand Down
Loading