Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth HFP support for Android App with SIP/VoIP

I am trying to add support for bluetooth devices like headsets/headphones/car stereo to my android app which allows user to make SIP/VoIP calls. I am trying to mostly address the requirements of Answering and Ending of calls using button on bluetooth headsets, other buttons/features handling is good to have.

With the search I have done and all the text I have read so far, I have come across the following-

  • One common way suggested everywhere is registering to ACTION_AUDIO_STATE_CHANGED. But this doesn't really helps me. Intents for it are sent every time the button on Bluetooth headset is pressed And also when we start the ring tone on bluetooth headset.
  • A very common solution I found was use of Bluetooth Adapter class. There isn't much you could do with it. So again not helpful.
  • Another approach I came across is the use of Vendor specific headset events. After some efforts I was able to get this working for specific Plantronics Bluetooth headsets. Supporting Jabra is important.
  • One more approach I came across is binding with IBluetoothHeadsetPhone.aidl, the way the phone app does it. I could find very little information on it, not enough to go ahead and implement any thing.

If anyone has done such things, I think the problem I am facing is not an uncommon one, I just believe it is not documented well. Any pointer, approach, link would be appreciated.

I will try to add more info as I find any or any other approaches I try. Please ask for details if you need any more on the solutions I have tried. And please suggest changes instead of just flagging the question. Thanks in adv.

like image 497
sole007 Avatar asked Jun 16 '17 14:06

sole007


1 Answers

Sorry about the late post. I was able to find a solution for this issue. It is not simple fix.

You need to use ConnectionService from Android telecom framework. Check out this link here & here. After this your VoIP calls will have cellular call like treatment.

like image 182
sole007 Avatar answered Oct 14 '22 22:10

sole007