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

Commit 75e7181e authored by xiaowang's avatar xiaowang
Browse files

Connect to BassClientService automatically

Test: manual
Change-Id: I63f8a384565408a9c2a7217037b482b5dc99bf52
parent 19565cda
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -439,7 +439,8 @@ class PhonePolicy {
        if (((profileId == BluetoothProfile.A2DP) || (profileId == BluetoothProfile.HEADSET)
                || (profileId == BluetoothProfile.LE_AUDIO)
                || (profileId == BluetoothProfile.CSIP_SET_COORDINATOR)
                || (profileId == BluetoothProfile.VOLUME_CONTROL))) {
                || (profileId == BluetoothProfile.VOLUME_CONTROL)
                || (profileId == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT))) {
            if (nextState == BluetoothProfile.STATE_CONNECTED) {
                switch (profileId) {
                    case BluetoothProfile.A2DP:
@@ -685,6 +686,7 @@ class PhonePolicy {
            mFactory.getVolumeControlService();
        BatteryService batteryService = mFactory.getBatteryService();
        HidHostService hidHostService = mFactory.getHidHostService();
        BassClientService bcService = mFactory.getBassClientService();

        if (hsService != null) {
            if (!mHeadsetRetrySet.contains(device) && (hsService.getConnectionPolicy(device)
@@ -767,6 +769,16 @@ class PhonePolicy {
                hidHostService.connect(device);
            }
        }
        if (bcService != null) {
            List<BluetoothDevice> connectedDevices = bcService.getConnectedDevices();
            if (!connectedDevices.contains(device) && (bcService.getConnectionPolicy(device)
                    == BluetoothProfile.CONNECTION_POLICY_ALLOWED)
                    && (bcService.getConnectionState(device)
                    == BluetoothProfile.STATE_DISCONNECTED)) {
                debugLog("Retrying connection to BASS with device " + device);
                bcService.connect(device);
            }
        }
    }

    private static void debugLog(String msg) {