summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavi Nagarajan <nravi@broadcom.com>2012-08-29 05:29:51 -0700
committerMatthew Xie <mattx@google.com>2012-08-29 12:40:27 -0700
commit9eb4a84924718019c35fc5b32e59a6750ecf4116 (patch)
tree94dcd9d36cea35e34cb63e36a43ff2716297f3f5
parent976912e5f597f015754aa67f2a74040e27f58eab (diff)
downloadandroid_packages_apps_Bluetooth-9eb4a84924718019c35fc5b32e59a6750ecf4116.tar.gz
android_packages_apps_Bluetooth-9eb4a84924718019c35fc5b32e59a6750ecf4116.tar.bz2
android_packages_apps_Bluetooth-9eb4a84924718019c35fc5b32e59a6750ecf4116.zip
Adjust profile priorities when setting auto-connect
At a given point only one device should be set to have PRIORITY_AUTO_CONNECT per profile. When setting a device priority adjust the other devices' priority to make sure auto-connect is attempted with only one device bug 7076087 Change-Id: I1e03945a06e7acc901b53f34429194b3c3e76cd7
-rwxr-xr-xsrc/com/android/bluetooth/btservice/AdapterService.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index b7994e10b..7f2d378a0 100755
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -952,11 +952,32 @@ public class AdapterService extends Service {
}
}
+ private void adjustOtherHeadsetPriorities(HeadsetService hsService,
+ BluetoothDevice connectedDevice) {
+ for (BluetoothDevice device : getBondedDevices()) {
+ if (hsService.getPriority(device) >= BluetoothProfile.PRIORITY_AUTO_CONNECT &&
+ !device.equals(connectedDevice)) {
+ hsService.setPriority(device, BluetoothProfile.PRIORITY_ON);
+ }
+ }
+ }
+
+ private void adjustOtherSinkPriorities(A2dpService a2dpService,
+ BluetoothDevice connectedDevice) {
+ for (BluetoothDevice device : getBondedDevices()) {
+ if (a2dpService.getPriority(device) >= BluetoothProfile.PRIORITY_AUTO_CONNECT &&
+ !device.equals(connectedDevice)) {
+ a2dpService.setPriority(device, BluetoothProfile.PRIORITY_ON);
+ }
+ }
+ }
+
void setProfileAutoConnectionPriority (BluetoothDevice device, int profileId){
if (profileId == BluetoothProfile.HEADSET) {
HeadsetService hsService = HeadsetService.getHeadsetService();
if ((hsService != null) &&
(BluetoothProfile.PRIORITY_AUTO_CONNECT != hsService.getPriority(device))){
+ adjustOtherHeadsetPriorities(hsService, device);
hsService.setPriority(device,BluetoothProfile.PRIORITY_AUTO_CONNECT);
}
}
@@ -964,6 +985,7 @@ public class AdapterService extends Service {
A2dpService a2dpService = A2dpService.getA2dpService();
if ((a2dpService != null) &&
(BluetoothProfile.PRIORITY_AUTO_CONNECT != a2dpService.getPriority(device))){
+ adjustOtherSinkPriorities(a2dpService, device);
a2dpService.setPriority(device,BluetoothProfile.PRIORITY_AUTO_CONNECT);
}
}