Search code examples
androidbluetoothbluetooth-sco

Android Bluetooth SCO with Nissan car radio


Before we get to the details, a little context:

  • Car: Nissan Note (UK 2011 Model)
  • Device: Nexus 4
  • OS: Android 4.3 Stock

I'm trying to create an app to do speech recognition and synthesis in my car while the phone is connected over bluetooth. The car audio system does not provide it's own voice recognition, but instead delegates this to the phone by triggering an intent android.intent.action.VOICE_COMMAND

The default app on the device for handling this is the Google Search app, which has a specific activity for hands-free dialling. This app has terrible speech recognition but does demonstrate how the system is supposed to work - when activated the car displays "Voice recognition active" on the phone screen while the app is running, and then hides it when the app exits.

The problem I have is that while I can make this label appear by calling AudioManager.startBluetoothSco() and thus play audio through the car speakers and record it through the car microphone, but AudioManager.stopBluetoothSco() does not disable this mode in the car, and it remains displaying 'Voice recognition active'. This is a problem since the car will not then launch the app until the bluetooth connection has been closed and re-opened.

My experiments have verified that it is AudioManager.startBluetoothSco() which enables the mode in the car, and that AudioManager.stopBluetoothSco() appears to have the effect of changing the ambient sound produced by the car (a very faint hiss usually heard when the audio system is active will stop when this command is issued) but no other effect is seen.

I am unsure if something else is activated implicitly with the call to AudioManager.startBluetoothSco() which must then be implicitly stopped, but I'm currently out of ideas for what to try.


Solution

  • After a lot more research I came across this: http://developer.android.com/reference/android/bluetooth/BluetoothHeadset.html#stopVoiceRecognition%28android.bluetooth.BluetoothDevice%29 which would appear to be related to the problem. After calling startVoiceRecognition and stopVoiceRecognition as appropriate, things appeared to return to their normal state.