Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio is routing via Bluetooth but device list have Earpiece & Speaker phone only and BT option is not available #167

Open
tech-ajit-mob opened this issue Oct 8, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@tech-ajit-mob
Copy link

tech-ajit-mob commented Oct 8, 2024

The Bluetooth icon is not showing but the audio is routing via Bluetooth.

BT- Bluetooth

  1. Bluetooth is ON and connected> Incoming call is received and user is landed on the ongoing call screen
  2. Audio is coming via Bluetooth but Bluetooth icon is not showing on the ongoing call screen instead phone icon is showing.
  3. If you tap on the phone icon, audio switch options are only phone and speaker.

To Reproduce
Steps to reproduce the behavior:

  1. BT is connected and receives the call
  2. Click on the accept button
  3. Voice is routing via BT and it's working fine also you can change the mode from BT to Speaker or Phone.
  4. Disconnect BT from the notification drawer and reconnect again and working fine.
  5. Disconnect the call.
  6. BT is connected, again receives the incoming call, and clicks on the accept button
  7. 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 disable 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
Issue

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)

@tech-ajit-mob tech-ajit-mob added the bug Something isn't working label Oct 8, 2024
@tech-ajit-mob
Copy link
Author

Hi Team,
Have you had a chance to review this issue?

@ocarevs
Copy link
Collaborator

ocarevs commented Oct 21, 2024

Hi @tech-ajit-mob to clarify, in the initial steps 1-5, bluetooth is connected, but does not appear in the list of available devices, only after reconnecting the BT device it becomes listed? And then when you make a second call (while bluetooth is connected and active) then the BT device is missing in the device list again, is that correct?

@ocarevs
Copy link
Collaborator

ocarevs commented Oct 21, 2024

Are you using BluetoothHeadsetConnectionListener to see bluetooth related callbacks?

@tech-ajit-mob
Copy link
Author

tech-ajit-mob commented Oct 22, 2024

Are you using BluetoothHeadsetConnectionListener to see bluetooth related callbacks?

Yes, I was using it to get status only.

@tech-ajit-mob
Copy link
Author

tech-ajit-mob commented Oct 22, 2024

Hi @tech-ajit-mob to clarify, in the initial steps 1-5, bluetooth is connected, but does not appear in the list of available devices, only after reconnecting the BT device it becomes listed? And then when you make a second call (while bluetooth is connected and active) then the BT device is missing in the device list again, is that correct?

@ocarevs
Reply: Yes, that's correct. However, what's surprising is that although the Bluetooth (BT) is connected and audio is coming through it, the BT device doesn't appear in the list. You can also see this in the logs.

@ocarevs
Copy link
Collaborator

ocarevs commented Oct 29, 2024

@tech-ajit-mob We are investigating this issue. One question, have you tried our Voice quickstart, do you experience the same issue with quickstart?

@tech-ajit-mob
Copy link
Author

@ocarevs sorry for the delayed response due to festive season
I haven't tried with Voice quickstart . I will try to reproduce with quickstart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants