summaryrefslogtreecommitdiffstats
path: root/core/java/android/bluetooth
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google..com>2011-10-26 15:03:08 -0700
committerJaikumar Ganesh <jaikumar@google.com>2011-10-26 16:00:28 -0700
commit6ae591217591e7f3e7de20b71f89d2ee9c8dc8bb (patch)
tree83317e607db775291aa45e8cafd323ab3c0ab929 /core/java/android/bluetooth
parented12460301cf0e04ac61993aaf1142f75f504814 (diff)
downloadframeworks_base-6ae591217591e7f3e7de20b71f89d2ee9c8dc8bb.zip
frameworks_base-6ae591217591e7f3e7de20b71f89d2ee9c8dc8bb.tar.gz
frameworks_base-6ae591217591e7f3e7de20b71f89d2ee9c8dc8bb.tar.bz2
Fix auto connection of headset profile.
Sometimes when headset service doesn't get bound, the auto connection fails. Based on a patch by: Chunho Park <chun.ho.park@samsung.com> Change-Id: Ia24613b47487717f51895953c7e8bc52abffecb5
Diffstat (limited to 'core/java/android/bluetooth')
-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 48d0203..7addd4a 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,