Loading src/com/android/settings/development/BluetoothLeAudioModePreferenceController.java +9 −4 Original line number Diff line number Diff line Loading @@ -96,17 +96,17 @@ public class BluetoothLeAudioModePreferenceController return; } String currentValue; if (mBluetoothAdapter.isLeAudioBroadcastSourceSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED) { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "broadcast"); currentValue = "broadcast"; } else if (mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED) { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "unicast"); currentValue = "unicast"; } else { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "disabled"); currentValue = "disabled"; } final String currentValue = SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY); int index = 0; for (int i = 0; i < mListValues.length; i++) { if (TextUtils.equals(currentValue, mListValues[i])) { Loading @@ -118,6 +118,11 @@ public class BluetoothLeAudioModePreferenceController final ListPreference listPreference = (ListPreference) preference; listPreference.setValue(mListValues[index]); listPreference.setSummary(mListSummaries[index]); if (!mBluetoothAdapter.isEnabled()) { listPreference.setEnabled(false); return; } } /** Loading tests/robotests/src/com/android/settings/development/BluetoothLeAudioModePreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -105,4 +105,16 @@ public class BluetoothLeAudioModePreferenceControllerTest { assertThat(SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]) .equals(mController.mNewMode)).isFalse(); } @Test public void onBluetoothTurnOff_shouldNotChangeLeAudioMode() { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[1]); when(mBluetoothAdapter.isEnabled()) .thenReturn(false); mController.updateState(mPreference); final String mode = SystemProperties .get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]); assertThat(mode.equals(mListValues[1])).isTrue(); } } Loading
src/com/android/settings/development/BluetoothLeAudioModePreferenceController.java +9 −4 Original line number Diff line number Diff line Loading @@ -96,17 +96,17 @@ public class BluetoothLeAudioModePreferenceController return; } String currentValue; if (mBluetoothAdapter.isLeAudioBroadcastSourceSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED) { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "broadcast"); currentValue = "broadcast"; } else if (mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED) { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "unicast"); currentValue = "unicast"; } else { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "disabled"); currentValue = "disabled"; } final String currentValue = SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY); int index = 0; for (int i = 0; i < mListValues.length; i++) { if (TextUtils.equals(currentValue, mListValues[i])) { Loading @@ -118,6 +118,11 @@ public class BluetoothLeAudioModePreferenceController final ListPreference listPreference = (ListPreference) preference; listPreference.setValue(mListValues[index]); listPreference.setSummary(mListSummaries[index]); if (!mBluetoothAdapter.isEnabled()) { listPreference.setEnabled(false); return; } } /** Loading
tests/robotests/src/com/android/settings/development/BluetoothLeAudioModePreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -105,4 +105,16 @@ public class BluetoothLeAudioModePreferenceControllerTest { assertThat(SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]) .equals(mController.mNewMode)).isFalse(); } @Test public void onBluetoothTurnOff_shouldNotChangeLeAudioMode() { SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[1]); when(mBluetoothAdapter.isEnabled()) .thenReturn(false); mController.updateState(mPreference); final String mode = SystemProperties .get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]); assertThat(mode.equals(mListValues[1])).isTrue(); } }