1

I am trying to keep the bluetooth sco connected for a device running android from the time the bluetooth headset is connected to when the headset is disconnected or more specifically I would like the sco link not torn down by an app while the bluetooth headset is connected. It is okay for a user while in the VOIP call menu to select the BT/speaker icon button and tear down and bring back up the sco link (as it is user initiated).

When a VOIP call ends (eg whatsApp, google hangouts, skype, viber etc) while using a bluetooth headset, the sco link gets torn down. I would like the sco link to be either not torn down when the VOIP call ends (preferred operation) or re-established through "some" mechanism.

Things I have tried (with no success):

1) Trying to detect VOIP call start/end but reading other SO posts, looks like this is not possible. There are a lot of hooks to detect a sim-based call and end but not for VOIP based calls.

2) Start sco using startVoiceRecognition() like below. This seemed to work...almost...

audioManager.setMode(MODE_IN_COMMUNICATION)
audioManager.startVoiceRecognition()

There were two problems with this approach.

  • An incoming whatsApp call tears down the sco established by using the startVoiceRecognition() api
  • While in a VOIP call (hangouts, whatsApp etc), the in-call audio route options do not work

I have gone over several SO posts on this but with no success.

3) I observed that Audiomanager.setMode gets set to MODE_NORMAL (0) when a VOIP call ends and I can startBlueToothSco() there but there is no listener for AudioManager mode changes and I do not want to poll it. I also observed that depends on the VOIP app attempting to stop sco on a call end, checking the mode may not work as the app could call stopBluetoothSco after the mode change.

4) Make a dummy call using ConnectionService api's that makes android think its in a call but that prevents VOIP calls from being established and hence the sco link will not be disconnected. (not desirable as I need VOIP calls to happen)

Any ideas/suggestions will be appreciated.

0 Answers0