Merge "Update Opus over A2DP to use BluetoothCodecConfig api"
This commit is contained in:
@@ -40,9 +40,8 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
|
|
||||||
private static final String TAG = "AbstractBtDlgCtr";
|
private static final String TAG = "AbstractBtDlgCtr";
|
||||||
|
|
||||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO(b/240635097): remove in U
|
protected static final int[] CODEC_TYPES = {
|
||||||
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS,
|
||||||
protected static final int[] CODEC_TYPES = {SOURCE_CODEC_TYPE_OPUS,
|
|
||||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
|
||||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||||
|
@@ -40,8 +40,6 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
private static final String KEY = "bluetooth_audio_codec_settings";
|
private static final String KEY = "bluetooth_audio_codec_settings";
|
||||||
private static final String TAG = "BtCodecCtr";
|
private static final String TAG = "BtCodecCtr";
|
||||||
|
|
||||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U
|
|
||||||
|
|
||||||
private final Callback mCallback;
|
private final Callback mCallback;
|
||||||
|
|
||||||
public BluetoothCodecDialogPreferenceController(Context context, Lifecycle lifecycle,
|
public BluetoothCodecDialogPreferenceController(Context context, Lifecycle lifecycle,
|
||||||
@@ -125,7 +123,7 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
codecTypeValue = SOURCE_CODEC_TYPE_OPUS; // TODO update in U
|
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS;
|
||||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -190,7 +188,7 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
|
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
|
||||||
index = 5;
|
index = 5;
|
||||||
break;
|
break;
|
||||||
case SOURCE_CODEC_TYPE_OPUS: // TODO update in U
|
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS:
|
||||||
index = 7;
|
index = 7;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -52,8 +52,6 @@ import java.util.List;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class BluetoothCodecDialogPreferenceControllerTest {
|
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";
|
private static final String DEVICE_ADDRESS = "00:11:22:33:44:55";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@@ -123,7 +121,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||||
.build();
|
.build();
|
||||||
mCodecConfigOPUS = new BluetoothCodecConfig.Builder()
|
mCodecConfigOPUS = new BluetoothCodecConfig.Builder()
|
||||||
.setCodecType(SOURCE_CODEC_TYPE_OPUS)
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS)
|
||||||
.build();
|
.build();
|
||||||
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||||
.thenReturn(Arrays.asList(mActiveDevice));
|
.thenReturn(Arrays.asList(mActiveDevice));
|
||||||
@@ -143,8 +141,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
|
||||||
mController.writeConfigurationValues(0);
|
mController.writeConfigurationValues(0);
|
||||||
// TODO(b/240635097): update in U
|
verify(mBluetoothA2dpConfigStore).setCodecType(
|
||||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -176,8 +174,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
||||||
|
|
||||||
mController.writeConfigurationValues(7);
|
mController.writeConfigurationValues(7);
|
||||||
// TODO(b/240635097): update in U
|
verify(mBluetoothA2dpConfigStore).setCodecType(
|
||||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -211,8 +209,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getCurrentIndexByConfig_verifyOpusIndex() {
|
public void getCurrentIndexByConfig_verifyOpusIndex() {
|
||||||
assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo(
|
assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo(
|
||||||
mController.convertCfgToBtnIndex(SOURCE_CODEC_TYPE_OPUS));
|
mController.convertCfgToBtnIndex(
|
||||||
// TODO(b/240635097): update in U
|
BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,7 +237,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
mController.onHDAudioEnabled(/* enabled= */ true);
|
mController.onHDAudioEnabled(/* enabled= */ true);
|
||||||
|
|
||||||
verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
|
verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
|
||||||
eq(SOURCE_CODEC_TYPE_OPUS)); // TODO(b/240635097): update in U
|
eq(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user