I’m trying to keep Bluetooth SCO mode on for longer than 6 sec. time, for recording audio from it and playing some sounds in same time, anytime. It’s not a call, it’s just local communication (“hands free”) for recording quite short messages with audio feedback when time-limit or smth happens in background during recording. Feature must work immediate and I see on variety of devices that switching between default A2DP and SCO takes 1-few secs – thats unacceptable for my case
Starting Android 12/API 31 there is a new setCommunicationDevice
method, I can find in availableCommunicationDevices
proper device with type=AudioDeviceInfo.TYPE_BLUETOOTH_SCO
, set it, get true
as result (so request sent), but no callback onCommunicationDeviceChanged
ever, no effect at all… Audio still recorded and played out loud from Android device. And fun fact: old isBluetoothScoOn
method returns true
…
This (really) works when I’m changing mode to MODE_IN_COMMUNICATION
and setting up a call through Telecom manager
, using then also CallAudioState.ROUTE_BLUETOOTH
for routing. But above feature isn’t a call, I’m not sure if I even should set MODE_IN_COMMUNICATION
then, for sure not setting up a call… Looks like MODE_IN_COMMUNICATION
is now mandatory for keeping SCO on, but additionaly audio record must be started (or played) in 6 sec., if not then Android will auto-switch mode to MODE_NORMAL
… I want to keep “SCO-mode” as long as possible, ready for record/play any time, even after minutes or hours of “idle state”