From 8594394aadeaaa3f834d33d7b198fb071e0f31fe Mon Sep 17 00:00:00 2001 From: Matthew Xie Date: Fri, 29 Jul 2011 18:57:58 -0700 Subject: Move mBluetoothService.runBluetooth after broadcasting the STATE_ON intent. This is because broadcastState method move the Bluetooth adapter state to ON. The mBluetoothService.runBluetooth should be called only in the ON state. Remove mIsDiscovering variable in BluetoothService. Fix a bug in BluetoothA2dpService that caused 2 times of state change from DISCONNECTED to CONNECTING that messed up BluetoothService's connection state count. Change-Id: Ifb782a845ae70f007d2e036d930bb55f445d68b5 --- core/java/android/server/BluetoothA2dpService.java | 25 +++++----------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'core/java/android/server/BluetoothA2dpService.java') diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index fd277d0..f498bb2 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -187,24 +187,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { return false; } - private synchronized boolean addAudioSink(BluetoothDevice device) { - String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); - String propValues[] = (String []) getSinkPropertiesNative(path); - if (propValues == null) { - Log.e(TAG, "Error while getting AudioSink properties for device: " + device); - return false; - } - Integer state = null; - // Properties are name-value pairs - for (int i = 0; i < propValues.length; i+=2) { - if (propValues[i].equals(PROPERTY_STATE)) { - state = new Integer(convertBluezSinkStringToState(propValues[i+1])); - break; - } + private synchronized void addAudioSink(BluetoothDevice device) { + if (mAudioDevices.get(device) == null) { + mAudioDevices.put(device, BluetoothA2dp.STATE_DISCONNECTED); } - mAudioDevices.put(device, state); - handleSinkStateChange(device, BluetoothA2dp.STATE_DISCONNECTED, state); - return true; } private synchronized void onBluetoothEnable() { @@ -259,9 +245,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { return false; } - if (mAudioDevices.get(device) == null && !addAudioSink(device)) { - return false; - } + addAudioSink(device); String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); if (path == null) { @@ -495,6 +479,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { // This is for an incoming connection for a device not known to us. // We have authorized it and bluez state has changed. addAudioSink(device); + handleSinkStateChange(device, BluetoothA2dp.STATE_DISCONNECTED, state); } else { if (state == BluetoothA2dp.STATE_PLAYING && mPlayingA2dpDevice == null) { mPlayingA2dpDevice = device; -- cgit v1.1