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

Commit 3fa8ed66 authored by Jack He's avatar Jack He
Browse files

Adapter: Use config value for default max connected audio devices

* Use config_bluetooth_max_connected_audio_devices config value for
  default max connected audio devices
* Override above value using system property if the property is set by
  development settings
* Check and normalize resultant value to permitted range
  [MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND,
  MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND]
* Dump this value to dumpsys

Bug: 64767509
Test: Enable and disable multi-device mode in development settings
Change-Id: Id038d742e9aadfc964b52e406467f4e86a73b73f
parent 2a1b62e2
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ class AdapterProperties {

    private static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
            "persist.bluetooth.maxconnectedaudiodevices";
    static final int MIN_CONNECTED_AUDIO_DEVICES = 1;
    static final int MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND = 1;
    private static final int MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND = 5;

    private static final long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800;
    private static final int BD_ADDR_LEN = 6; // in bytes
@@ -170,8 +171,20 @@ class AdapterProperties {
        mProfileConnectionState.clear();
        mRemoteDevices = remoteDevices;

        mMaxConnectedAudioDevices = SystemProperties.getInt(
                MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, MIN_CONNECTED_AUDIO_DEVICES);
        // Get default max connected audio devices from config.xml in frameworks/base/core
        int configDefaultMaxConnectedAudioDevices = mService.getResources().getInteger(
                com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
        // Override max connected audio devices if MAX_CONNECTED_AUDIO_DEVICES_PROPERTY is set
        int propertyOverlayedMaxConnectedAudioDevices =
                SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
                        configDefaultMaxConnectedAudioDevices);
        // Make sure the final value of max connected audio devices is within allowed range
        mMaxConnectedAudioDevices = Math.min(Math.max(propertyOverlayedMaxConnectedAudioDevices,
                MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND), MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND);
        Log.i(TAG, "init(), maxConnectedAudioDevices, default="
                + configDefaultMaxConnectedAudioDevices + ", propertyOverlayed="
                + propertyOverlayedMaxConnectedAudioDevices + ", finalValue="
                + mMaxConnectedAudioDevices);

        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
+6 −1
Original line number Diff line number Diff line
@@ -1368,7 +1368,7 @@ public class AdapterService extends Service {
            // don't check caller, may be called from system UI
            AdapterService service = getService();
            if (service == null) {
                return AdapterProperties.MIN_CONNECTED_AUDIO_DEVICES;
                return AdapterProperties.MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND;
            }
            return service.getMaxConnectedAudioDevices();
        }
@@ -2380,6 +2380,11 @@ public class AdapterService extends Service {
            return;
        }

        writer.println("AdapterProperties");
        writer.println("  " + "MaxConnectedAudioDevices: " + getMaxConnectedAudioDevices());
        writer.println();


        writer.println("Bonded devices:");
        for (BluetoothDevice device : getBondedDevices()) {
            writer.println(