Description
The Bluetooth icon is not showing but the audio is routing via Bluetooth.
BT- Bluetooth
- Bluetooth is ON and connected> Incoming call is received and user is landed on the ongoing call screen
- Audio is coming via Bluetooth but Bluetooth icon is not showing on the ongoing call screen instead phone icon is showing.
- If you tap on the phone icon, audio switch options are only phone and speaker.
To Reproduce
Steps to reproduce the behavior:
- BT is connected and receives the call
- Click on the accept button
- Voice is routing via BT and it's working fine also you can change the mode from BT to Speaker or Phone.
- Disconnect BT from the notification drawer and reconnect again and working fine.
- Disconnect the call.
- BT is connected, again receives the incoming call, and clicks on the accept button
- User can hear the voice through BT but the Devices list shows [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)] only
Expected behavior
BT options should be there in the device list.
Actual behavior
The voice is transmitted through Bluetooth, but Bluetooth does not appear in the device list, preventing us from displaying the Bluetooth option in the UI.
Application Logs Steps wise
Step1 to 5
- 15:03:19.267 D AudioSwitch(1.2.0)
15:03:19.267 D Preferred device list = [BluetoothHeadset, WiredHeadset, Earpiece, Speakerphone]
15:03:19.276 D Earpiece available
15:03:19.276 D Speakerphone available
15:03:19.277 D Available AudioDevice list updated: [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:03:19.277 D Current user selected AudioDevice = null
15:03:19.304 D Bluetooth Jabra Elite 4 connected
15:03:19.309 D Device size 1 with device name: Jabra Elite 4
15:03:19.309 D Earpiece available
15:03:19.309 D Speakerphone available
15:03:19.309 D Available AudioDevice list updated: [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:03:19.309 D Current user selected AudioDevice = null
15:03:19.309 D Bluetooth SCO connected
15:03:22.133 W Cannot deactivate when in the Disconnected state
Step 6 : Disconnect BT
- 15:00:04.001 D Bluetooth disconnected
15:00:04.001 D Headset state changed to Disconnected
15:00:04.001 D Earpiece available
15:00:04.908 D Speakerphone available
15:00:04.908 D Available AudioDevice list updated: [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:00:04.908 D Current user selected AudioDevice = null
15:00:04.930 W Cannot deactivate when in the Disconnected state
15:00:04.942 D Bluetooth SCO disconnected
Step 6: Reconnect BT: Working fine
-
15:00:33.896 D Bluetooth SCO disconnected
15:00:34.077 D Bluetooth headset BluetoothDeviceWrapperImpl(device=XX:XX:XX:XX:54:B4, name=Jabra Elite 4, deviceClass=7936) connected
15:00:34.080 D Headset state changed to Connected
15:00:34.080 D Earpiece available
15:00:34.418 D Speakerphone available
15:00:34.419 D Available AudioDevice list updated: [BluetoothHeadset(name=Jabra Elite 4), Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:00:34.419 D Current user selected AudioDevice = null
15:00:34.426 D Scheduled bluetooth sco job
15:00:34.429 D Bluetooth SCO disconnected
15:00:34.432 D Attempting to enable bluetooth SCO
15:00:34.432 D Headset state changed to AudioActivating
15:00:34.482 D Bluetooth SCO connecting
15:00:34.580 D Bluetooth audio connected on device BluetoothDeviceWrapperImpl(device=XX:XX:XX:XX:54:B4, name=Jabra Elite 4, deviceClass=7936)
15:00:34.580 D Canceled bluetooth sco job
15:00:34.580 D Headset state changed to AudioActivated
15:00:34.580 D Earpiece available
15:00:34.598 D Speakerphone available
15:00:34.598 D Available AudioDevice list updated: [BluetoothHeadset(name=Jabra Elite 4), Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:00:34.598 D Current user selected AudioDevice = null
15:00:34.745 W Cannot activate when in the AudioActivated state
15:00:34.746 D Bluetooth SCO disconnected
15:00:35.624 D Bluetooth SCO connected
Step 7: Disconnect the call -
15:02:01.251 D AudioSwitch(1.2.0)
15:02:01.252 D Preferred device list = [BluetoothHeadset, WiredHeadset, Earpiece, Speakerphone]
15:02:01.289 D Redundant stop() invocation while already in the stopped state
Step 8: When receiving incoming calls and clicking the accept button, the audio comes through Bluetooth, but the Bluetooth option is not available in the UI:
- 15:03:19.267 D AudioSwitch(1.2.0)
15:03:19.267 D Preferred device list = [BluetoothHeadset, WiredHeadset, Earpiece, Speakerphone]
15:03:19.276 D Earpiece available
15:03:19.276 D Speakerphone available
15:03:19.277 D Available AudioDevice list updated: [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:03:19.277 D Current user selected AudioDevice = null
15:03:19.304 D Bluetooth Jabra Elite 4 connected
15:03:19.309 D Device size 1 with device name: Jabra Elite 4
15:03:19.309 D Earpiece available
15:03:19.309 D Speakerphone available
15:03:19.309 D Available AudioDevice list updated: [Earpiece(name=Earpiece), Speakerphone(name=Speakerphone)]
15:03:19.309 D Current user selected AudioDevice = null
15:03:19.309 D Bluetooth SCO connected
15:03:22.133 W Cannot deactivate when in the Disconnected state
Sometimes Logcat observation:
- 15:00:58.065 D Scheduled bluetooth sco job
15:00:58.073 D Bluetooth disconnected
15:00:58.073 D Headset state changed to Disconnected
15:00:58.094 D Attempting to disable bluetooth SCO
15:00:58.103 D Headset state changed to Connected
15:00:58.746 D Attempting to disa 695D ble bluetooth SCO
15:00:59.250 D Attempting to disable bluetooth SCO
15:00:59.759 D Attempting to disable bluetooth SCO
15:01:00.269 D Attempting to disable bluetooth SCO
15:01:00.777 D Attempting to disable bluetooth SCO
15:01:01.287 D Attempting to disable bluetooth SCO
15:01:01.794 D Attempting to disable bluetooth SCO
15:01:02.304 D Attempting to disable bluetooth SCO
15:01:02.812 D Attempting to disable bluetooth SCO
15:01:03.319 D Attempting to disable bluetooth SCO
15:01:03.832 E Bluetooth sco job timed out
java.util.concurrent.TimeoutException
at com.twilio.audioswitch.bluetooth.BluetoothScoJob$BluetoothScoRunnable.run(BluetoothScoJob.kt:55)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
15:01:03.832 D Headset state changed to AudioActivationError
15:01:03.833 D Canceled bluetooth sco job
AudioSwitch Version
- Version: 1.2.0
Android Device (please complete the following information):
- Device: Pixel 7 & Samsung
- API Version: 34
Screenshots: Audio is coming via BT
My Observation and logs based on steps
There are two options to disconnect the call: from the main UI and the notification drawer. The issue typically occurs when I disconnect the call via the notification drawer but the code is same in both cases.
Code snippet related audio switch:
override fun onConnected(call: Call) {
_audioSwitch.activate()
mCallListener?.onConnected(call)
updatedUserConferenceJoinedStatus(isJoined = true)
}
VoiceCallService:
override fun onDestroy() {
Timber.d("Service on destroy>>>>>>>>>>>>>>>>>>>>>>>>>>>ready to stop audio service")
stopAudioService()
disconnectCall(true)
mCallServiceInstance = null
super.onDestroy()
}
Audio Switch Initialization:
_audioSwitch = AudioSwitch(applicationContext, loggingEnabled = true)