From d1889ed4bd9b6611347553d45aac0930dba0f136 Mon Sep 17 00:00:00 2001 From: Ravi Nagarajan Date: Tue, 22 May 2012 18:08:48 +0530 Subject: [PATCH] Headset connection status is displayed incorrectly, as the boolean mIsProfileReady is not initalized properly. Make sure mIsProfileReady is initialized always when onServiceConnected is received Change-Id: I968ce6900121a6140256b3181c792d421bdb7cf6 --- .../settings/bluetooth/HeadsetProfile.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/com/android/settings/bluetooth/HeadsetProfile.java b/src/com/android/settings/bluetooth/HeadsetProfile.java index 04c50ec1b7d..18992e069ce 100755 --- a/src/com/android/settings/bluetooth/HeadsetProfile.java +++ b/src/com/android/settings/bluetooth/HeadsetProfile.java @@ -65,19 +65,17 @@ final class HeadsetProfile implements LocalBluetoothProfile { // We just bound to the service, so refresh the UI of the // headset device. List deviceList = mService.getConnectedDevices(); - if (deviceList.isEmpty()) { - mProfileManager.setHfServiceUp(true); - return; + if (!deviceList.isEmpty()) { + BluetoothDevice firstDevice = deviceList.get(0); + CachedBluetoothDevice device = mDeviceManager.findDevice(firstDevice); + // we may add a new device here, but generally this should not happen + if (device == null) { + Log.w(TAG, "HeadsetProfile found new device: " + firstDevice); + device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, firstDevice); + } + device.onProfileStateChanged(HeadsetProfile.this, + BluetoothProfile.STATE_CONNECTED); } - BluetoothDevice firstDevice = deviceList.get(0); - CachedBluetoothDevice device = mDeviceManager.findDevice(firstDevice); - // we may add a new device here, but generally this should not happen - if (device == null) { - Log.w(TAG, "HeadsetProfile found new device: " + firstDevice); - device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, firstDevice); - } - device.onProfileStateChanged(HeadsetProfile.this, - BluetoothProfile.STATE_CONNECTED); mProfileManager.callServiceConnectedListeners(); mProfileManager.setHfServiceUp(true);