diff options
author | Nick Pelly <npelly@google.com> | 2009-08-19 14:49:29 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-08-19 15:20:39 -0700 |
commit | a56d1c72190462aa9e377906583eceb58e0efcdd (patch) | |
tree | 2ab6030776ecec07313c2fd768736caf23c84810 /media | |
parent | 77035a31dda76200b4096db49cb58a169ab54b2c (diff) | |
download | frameworks_base-a56d1c72190462aa9e377906583eceb58e0efcdd.zip frameworks_base-a56d1c72190462aa9e377906583eceb58e0efcdd.tar.gz frameworks_base-a56d1c72190462aa9e377906583eceb58e0efcdd.tar.bz2 |
Fix AudioService on HFP power off due to new Bluetooth API.
HEADSET_STATE_CHANGED_ACTION contains a null BluetoothDevice when the HFP
disconnects.
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioService.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 05b68d4..0a1b142 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -1391,21 +1391,26 @@ public class AudioService extends IAudioService.Stub { } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) { int state = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, BluetoothHeadset.STATE_ERROR); - BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); - String address = btDevice.getAddress(); int device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO; - int btClass = btDevice.getBluetoothClass(); - if (BluetoothClass.Device.Major.getDeviceMajor(btClass) == BluetoothClass.Device.Major.AUDIO_VIDEO) { - switch (BluetoothClass.Device.getDevice(btClass)) { - case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: - case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: - device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET; - break; - case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: - device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT; - break; - default: - break; + BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); + String address = null; + int btClass = BluetoothClass.ERROR; + if (btDevice != null) { + address = btDevice.getAddress(); + btClass = btDevice.getBluetoothClass(); + if (BluetoothClass.Device.Major.getDeviceMajor(btClass) == + BluetoothClass.Device.Major.AUDIO_VIDEO) { + switch (BluetoothClass.Device.getDevice(btClass)) { + case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: + case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: + device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET; + break; + case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT; + break; + default: + break; + } } } |