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

Commit 7937798b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Bluetooth MaxConnectedAudioDevices show correct number"

parents f3fa890b de2855ab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1630,7 +1630,7 @@
    <string name="bluetooth_dock_settings_remember">Remember settings</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>
    <string name="bluetooth_max_connected_audio_devices_string">Maximum 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>
+3 −2
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
        updateState(preference);
        return true;
    }

@@ -88,13 +89,13 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
    @Override
    protected void onDeveloperOptionsSwitchEnabled() {
        mPreference.setEnabled(true);
        mPreference.setValue(mListValues[0]);
        mPreference.setSummary(mListSummaries[0]);
        updateState(mPreference);
    }

    @Override
    protected void onDeveloperOptionsSwitchDisabled() {
        mPreference.setEnabled(false);
        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, mListValues[0]);
        mPreference.setValue(mListValues[0]);
        mPreference.setSummary(mListSummaries[0]);
    }
+16 −6
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
                    BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);

            assertThat(currentValue).isEqualTo(mListValues[numberOfDevices]);
            assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
            assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
        }
    }

@@ -122,20 +124,28 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
    @Test
    public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
        mController.onDeveloperOptionsSwitchDisabled();
        mController.updateState(mPreference);

        assertThat(mPreference.isEnabled()).isFalse();
        assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
        assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
        final String currentValue = SystemProperties.get(
                BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
        assertThat(currentValue).isEqualTo(mListValues[0]);
    }

    @Test
    public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
        for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
            mController.onDeveloperOptionsSwitchDisabled();
            assertThat(mPreference.isEnabled()).isFalse();

            SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
                    mListValues[numberOfDevices]);
            mController.onDeveloperOptionsSwitchEnabled();
        mController.updateState(mPreference);

            assertThat(mPreference.isEnabled()).isTrue();
        assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
        assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
            assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
            assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
        }
    }
}