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

Commit 87f90bc6 authored by Chienyuan's avatar Chienyuan
Browse files

Remove A2DP connect logic from settingslib

A2dpProfile will disconnect current device when receive connect event
and max connectable device is one. Ideally we shouldn't have any
bluetooth code in settingslib. The corresponding logic is moved to
the Bluetooth A2dpService.

Bug: 111812003
Test: 1. Developer options > Maxium connected Bluetooth device > 1.
      2. Connected 2 BT Headset respectively

Change-Id: I298c39942756523b8a2b34a4104bcd247d2455eb
parent 4d98474f
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -133,20 +133,6 @@ public class A2dpProfile implements LocalBluetoothProfile {

    public boolean connect(BluetoothDevice device) {
        if (mService == null) return false;
        int max_connected_devices = mLocalAdapter.getMaxConnectedAudioDevices();
        if (max_connected_devices == 1) {
            // Original behavior: disconnect currently connected device
            List<BluetoothDevice> sinks = getConnectedDevices();
            if (sinks != null) {
                for (BluetoothDevice sink : sinks) {
                    if (sink.equals(device)) {
                        Log.w(TAG, "Connecting to device " + device + " : disconnect skipped");
                        continue;
                    }
                    mService.disconnect(sink);
                }
            }
        }
        return mService.connect(device);
    }

+0 −4
Original line number Diff line number Diff line
@@ -246,10 +246,6 @@ public class LocalBluetoothAdapter {
        return mAdapter.getRemoteDevice(address);
    }

    public int getMaxConnectedAudioDevices() {
        return mAdapter.getMaxConnectedAudioDevices();
    }

    public List<Integer> getSupportedProfiles() {
        return mAdapter.getSupportedProfiles();
    }