Merge "Add support for selection of Opus in Developer Options" into tm-qpr-dev am: cb930bc0ff
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17901372 Change-Id: I5f3658d3d580858c502c8b44ff540723118c2021 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -52,6 +52,8 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
|
||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO(b/240635097): remove in U
|
||||
|
||||
private static final String DEVICE_ADDRESS = "00:11:22:33:44:55";
|
||||
|
||||
@Mock
|
||||
@@ -72,6 +74,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
private BluetoothCodecConfig mCodecConfigAPTX;
|
||||
private BluetoothCodecConfig mCodecConfigAPTXHD;
|
||||
private BluetoothCodecConfig mCodecConfigLDAC;
|
||||
private BluetoothCodecConfig mCodecConfigOPUS;
|
||||
private BluetoothDevice mActiveDevice;
|
||||
private Context mContext;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
@@ -119,13 +122,17 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||
.build();
|
||||
mCodecConfigOPUS = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(SOURCE_CODEC_TYPE_OPUS)
|
||||
.build();
|
||||
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||
.thenReturn(Arrays.asList(mActiveDevice));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC,
|
||||
mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigSBC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -136,13 +143,14 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
mController.writeConfigurationValues(0);
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
|
||||
// TODO(b/240635097): update in U
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_checkCodec() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC,
|
||||
mCodecConfigSBC, mCodecConfigAPTX, mCodecConfigAPTXHD, mCodecConfigLDAC};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigSBC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -167,12 +175,15 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.writeConfigurationValues(5);
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
||||
|
||||
mController.writeConfigurationValues(7);
|
||||
// TODO(b/240635097): update in U
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_resetHighestConfig() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigOPUS};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -197,6 +208,14 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.convertCfgToBtnIndex(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentIndexByConfig_verifyOpusIndex() {
|
||||
assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo(
|
||||
mController.convertCfgToBtnIndex(SOURCE_CODEC_TYPE_OPUS));
|
||||
// TODO(b/240635097): update in U
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void onIndexUpdated_notifyPreference() {
|
||||
mController.onIndexUpdated(0);
|
||||
@@ -204,9 +223,29 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
verify(mCallback).onBluetoothCodecChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsOpus() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigOPUS)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
.build();
|
||||
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(SOURCE_CODEC_TYPE_OPUS)); // TODO(b/240635097): update in U
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
@@ -223,7 +262,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
}
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
|
Reference in New Issue
Block a user