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

Commit 15599f40 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Adapter: Use config value for default max connected audio devices"

parents 1b31e7d7 3fa8ed66
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -56,7 +56,8 @@ class AdapterProperties {


    private static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
    private static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
            "persist.bluetooth.maxconnectedaudiodevices";
            "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 long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800;
    private static final int BD_ADDR_LEN = 6; // in bytes
    private static final int BD_ADDR_LEN = 6; // in bytes
@@ -170,8 +171,20 @@ class AdapterProperties {
        mProfileConnectionState.clear();
        mProfileConnectionState.clear();
        mRemoteDevices = remoteDevices;
        mRemoteDevices = remoteDevices;


        mMaxConnectedAudioDevices = SystemProperties.getInt(
        // Get default max connected audio devices from config.xml in frameworks/base/core
                MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, MIN_CONNECTED_AUDIO_DEVICES);
        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();
        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
+6 −1
Original line number Original line Diff line number Diff line
@@ -1368,7 +1368,7 @@ public class AdapterService extends Service {
            // don't check caller, may be called from system UI
            // don't check caller, may be called from system UI
            AdapterService service = getService();
            AdapterService service = getService();
            if (service == null) {
            if (service == null) {
                return AdapterProperties.MIN_CONNECTED_AUDIO_DEVICES;
                return AdapterProperties.MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND;
            }
            }
            return service.getMaxConnectedAudioDevices();
            return service.getMaxConnectedAudioDevices();
        }
        }
@@ -2380,6 +2380,11 @@ public class AdapterService extends Service {
            return;
            return;
        }
        }


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


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