Skip to content

fix(android): disable AudioSwitch audio focus to fix stuck volume controls after call (WT-1429)#1237

Merged
SERDUN merged 2 commits intodevelopfrom
fix/wt-1429-audio-focus-stuck-after-call
Apr 30, 2026
Merged

fix(android): disable AudioSwitch audio focus to fix stuck volume controls after call (WT-1429)#1237
SERDUN merged 2 commits intodevelopfrom
fix/wt-1429-audio-focus-stuck-after-call

Conversation

@SERDUN
Copy link
Copy Markdown
Member

@SERDUN SERDUN commented Apr 30, 2026

Summary

  • Disables AudioSwitch (manageAudioFocus: false) so Telecom is the sole owner of Android audio focus during VoIP calls
  • Fixes volume buttons staying stuck in call mode after a call ends on older MIUI devices (Xiaomi Mi 9 Lite Android 10, Redmi Note 5 Android 9)
  • One-line change in CallMediaManager._configure() — no flutter-webrtc changes needed

Root cause

Two independent audio focus clients competed for AUDIOFOCUS_GAIN:

  1. Telecom (AudioFocus_For_Phone_Ring_And_Calls) — always correctly abandoned focus on call end
  2. AudioSwitch (com.cloudwebrtc.webrtc.audio.c) — requested permanent AUDIOFOCUS_GAIN on call start but did not always release it

When Telecom abandoned focus, Android dispatched AUDIOFOCUS_GAIN back to AudioSwitch, which held it permanently. Android kept MODE_IN_COMMUNICATION active, so volume buttons controlled call volume instead of media/ring volume. Only Force Stop (which triggers removeFocusStackEntryOnDeath) restored normal behaviour.

Setting manageAudioFocus: false prevents AudioSwitch from requesting focus at all. Telecom becomes the sole manager and reliably releases focus on every call end. Device routing (earpiece / speakerphone / bluetooth) and MODE_IN_COMMUNICATION are unaffected — AudioSwitch still handles them regardless of the focus flag.

Test plan

  • Make and end a call on Xiaomi Android 9–10 — volume buttons should control media/ring volume immediately after the call
  • Verify earpiece → speakerphone toggle works during a call
  • Verify Bluetooth headset routes correctly during a call
  • Verify no regression on Samsung / newer Android devices
  • Verify incoming call answer/reject audio routing is correct

SERDUN added 2 commits April 30, 2026 12:15
…trols after call

Telecom (callkeep) already manages audio focus for self-managed VoIP
calls. AudioSwitch holding a concurrent permanent AUDIOFOCUS_GAIN kept
Android in call audio mode after the call ended on older MIUI devices,
causing volume buttons to control call volume instead of media volume.

Disabling manageAudioFocus prevents AudioSwitch from requesting focus
while leaving device routing (earpiece/speaker/bluetooth) intact.

Fixes WT-1429
@WebTrit WebTrit deleted a comment from claude Bot Apr 30, 2026
@SERDUN SERDUN requested a review from digiboridev April 30, 2026 10:15
@SERDUN SERDUN marked this pull request as ready for review April 30, 2026 10:15
@SERDUN SERDUN merged commit 5162e5f into develop Apr 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants