Merge "Bluetooth MaxConnectedAudioDevices show correct number"

This commit is contained in:
TreeHugger Robot
2018-01-06 05:57:23 +00:00
committed by Android (Google) Code Review
3 changed files with 20 additions and 9 deletions

View File

@@ -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>

View File

@@ -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]);
}

View File

@@ -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() {
mController.onDeveloperOptionsSwitchEnabled();
mController.updateState(mPreference);
for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
mController.onDeveloperOptionsSwitchDisabled();
assertThat(mPreference.isEnabled()).isFalse();
assertThat(mPreference.isEnabled()).isTrue();
assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
mListValues[numberOfDevices]);
mController.onDeveloperOptionsSwitchEnabled();
assertThat(mPreference.isEnabled()).isTrue();
assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
}
}
}