From 62895a67d2c34fc2a4b8943e330c4269275b1c20 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Wed, 30 Sep 2009 15:30:43 -0700 Subject: Fix regression. When turning off BT while connected to an A2DP/HFP headset we can hit the path BluetoothHeadsetService.onReceive(BluetoothHeadset.STATE_CHANGED) -> BluetoothHandsfree.audioOff() -> BluetoothA2dp.resumeSink() -> which causes resumeSink() to NPE because mAudioDevices.get() returns null. It's a race between A2DP marking the device as disconnected, and HFP marking the device as disconnected. Fix is to NPE check in resumeSink(). Change-Id: I2782ac8c70ea1678d7de5fcd49bff8e03df36f4e --- core/java/android/server/BluetoothA2dpService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'core/java/android/server') diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index 4a5f431..f871533 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -333,10 +333,11 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { return false; } String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); - if (path == null) { + Integer state = mAudioDevices.get(device); + if (path == null || state == null) { return false; } - switch (mAudioDevices.get(device)) { + switch (state.intValue()) { case BluetoothA2dp.STATE_CONNECTED: return true; case BluetoothA2dp.STATE_PLAYING: @@ -354,10 +355,11 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { return false; } String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); - if (path == null) { + Integer state = mAudioDevices.get(device); + if (path == null || state == null) { return false; } - switch (mAudioDevices.get(device)) { + switch (state.intValue()) { case BluetoothA2dp.STATE_PLAYING: return true; case BluetoothA2dp.STATE_CONNECTED: -- cgit v1.1