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

Commit 4b367aba authored by Hansong Zhang's avatar Hansong Zhang
Browse files

DO NOT MERGE Add developer menu to select max number of connected audio devices

The new developer option modifies the system property
"persist.bluetooth.maxconnectedaudiodevices"; it allows testing
multiple connected devices for A2DP, AVRCP, HFP.

Bug: 71603731
Test: Robolectric test
Change-Id: If8c2c26ad4c9a2b7458a2d16a0c29d5f9b4df5c7
parent 80c0656c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -316,6 +316,24 @@
        <item>Never time out</item>
    </string-array>

    <!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
    <string-array name="bluetooth_max_connected_audio_devices">
        <item>1 (Default)</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
    </string-array>

    <!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
    <string-array name="bluetooth_max_connected_audio_devices_values">
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
    </string-array>

    <!-- Match this with drawable.wifi_signal. --> <skip />
    <!-- Wi-Fi settings. The signal strength a Wi-Fi network has. -->
    <string-array name="wifi_signal">
+5 −0
Original line number Diff line number Diff line
@@ -1606,6 +1606,11 @@
    <!-- Summary of checkbox for disabling Bluetooth inband ringing in Development Settings -->
    <string name="bluetooth_disable_inband_ringing_summary">Don’t play custom phone ringtones on Bluetooth headsets</string>
    <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
    <string name="bluetooth_max_connected_audio_devices_string">Maximum number of connected Bluetooth audio devices</string>
    <!-- Bluetooth developer settings: Maximum number of connected audio devices -->
    <string name="bluetooth_max_connected_audio_devices_dialog_title">Select maximum number of connected Bluetooth audio devices</string>
    <!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
    <string name="wifi_display_settings_title">Cast</string>
    <!-- Wifi Display settings. The title of a menu item to enable wireless display [CHAR LIMIT=40] -->
+7 −0
Original line number Diff line number Diff line
@@ -270,6 +270,13 @@
            android:entries="@array/bluetooth_a2dp_codec_ldac_playback_quality_titles"
            android:entryValues="@array/bluetooth_a2dp_codec_ldac_playback_quality_values" />

        <ListPreference
            android:key="bluetooth_max_connected_audio_devices"
            android:title="@string/bluetooth_max_connected_audio_devices_string"
            android:dialogTitle="@string/bluetooth_max_connected_audio_devices_dialog_title"
            android:entries="@array/bluetooth_max_connected_audio_devices"
            android:entryValues="@array/bluetooth_max_connected_audio_devices_values" />

        <com.android.settings.development.PrivateDnsModeDialogPreference
            android:key="select_private_dns_configuration"
            android:title="@string/select_private_dns_configuration_title"
+26 −0
Original line number Diff line number Diff line
@@ -215,6 +215,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
    private static final String BLUETOOTH_BTSNOOP_ENABLE_PROPERTY =
                                    "persist.bluetooth.btsnoopenable";

    static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
            "persist.bluetooth.maxconnectedaudiodevices";

    private static final String BLUETOOTH_DISABLE_INBAND_RINGING_KEY = "bluetooth_disable_inband_ringing";
    private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY = "bluetooth_select_avrcp_version";
    private static final String BLUETOOTH_SELECT_A2DP_CODEC_KEY = "bluetooth_select_a2dp_codec";
@@ -222,6 +225,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
    private static final String BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY = "bluetooth_select_a2dp_bits_per_sample";
    private static final String BLUETOOTH_SELECT_A2DP_CHANNEL_MODE_KEY = "bluetooth_select_a2dp_channel_mode";
    private static final String BLUETOOTH_SELECT_A2DP_LDAC_PLAYBACK_QUALITY_KEY = "bluetooth_select_a2dp_ldac_playback_quality";
    private static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY =
            "bluetooth_max_connected_audio_devices";

    private static final String PRIVATE_DNS_PREF_KEY = "select_private_dns_configuration";

@@ -301,6 +306,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
    private ListPreference mBluetoothSelectA2dpBitsPerSample;
    private ListPreference mBluetoothSelectA2dpChannelMode;
    private ListPreference mBluetoothSelectA2dpLdacPlaybackQuality;
    private ListPreference mBluetoothSelectMaxConnectedAudioDevices;

    private SwitchPreference mOtaDisableAutomaticUpdate;
    private SwitchPreference mWifiAllowScansWithTraffic;
@@ -525,6 +531,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY);
        mBluetoothSelectA2dpChannelMode = addListPreference(BLUETOOTH_SELECT_A2DP_CHANNEL_MODE_KEY);
        mBluetoothSelectA2dpLdacPlaybackQuality = addListPreference(BLUETOOTH_SELECT_A2DP_LDAC_PLAYBACK_QUALITY_KEY);
        mBluetoothSelectMaxConnectedAudioDevices = addListPreference(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY);
        initBluetoothConfigurationValues();

        updatePrivateDnsSummary();
@@ -1858,6 +1865,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        index = 3;
        mBluetoothSelectA2dpLdacPlaybackQuality.setValue(values[index]);
        mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);

        // Init the maximum connected devices - Default
        values = getResources().getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
        summaries = getResources().getStringArray(R.array.bluetooth_max_connected_audio_devices);
        index = 0;
        mBluetoothSelectMaxConnectedAudioDevices.setValue(values[index]);
        mBluetoothSelectMaxConnectedAudioDevices.setSummary(summaries[index]);
    }

    private void writeBluetoothAvrcpVersion(Object newValue) {
@@ -2026,6 +2040,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
        }
    }

    private void writeBluetoothMaxConnectedAudioDevices(Object newValue) {
        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
        int index = mBluetoothSelectMaxConnectedAudioDevices.findIndexOfValue(newValue.toString());
        if (index >= 0) {
            String[] titles = getResources().getStringArray(R.array.bluetooth_max_connected_audio_devices);
            mBluetoothSelectMaxConnectedAudioDevices.setSummary(titles[index]);
        }
    }

    private void writeBluetoothConfigurationOption(Preference preference,
                                                   Object newValue) {
        String[] summaries;
@@ -2621,6 +2644,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                   (preference == mBluetoothSelectA2dpLdacPlaybackQuality)) {
            writeBluetoothConfigurationOption(preference, newValue);
            return true;
        } else if (preference == mBluetoothSelectMaxConnectedAudioDevices) {
            writeBluetoothMaxConnectedAudioDevices(newValue);
            return true;
        } else if (preference == mLogdSize) {
            writeLogdSizeOption(newValue);
            return true;