Loading res/layout/bluetooth_audio_codec_dialog.xml +9 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,15 @@ <include android:id="@+id/bluetooth_audio_codec_ldac" layout="@layout/preference_widget_dialog_radiobutton"/> <include android:id="@+id/bluetooth_audio_codec_lc3" layout="@layout/preference_widget_dialog_radiobutton"/> <include android:id="@+id/bluetooth_audio_codec_opus" layout="@layout/preference_widget_dialog_radiobutton"/> </RadioGroup> <include Loading src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,11 @@ public abstract class AbstractBluetoothDialogPreferenceController extends private static final String TAG = "AbstractBtDlgCtr"; protected static final int[] CODEC_TYPES = {BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 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, BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, Loading src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreference.java +2 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ public class BluetoothCodecDialogPreference extends BaseBluetoothDialogPreferenc mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx); mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx_hd); mRadioButtonIds.add(R.id.bluetooth_audio_codec_ldac); mRadioButtonIds.add(R.id.bluetooth_audio_codec_lc3); mRadioButtonIds.add(R.id.bluetooth_audio_codec_opus); String[] stringArray = context.getResources().getStringArray( R.array.bluetooth_a2dp_codec_titles); for (int i = 0; i < stringArray.length; i++) { Loading src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +13 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ 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, Loading Loading @@ -118,6 +120,14 @@ public class BluetoothCodecDialogPreferenceController extends codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC; codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 6: codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3; codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 7: codecTypeValue = SOURCE_CODEC_TYPE_OPUS; // TODO update in U codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; default: break; } Loading Loading @@ -180,6 +190,9 @@ public class BluetoothCodecDialogPreferenceController extends case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC: index = 5; break; case SOURCE_CODEC_TYPE_OPUS: // TODO update in U index = 7; break; default: Log.e(TAG, "Unsupported config:" + config); break; Loading tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java +47 −7 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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)) Loading @@ -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)) Loading @@ -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)) Loading @@ -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); Loading @@ -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) Loading @@ -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) Loading Loading
res/layout/bluetooth_audio_codec_dialog.xml +9 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,15 @@ <include android:id="@+id/bluetooth_audio_codec_ldac" layout="@layout/preference_widget_dialog_radiobutton"/> <include android:id="@+id/bluetooth_audio_codec_lc3" layout="@layout/preference_widget_dialog_radiobutton"/> <include android:id="@+id/bluetooth_audio_codec_opus" layout="@layout/preference_widget_dialog_radiobutton"/> </RadioGroup> <include Loading
src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,11 @@ public abstract class AbstractBluetoothDialogPreferenceController extends private static final String TAG = "AbstractBtDlgCtr"; protected static final int[] CODEC_TYPES = {BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, 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, BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, Loading
src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreference.java +2 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ public class BluetoothCodecDialogPreference extends BaseBluetoothDialogPreferenc mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx); mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx_hd); mRadioButtonIds.add(R.id.bluetooth_audio_codec_ldac); mRadioButtonIds.add(R.id.bluetooth_audio_codec_lc3); mRadioButtonIds.add(R.id.bluetooth_audio_codec_opus); String[] stringArray = context.getResources().getStringArray( R.array.bluetooth_a2dp_codec_titles); for (int i = 0; i < stringArray.length; i++) { Loading
src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +13 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ 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, Loading Loading @@ -118,6 +120,14 @@ public class BluetoothCodecDialogPreferenceController extends codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC; codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 6: codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3; codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; case 7: codecTypeValue = SOURCE_CODEC_TYPE_OPUS; // TODO update in U codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; break; default: break; } Loading Loading @@ -180,6 +190,9 @@ public class BluetoothCodecDialogPreferenceController extends case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC: index = 5; break; case SOURCE_CODEC_TYPE_OPUS: // TODO update in U index = 7; break; default: Log.e(TAG, "Unsupported config:" + config); break; Loading
tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java +47 −7 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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)) Loading @@ -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)) Loading @@ -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)) Loading @@ -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); Loading @@ -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) Loading @@ -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) Loading