Merge "Phone fails to switch channel mode from stereo to mono"

This commit is contained in:
TreeHugger Robot
2021-09-01 09:47:24 +00:00
committed by Android (Google) Code Review
3 changed files with 51 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.development.bluetooth;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -108,6 +109,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -172,4 +175,37 @@ public class BluetoothCodecDialogPreferenceControllerTest {
verify(mCallback).onBluetoothCodecChanged();
}
@Test
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
/* codecsLocalCapabilities= */ null,
mCodecConfigs);
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.onHDAudioEnabled(/* enabled= */ true);
verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
eq(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC));
}
@Test
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
/* codecsLocalCapabilities= */ null,
mCodecConfigs);
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.onHDAudioEnabled(/* enabled= */ false);
verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
eq(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC));
}
}