twilio / audioswitch

An Android audio management library for real-time communication apps.
Apache License 2.0
160 stars 49 forks source link

BluetoothHeadsetConnectionListener in BluetoothHeadsetManager causes inconsistency in the bluetooth device detection #131

Closed filipebatista closed 6 months ago

filipebatista commented 1 year ago

Describe the bug The BluetoothHeadsetManager receives an update form the system indicating STATE_AUDIO_CONNECTED is calling the BluetoothHeadsetConnectionListener.onBluetoothHeadsetStateChanged() with no Bluetooth device name. This will trigger the BluetoothHeadsetConnectionListener registered in AudioSwitch that consequently will remove the previous Bluetooth device detected by AudioSwitch.

To Reproduce Steps to reproduce the behavior:

  1. Pair the bluetooth audio device. Check that the STATE_CONNECTED is received in BluetoothHeadsetManager and that the device becomes available inAudioSwitch.availableAudioDevices.
  2. Wait a few moments to receive the STATE_AUDIO_CONNECTED in BluetoothHeadsetManager and that the previously detected device is removed from AudioSwitch.availableAudioDevices.

Expected behavior In BluetoothHeadsetManager when receiving aSTATE_AUDIO_CONNECTED should call the headsetListener?.onBluetoothHeadsetStateChanged(bluetoothDevice.name)

AudioSwitch Version Version: 1.1.5

ocarevs commented 1 year ago

@filipebatista I cannot reproduce this issue with your provided steps. Regarding your linked PR. The bluetooth device name is passed from the intent in STATE_CONNECTED is because there's a delay before device name can be taken via the BluetoothHeadset proxy class - link. Later when STATE_AUDIO_CONNECTED arrives no name is passed and bluetooth device name is gather via the proxy class here If you are having issue with bluetooth device disappearing from the list there might be some other issue here. cc: @afalls-twilio

filipebatista commented 1 year ago

I was able to reproduce the issue several times, with a Xiaomi mi lite 11, Samsung A10 and with airpods and defunc true go . Only when I performed the change of the open pull request the device name appeared correctly in the. Audioswitch available devices.

cc @nylton-martins

afalls-twilio commented 7 months ago

@filipebatista are you able to reproduced this with the quickstart? we are struggling to reproduce this issue and looking for a way to so that we can fix it.

filipebatista commented 7 months ago

Hello 👋 Didn't try to replicate with the quick start, nevertheless currently I'm no longer with the product that used your SDK so I can't really try it. Feel free to close if you find relevant. Thanks

afalls-twilio commented 6 months ago

closing due to no longer customer issue