Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ad55529 authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by Sanket Agarwal
Browse files

MAP Client connect after PBAP Client

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)
parent c1c6d1d5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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)) {