From 11b1b0697325176f2ea4544c2227a4ea96e4ca9f Mon Sep 17 00:00:00 2001 From: Joseph Pirozzo Date: Thu, 30 Mar 2017 15:42:01 -0700 Subject: [PATCH] Bluetooth Multi Connect Allow automotive bluetooth profiles to connect to issue multiple connect calls without disconnecting other devices. These client side profiles either support multiple connections or handle multiple connection requests gracefully. Bug: 36789202 Test: Manual, Connect to one paired device then attempt to connect to a second paired device, observe that HFP and PBAP are both connected on both devices. Change-Id: I8bd6aea2b8411ba5585b34292d8c6ec62c5c2f96 (cherry picked from commit 43eba0836d89c21c4bec20bd251f4e82310b7cf1) --- .../android/settingslib/bluetooth/A2dpSinkProfile.java | 3 --- .../android/settingslib/bluetooth/HfpClientProfile.java | 5 ----- .../android/settingslib/bluetooth/MapClientProfile.java | 8 ++++---- .../android/settingslib/bluetooth/PbapClientProfile.java | 3 --- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java index 77f2e19abd97e..a1c8de566578e 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java @@ -122,9 +122,6 @@ final class A2dpSinkProfile implements LocalBluetoothProfile { return true; } } - for (BluetoothDevice src : srcs) { - mService.disconnect(src); - } } return mService.connect(device); } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java index 9b699bcfd38cc..169aac9eb60ff 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HfpClientProfile.java @@ -132,11 +132,6 @@ final class HfpClientProfile implements LocalBluetoothProfile { return true; } } - // Handsfree HF only supports one source connection and hence it is OK to disconnect - // the only connected device here. - for (BluetoothDevice src : srcs) { - mService.disconnect(src); - } } return mService.connect(device); } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java index a7621fcf02fb1..6efa4687d9134 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/MapClientProfile.java @@ -115,10 +115,10 @@ public final class MapClientProfile implements LocalBluetoothProfile { public boolean connect(BluetoothDevice device) { if (mService == null) return false; List connectedDevices = getConnectedDevices(); - if (connectedDevices != null) { - for (BluetoothDevice connectedDevice : connectedDevices) { - mService.disconnect(connectedDevice); - } + if (connectedDevices != null && connectedDevices.contains(device)) { + // Connect to same device, Ignore it + Log.d(TAG,"Ignoring Connect"); + return true; } return mService.connect(device); } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java index 72a3b3a00e221..bd37abeb3b0c0 100755 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapClientProfile.java @@ -144,9 +144,6 @@ final class PbapClientProfile implements LocalBluetoothProfile { return true; } } - for (BluetoothDevice src : srcs) { - mService.disconnect(src); - } } Log.d(TAG,"PBAPClientProfile attempting to connect to " + device.getAddress());