summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jaikumar Ganesh <jaikumar@google.com> 2011-10-26 23:20:48 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2011-10-26 23:20:48 +0000
commitc307d1aea2fe755780f02922e1d1d347bf35aba3 (patch)
tree137794acb093247a3ae759eb1a0738a62460fd91
parent1825e51b2d35e3b5a06411274ea4382da0439973 (diff)
parent01d24784a5ddece8bb7c5d088bf93c99faa0dc7e (diff)
am 01d24784: Merge "Fix auto connection of headset profile." into ics-mr0
* commit '01d24784a5ddece8bb7c5d088bf93c99faa0dc7e': Fix auto connection of headset profile.
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 48d0203b06fe..7addd4a56d18 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -110,6 +110,7 @@ public final class BluetoothDeviceProfileState extends StateMachine {
private BluetoothHeadset mHeadsetService;
private BluetoothPbap mPbapService;
private boolean mPbapServiceConnected;
+ private boolean mAutoConnectionPending;
private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
private BluetoothDevice mDevice;
@@ -272,6 +273,10 @@ public final class BluetoothDeviceProfileState extends StateMachine {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
synchronized(BluetoothDeviceProfileState.this) {
mHeadsetService = (BluetoothHeadset) proxy;
+ if (mAutoConnectionPending) {
+ sendMessage(AUTO_CONNECT_PROFILES);
+ mAutoConnectionPending = false;
+ }
}
}
public void onServiceDisconnected(int profile) {
@@ -360,8 +365,9 @@ public final class BluetoothDeviceProfileState extends StateMachine {
// Don't auto connect to docks.
break;
} else {
- if (mHeadsetService != null &&
- mHeadsetService.getPriority(mDevice) ==
+ if (mHeadsetService == null) {
+ mAutoConnectionPending = true;
+ } else if (mHeadsetService.getPriority(mDevice) ==
BluetoothHeadset.PRIORITY_AUTO_CONNECT &&
mHeadsetService.getDevicesMatchingConnectionStates(
new int[] {BluetoothProfile.STATE_CONNECTED,