fix(call): restore Bluetooth audio routing - #6567
Conversation
2a60dbe to
97bb606
Compare
|
Thank you for contributing @flake92 🙏 It would be great if the new java class could be converted to kotlin. Just let us know if you want to do this (that would be awesome!) or if we should take over. Claude AI review: Correctness (4 findings)
Efficiency/simplification/reuse (6 findings) — lower severity: exhausted retries keep re-triggering startScoAudio() harmlessly forever; the legacy vs. Android-12+ paths are interleaved via SDK-version branches across ~11 call sites instead of being split behind an interface (real maintenance risk going forward); some duplicated device-enumeration logic between WebRtcAudioManager and ModernBluetoothRoute; one dead code branch; one needless one-line wrapper. The two "removed behavior" concerns I'd have flagged up front — un-stickying Bluetooth selection on disconnect, and a possible SCO_DISCONNECTING race in requestBluetoothAudioSelection() — were investigated and ruled out: the first is the intentional point of the fix, the second self-heals within the 4s timeout. Given this is call-audio-routing code (hard to unit test end-to-end, easy to regress silently), I'd suggest at minimum fixing the first two correctness findings before merging, and manually testing the "switch away from Bluetooth mid-call" and "notification during a Bluetooth call" paths on a real device. |
|
Changes:
|
Prefer call-capable Bluetooth communication devices and preserve selection across reconnects. Assisted-by: Codex:gpt-5 Signed-off-by: Oleg Cherry <80347136+flake92@users.noreply.github.com>
Assisted-by: Codex:gpt-5 Signed-off-by: Oleg Cherry <80347136+flake92@users.noreply.github.com>
Keep the working route when a device switch is rejected, preserve bounded retry state across focus changes, reject stale callbacks, and share wired-device detection. Convert the new policy and tests to Kotlin. Assisted-by: Codex:gpt-5 Signed-off-by: flake92 <flake92@live.com>
98c2aba to
ef84967
Compare
|
Thank you @flake92 👍 As there are quite some changes here, this PR won't make it into v25.0.x (we are already in RC phase). |
Preserve the active route until a non-Bluetooth replacement is confirmed. Keep automatic retry limits across focus recovery, reject stale callbacks, and reconcile wired and USB devices consistently. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: flake92 <flake92@live.com>
|
@mahibi For now, I’m using my own custom builds because I make calls frequently, and this bug is especially frustrating in quiet public places, such as a cinema. With my changes, video calls now work perfectly. However, when starting an audio call, the ringback tone still briefly comes through the device speaker instead of the Bluetooth headset. I’ll continue working on that and get this PR back to green. I’m looking forward to seeing these changes included in a future release, but there’s no need for them to land specifically in v25.1—I’ll be happy to have them accepted for any later version. Thanks again! |
Extract modern Bluetooth focus recovery into a dedicated helper to keep the public dispatcher below the Codacy PMD NPath threshold without changing behavior. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: flake92 <flake92@live.com>
|
Changes: Added a Kotlin audio-route policy and Kotlin regression tests. Preserved the active Bluetooth route until a replacement output is successfully confirmed. Prevented route loss when switching from Bluetooth fails. Kept Bluetooth retry limits intact across audio-focus recovery. Added a safe non-Bluetooth fallback after retry exhaustion. Prevented stale getters and delayed callbacks from re-enabling Bluetooth. Improved modern and legacy Bluetooth recovery after transient audio-focus loss. Made wired headset and USB output detection consistent. Added device callbacks to handle wired/USB replacement correctly. Prevented automatic Bluetooth restarts during transient focus loss. Reset focus state correctly between calls. Added regression coverage for routing failures, retry exhaustion, stale callbacks, focus recovery, and wired/USB devices. Reduced PMD NPath complexity by extracting modern focus recovery into a dedicated helper. Backported the final result to Nextcloud Talk v24.0.4. Built and signed the update-compatible 24.0.4-privacy.3 GPlay APK. |
Prefer call-capable Bluetooth communication devices and preserve selection across reconnects.
Assisted-by: Codex:gpt-5
🖼️ Screenshots
🚧 TODO
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)