Fix disconnect sound on call termination.

This commit is contained in:
Cody Henthorne 2022-03-16 10:08:06 -04:00
parent c7016aa462
commit 5b5b118b7a

View file

@ -413,6 +413,8 @@ class TelecomAwareSignalAudioManager(context: Context, eventListener: EventListe
if (!focusedGained) {
handler.postDelayed({ androidAudioManager.requestCallAudioFocus() }, 500)
}
state = State.PREINITIALIZED
}
override fun start() {
@ -423,11 +425,21 @@ class TelecomAwareSignalAudioManager(context: Context, eventListener: EventListe
if (!focusedGained) {
handler.postDelayed({ androidAudioManager.requestCallAudioFocus() }, 500)
}
state = State.RUNNING
}
override fun stop(playDisconnect: Boolean) {
incomingRinger.stop()
outgoingRinger.stop()
if (playDisconnect && state != State.UNINITIALIZED) {
val volume: Float = androidAudioManager.ringVolumeWithMinimum()
soundPool.play(disconnectedSoundId, volume, volume, 0, 0, 1.0f)
}
state = State.UNINITIALIZED
androidAudioManager.abandonCallAudioFocus()
}