OSDN Git Service

MAP Client connect after PBAP Client
authorJoseph Pirozzo <pirozzoj@google.com>
Thu, 13 Oct 2016 20:47:54 +0000 (13:47 -0700)
committerSanket Agarwal <sanketa@google.com>
Wed, 2 Nov 2016 04:41:27 +0000 (21:41 -0700)
Add code to automatically attempt to connect MAP Client (if enabled)
after PBAP Client connects.  This will typically be invoked at system or
adapter reset, but could as well happen if MAP Client isn't connected
and a new PBAP connection is established.

Bug: 32153228
Change-Id: I9ac5121ccf0d7ef3e5847df32034094e085aa434
(cherry picked from commit 46873217f3ddb8b848ce0b8fdf4a0531dfb04224)

src/com/android/bluetooth/btservice/AdapterService.java

index d370d6f..8119bef 100644 (file)
@@ -1786,6 +1786,7 @@ public class AdapterService extends Service {
         HeadsetClientService headsetClientService = HeadsetClientService.getHeadsetClientService();
         A2dpSinkService a2dpSinkService = A2dpSinkService.getA2dpSinkService();
         PbapClientService pbapClientService = PbapClientService.getPbapClientService();
+        MapClientService mapClientService = MapClientService.getMapClientService();
         PanService panService = PanService.getPanService();
 
         boolean allProfilesEmpty = true;
@@ -1794,6 +1795,7 @@ public class AdapterService extends Service {
         List<BluetoothDevice> headsetClientConnDevList = null;
         List<BluetoothDevice> a2dpSinkConnDevList = null;
         List<BluetoothDevice> pbapClientConnDevList = null;
+        List<BluetoothDevice> mapClientConnDevList = null;
         List<BluetoothDevice> panConnDevList = null;
 
         if (hsService != null) {
@@ -1816,6 +1818,10 @@ public class AdapterService extends Service {
             pbapClientConnDevList = pbapClientService.getConnectedDevices();
             allProfilesEmpty = allProfilesEmpty && pbapClientConnDevList.isEmpty();
         }
+        if (mapClientService != null) {
+            mapClientConnDevList = mapClientService.getConnectedDevices();
+            allProfilesEmpty = allProfilesEmpty && mapClientConnDevList.isEmpty();
+        }
         if (panService != null) {
             panConnDevList = panService.getConnectedDevices();
             allProfilesEmpty = allProfilesEmpty && panConnDevList.isEmpty();
@@ -1856,6 +1862,14 @@ public class AdapterService extends Service {
                 pbapClientService.connect(device);
             }
         }
+        if (mapClientService != null) {
+            if (mapClientConnDevList.isEmpty() &&
+                    (mapClientService.getPriority(device) >= BluetoothProfile.PRIORITY_ON)) {
+                if (pbapClientConnDevList.isEmpty() || pbapClientConnDevList.contains(device)) {
+                    mapClientService.connect(device);
+                }
+            }
+        }
         if (panService != null) {
             if (panConnDevList.isEmpty() &&
                 (panService.getPriority(device) >= BluetoothProfile.PRIORITY_ON)) {