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

Commit 27b4f6e9 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "PhonePolicy: add HAP to processConnectOtherProfiles" into main

parents 5b2d839b e2f924c4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1020,6 +1020,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback {
        BatteryService batteryService = mFactory.getBatteryService();
        HidHostService hidHostService = mFactory.getHidHostService();
        BassClientService bcService = mFactory.getBassClientService();
        HapClientService hapClientService = mFactory.getHapClientService();

        if (hsService != null) {
            if (!mHeadsetRetrySet.contains(device)
@@ -1120,6 +1121,19 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback {
                bcService.connect(device);
            }
        }
        if (Flags.connectHapOnOtherProfileConnect()) {
            if (hapClientService != null) {
                List<BluetoothDevice> connectedDevices = hapClientService.getConnectedDevices();
                if (!connectedDevices.contains(device)
                        && (hapClientService.getConnectionPolicy(device)
                                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)
                        && (hapClientService.getConnectionState(device)
                                == BluetoothProfile.STATE_DISCONNECTED)) {
                    debugLog("Retrying connection to HAS with device " + device);
                    hapClientService.connect(device);
                }
            }
        }
    }

    /**
+4 −1
Original line number Diff line number Diff line
@@ -280,7 +280,10 @@ public class HapClientService extends ProfileService {
        }
    }

    List<BluetoothDevice> getConnectedDevices() {
    /**
     * @return A list of connected {@link BluetoothDevice}.
     */
    public List<BluetoothDevice> getConnectedDevices() {
        synchronized (mStateMachines) {
            List<BluetoothDevice> devices = new ArrayList<>();
            for (HapClientStateMachine sm : mStateMachines.values()) {