Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d78a3aa authored by Omer Osman's avatar Omer Osman Committed by Android (Google) Code Review
Browse files

Merge "Update Opus over A2DP to use BluetoothCodecConfig api"

parents 7ab06294 dc7fdfa0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -40,9 +40,8 @@ public abstract class AbstractBluetoothDialogPreferenceController extends

    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 = {SOURCE_CODEC_TYPE_OPUS,
    protected static final int[] CODEC_TYPES = {
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
+2 −4
Original line number Diff line number Diff line
@@ -40,8 +40,6 @@ public class BluetoothCodecDialogPreferenceController extends
    private static final String KEY = "bluetooth_audio_codec_settings";
    private static final String TAG = "BtCodecCtr";

    private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U

    private final Callback mCallback;

    public BluetoothCodecDialogPreferenceController(Context context, Lifecycle lifecycle,
@@ -125,7 +123,7 @@ public class BluetoothCodecDialogPreferenceController extends
                codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
                break;
            case 7:
                codecTypeValue = SOURCE_CODEC_TYPE_OPUS; // TODO update in U
                codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS;
                codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
                break;
            default:
@@ -190,7 +188,7 @@ public class BluetoothCodecDialogPreferenceController extends
            case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
                index = 5;
                break;
            case SOURCE_CODEC_TYPE_OPUS: // TODO update in U
            case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS:
                index = 7;
                break;
            default:
+8 −10
Original line number Diff line number Diff line
@@ -52,8 +52,6 @@ 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
@@ -123,7 +121,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
                .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
                .build();
        mCodecConfigOPUS = new BluetoothCodecConfig.Builder()
                .setCodecType(SOURCE_CODEC_TYPE_OPUS)
                .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS)
                .build();
        when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
                .thenReturn(Arrays.asList(mActiveDevice));
@@ -143,8 +141,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
        mController.onBluetoothServiceConnected(mBluetoothA2dp);

        mController.writeConfigurationValues(0);
                                                // TODO(b/240635097): update in U
        verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
        verify(mBluetoothA2dpConfigStore).setCodecType(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS);
    }

    @Test
@@ -176,8 +174,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
        verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);

        mController.writeConfigurationValues(7);
                                                // TODO(b/240635097): update in U
        verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
        verify(mBluetoothA2dpConfigStore).setCodecType(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS);
    }

    @Test
@@ -211,8 +209,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
    @Test
    public void getCurrentIndexByConfig_verifyOpusIndex() {
        assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo(
                mController.convertCfgToBtnIndex(SOURCE_CODEC_TYPE_OPUS));
                                             // TODO(b/240635097): update in U
                mController.convertCfgToBtnIndex(
                    BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS));
    }


@@ -239,7 +237,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
        mController.onHDAudioEnabled(/* enabled= */ true);

        verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
                eq(SOURCE_CODEC_TYPE_OPUS)); // TODO(b/240635097): update in U
                eq(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS));
    }

    @Test