I have spent full 7 days trying to make a PandaBoard ES act as a (full featured) headset. While I don't use Android (and don't want to ever use it ;) ) I have setup everything in a custom Linux OS
Well, hopefully in Android it is easier, but It was a mess to just get it to a semi working state (A2DP, AVCRP, HFP profiles), I had to customize BlueZ, customize PulseAudio, customize Alsa and customize some bits of the Kernel, specially the shmem parts (at least ofono was compiled as default)
And after a lot (really a lot) modifications, I can get A2DP fully working with some special combinations (BlueZ 5, Pulse from git), but no HFP with this combination, PulseA (for BlueZ 5.x) doesn't register a HFP (SCO) audio
agent.
Then I can get a semi-working HFP with a totally different combination (and more modifications) and finally use Alsa directly (I don't want to use PulseA in my OS), but the SCO audio quality was not really usable. You need to route via HCI and no PCM (the TiWiBle module, in the current PandaBoard setup can't route via PCM), the voice sounds as if is sampled at twice the speed, but the SCO connection reports 8000Hz, and this results in audio played back at twice the speed. But then A2DP didn't work with this setup.
PBAP never worked on any of my tests, and a somewhat small subset of AVCRP did
To solve this we need access to the firmware, and TI and LSI have it under a lock.
After almost a week on this, I have started playing with HCI commands to change the TiWiBLE setup directly to see if the sound issue can be corrected, but I decided that this is taking more than what was allowed for setting bluetooth, and we just threw hardware at the problem (we replaced the odd TiWiBLE with a BC127) and in a couple of hours it was working nicely with more features than what you would ever need (including PBAP, SAP, SPP, source, sink modes and BLE support)
So, hopefully the Bluetooth stack in Android is more mature and stable, but BlueZ/PulseAudio/ofono is a no go on Linux (at least in the current state) and not really usable for production
Anyway if you are using BlueZ on Android and need any help, ask away I will try to help
Lioric