fix(audio): clear BT SCO communication device on call end

Without clearCommunicationDevice(), the BT headset stays locked in SCO
mode after the call. Media playback (video, music) can't route to BT
A2DP, requiring a device reboot to restore normal audio.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-12 17:40:44 +04:00
parent 300ea66d13
commit 24cc74d93c

View File

@@ -1500,9 +1500,14 @@ impl CallEngine {
#[cfg(target_os = "android")]
{
crate::wzp_native::audio_stop();
// Restore MODE_NORMAL so other apps' audio (music, etc.)
// routes normally again. Without this, the system stays in
// communication mode and BT A2DP music goes to earpiece.
// Release the BT SCO communication device so Android can
// route media (video, music) back to BT A2DP. Without this,
// setCommunicationDevice locks BT to SCO mode and other apps
// can't use the headset for media playback until reboot.
if let Err(e) = crate::android_audio::stop_bluetooth_sco() {
tracing::warn!("stop_bluetooth_sco on call end failed: {e}");
}
// Restore MODE_NORMAL so other apps' audio routes normally.
if let Err(e) = crate::android_audio::set_audio_mode_normal() {
tracing::warn!("set_audio_mode_normal failed: {e}");
}