From 71d6acbfd1a726e8722e4e0f32f20b7bb21b6656 Mon Sep 17 00:00:00 2001 From: Gaurav Asati Date: Tue, 28 Jul 2015 20:57:29 +0530 Subject: BT: Multi A2dp support in Settings App. 1. The connected sinks are not disconnected from A2dpProfile when new sink is connecting. 2. Also return correct connection status for specific HS. 3. Sets priority for specific HS while disconnecting. Change-Id: I56142d1527aa86d2bb47fb7166b2f3ab451d9b17 Bluetooth: Add support of two A2dp connections. Audio Service will now manage two a2dp connections and makes sure that BT a2dp connections are consistently seen by other applications. The change removes the BD address usage in BT names, and uses a new Strin "BluetoothA2dp" in order to show A2dp connected devices. Change-Id: I59b8f8eff7bbc8033fcd46d0ac21d94ee338ca36 --- .../android/settingslib/bluetooth/A2dpProfile.java | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) mode change 100755 => 100644 packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java (limited to 'packages/SettingsLib/src/com') diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java old mode 100755 new mode 100644 index 9608daa..873d392 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java @@ -116,7 +116,11 @@ public final class A2dpProfile implements LocalBluetoothProfile { List sinks = getConnectedDevices(); if (sinks != null) { for (BluetoothDevice sink : sinks) { - mService.disconnect(sink); + if (sink.equals(device)) { + // Connect to same device, Ignore it + Log.d(TAG,"Not disconnecting device = " + sink); + return true; + } } } return mService.connect(device); @@ -124,18 +128,36 @@ public final class A2dpProfile implements LocalBluetoothProfile { public boolean disconnect(BluetoothDevice device) { if (mService == null) return false; - // Downgrade priority as user is disconnecting the headset. - if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON){ - mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + List deviceList = mService.getConnectedDevices(); + if (!deviceList.isEmpty()) { + for (BluetoothDevice dev : deviceList) { + if (dev.equals(device)) { + if (V) Log.d(TAG,"Downgrade priority as user" + + "is disconnecting the headset"); + // Downgrade priority as user is disconnecting the headset. + if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON) { + mService.setPriority(device, BluetoothProfile.PRIORITY_ON); + } + return mService.disconnect(device); + } + } } - return mService.disconnect(device); + return false; } public int getConnectionStatus(BluetoothDevice device) { if (mService == null) { return BluetoothProfile.STATE_DISCONNECTED; } - return mService.getConnectionState(device); + List deviceList = mService.getConnectedDevices(); + if (!deviceList.isEmpty()) { + for (BluetoothDevice dev : deviceList) { + if (dev.equals(device)) { + return mService.getConnectionState(device); + } + } + } + return BluetoothProfile.STATE_DISCONNECTED; } public boolean isPreferred(BluetoothDevice device) { -- cgit v1.1