diff --git a/aconfig/development/settings_core_flag_declarations.aconfig b/aconfig/development/settings_core_flag_declarations.aconfig index fec67f6b782..b73b0268009 100644 --- a/aconfig/development/settings_core_flag_declarations.aconfig +++ b/aconfig/development/settings_core_flag_declarations.aconfig @@ -1,13 +1,6 @@ package: "com.android.settings.development" container: "system" -flag { - name: "a2dp_offload_codec_extensibility_settings" - namespace: "bluetooth" - description: "Feature flag for Bluetooth Audio Codec extensibility in Settings" - bug: "323319530" -} - flag { name: "deprecate_list_activity" namespace: "android_settings" diff --git a/res/layout/bluetooth_audio_codec_dialog.xml b/res/layout/bluetooth_audio_codec_dialog.xml deleted file mode 100644 index 3a260a655e7..00000000000 --- a/res/layout/bluetooth_audio_codec_dialog.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index 28492380f32..6ac175d85bd 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -434,14 +434,6 @@ android:key="bluetooth_hd_audio_settings" android:title="@string/bluetooth_profile_a2dp_high_quality_unknown_codec"/> - - getSelectableIndex() { - List index = new ArrayList<>(); - final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp; - - index.add(getDefaultIndex()); - if (bluetoothA2dp == null) { - return index; - } - final BluetoothDevice activeDevice = getA2dpActiveDevice(); - if (activeDevice == null) { - Log.d(TAG, "Unable to get selectable index. No Active Bluetooth device"); - return index; - } - // Check HD audio is enabled, display the available list. - if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) - == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) { - List configs = getSelectableConfigs(activeDevice); - if (configs != null) { - return getIndexFromConfig(configs); - } - } - // If HD audio is disabled, SBC is the only one available codec. - index.add(convertCfgToBtnIndex(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)); - return index; - } - - @Override - protected void writeConfigurationValues(final int index) { - int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; // default - int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; - switch (index) { - case 0: - final BluetoothDevice activeDevice = getA2dpActiveDevice(); - codecTypeValue = getHighestCodec(mBluetoothA2dp, activeDevice, - getSelectableConfigs(activeDevice)); - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - case 1: - codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - case 2: - codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC; - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - case 3: - codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX; - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - case 4: - codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD; - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - case 5: - 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 = BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS; - codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; - break; - default: - break; - } - mBluetoothA2dpConfigStore.setCodecType(codecTypeValue); - mBluetoothA2dpConfigStore.setCodecPriority(codecPriorityValue); - - // Once user changes codec, to reset configs with highest quality. - final BluetoothCodecConfig config = getSelectableByCodecType(codecTypeValue); - if (config == null) { - Log.d(TAG, "Selectable config is null. Unable to reset"); - } - mBluetoothA2dpConfigStore.setSampleRate(getHighestSampleRate(config)); - mBluetoothA2dpConfigStore.setBitsPerSample(getHighestBitsPerSample(config)); - mBluetoothA2dpConfigStore.setChannelMode(getHighestChannelMode(config)); - } - - @Override - protected int getCurrentIndexByConfig(BluetoothCodecConfig config) { - if (config == null) { - Log.e(TAG, "Unable to get current config index. Config is null."); - } - return convertCfgToBtnIndex(config.getCodecType()); - } - - @Override - public void onIndexUpdated(int index) { - super.onIndexUpdated(index); - mCallback.onBluetoothCodecChanged(); - } - - @Override - public void onHDAudioEnabled(boolean enabled) { - writeConfigurationValues(/* index= */ 0); - } - - private List getIndexFromConfig(List configs) { - List indexArray = new ArrayList<>(); - for (BluetoothCodecConfig config : configs) { - indexArray.add(convertCfgToBtnIndex(config.getCodecType())); - } - return indexArray; - } - - @VisibleForTesting - int convertCfgToBtnIndex(int config) { - int index = getDefaultIndex(); - switch (config) { - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC: - index = 1; - break; - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC: - index = 2; - break; - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX: - index = 3; - break; - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD: - index = 4; - break; - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC: - index = 5; - break; - case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS: - index = 7; - break; - default: - Log.e(TAG, "Unsupported config:" + config); - break; - } - return index; - } -} diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java index 72da5053a69..11ed93cbd46 100644 --- a/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java +++ b/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceController.java @@ -32,7 +32,6 @@ import androidx.preference.PreferenceScreen; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.development.BluetoothA2dpConfigStore; -import com.android.settings.development.Flags; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.ArrayList; @@ -62,9 +61,7 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre @Override public boolean isAvailable() { - boolean available = Flags.a2dpOffloadCodecExtensibilitySettings(); - Log.d(TAG, "isAvailable: " + available); - return available; + return true; } @Override @@ -80,10 +77,6 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre @Override public boolean onPreferenceChange(@Nullable Preference preference, @NonNull Object newValue) { - if (!Flags.a2dpOffloadCodecExtensibilitySettings()) { - return false; - } - if (mListPreference == null) { Log.e(TAG, "onPreferenceChange: List preference is null"); return false; @@ -115,7 +108,7 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre } BluetoothCodecConfig codecConfig = - mBluetoothA2dpConfigStore.createCodecConfigFromCodecType(); + mBluetoothA2dpConfigStore.createCodecConfig(); Log.d(TAG, "onPreferenceChange: setCodecConfigPreference: " + codecConfig.toString()); bluetoothA2dp.setCodecConfigPreference(activeDevice, codecConfig); if (mCallback != null) { @@ -128,9 +121,6 @@ public class BluetoothCodecListPreferenceController extends AbstractBluetoothPre @Override public void updateState(@Nullable Preference preference) { super.updateState(preference); - if (!Flags.a2dpOffloadCodecExtensibilitySettings()) { - return; - } if (!isHDAudioEnabled()) { Log.d(TAG, "updateState: HD Audio is disabled"); diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java index 42b889cfa1a..9825c994374 100644 --- a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java @@ -220,7 +220,7 @@ public class AbstractBluetoothDialogPreferenceControllerTest { mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); - verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType()); + verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getExtendedCodecType()); verify(mBluetoothA2dpConfigStore).setSampleRate(mCodecConfigAAC.getSampleRate()); verify(mBluetoothA2dpConfigStore).setBitsPerSample(mCodecConfigAAC.getBitsPerSample()); verify(mBluetoothA2dpConfigStore).setChannelMode(mCodecConfigAAC.getChannelMode()); diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java deleted file mode 100644 index de2b363ed9b..00000000000 --- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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; - -import android.bluetooth.BluetoothA2dp; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothCodecConfig; -import android.bluetooth.BluetoothCodecStatus; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothProfile; -import android.content.Context; - -import androidx.lifecycle.LifecycleOwner; -import androidx.preference.PreferenceScreen; - -import com.android.settings.development.BluetoothA2dpConfigStore; -import com.android.settingslib.core.lifecycle.Lifecycle; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -import java.util.Arrays; -import java.util.List; - -@RunWith(RobolectricTestRunner.class) -public class BluetoothCodecDialogPreferenceControllerTest { - - private static final String DEVICE_ADDRESS = "00:11:22:33:44:55"; - - @Mock - private BluetoothA2dp mBluetoothA2dp; - @Mock - private BluetoothAdapter mBluetoothAdapter; - @Mock - private PreferenceScreen mScreen; - @Mock - private AbstractBluetoothPreferenceController.Callback mCallback; - - private BluetoothCodecDialogPreferenceController mController; - private BluetoothCodecDialogPreference mPreference; - private BluetoothA2dpConfigStore mBluetoothA2dpConfigStore; - private BluetoothCodecStatus mCodecStatus; - private BluetoothCodecConfig mCodecConfigAAC; - private BluetoothCodecConfig mCodecConfigSBC; - private BluetoothCodecConfig mCodecConfigAPTX; - private BluetoothCodecConfig mCodecConfigAPTXHD; - private BluetoothCodecConfig mCodecConfigLDAC; - private BluetoothCodecConfig mCodecConfigOPUS; - private BluetoothDevice mActiveDevice; - private Context mContext; - private LifecycleOwner mLifecycleOwner; - private Lifecycle mLifecycle; - - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - mContext = RuntimeEnvironment.application; - mLifecycleOwner = () -> mLifecycle; - mLifecycle = new Lifecycle(mLifecycleOwner); - mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore()); - mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS); - mController = new BluetoothCodecDialogPreferenceController(mContext, mLifecycle, - mBluetoothA2dpConfigStore, mCallback); - mController.mBluetoothAdapter = mBluetoothAdapter; - mPreference = new BluetoothCodecDialogPreference(mContext); - when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); - mController.displayPreference(mScreen); - mCodecConfigSBC = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) - .setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST) - .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000 - | BluetoothCodecConfig.SAMPLE_RATE_176400) - .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_32) - .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO - | BluetoothCodecConfig.CHANNEL_MODE_STEREO) - .build(); - mCodecConfigAAC = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) - .setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST) - .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000 - | BluetoothCodecConfig.SAMPLE_RATE_88200) - .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16 - | BluetoothCodecConfig.BITS_PER_SAMPLE_24) - .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO) - .build(); - mCodecConfigAPTX = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX) - .build(); - mCodecConfigAPTXHD = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD) - .build(); - mCodecConfigLDAC = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) - .build(); - mCodecConfigOPUS = new BluetoothCodecConfig.Builder() - .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS) - .build(); - when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP))) - .thenReturn(Arrays.asList(mActiveDevice)); - } - - @Test - public void writeConfigurationValues_selectDefault_setHighest() { - BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC, - mCodecConfigSBC}; - mCodecStatus = new BluetoothCodecStatus.Builder() - .setCodecConfig(mCodecConfigSBC) - .setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs)) - .build(); - when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); - when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn( - BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED); - mController.onBluetoothServiceConnected(mBluetoothA2dp); - - mController.writeConfigurationValues(0); - verify(mBluetoothA2dpConfigStore).setCodecType( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS); - } - - @Test - public void writeConfigurationValues_checkCodec() { - BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC, - mCodecConfigSBC, mCodecConfigAPTX, mCodecConfigAPTXHD, mCodecConfigLDAC}; - mCodecStatus = new BluetoothCodecStatus.Builder() - .setCodecConfig(mCodecConfigSBC) - .setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs)) - .build(); - when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); - mController.onBluetoothServiceConnected(mBluetoothA2dp); - - mController.writeConfigurationValues(1); - verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC); - - mController.writeConfigurationValues(2); - verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC); - - mController.writeConfigurationValues(3); - verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX); - - mController.writeConfigurationValues(4); - verify(mBluetoothA2dpConfigStore).setCodecType( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD); - - mController.writeConfigurationValues(5); - verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC); - - mController.writeConfigurationValues(7); - verify(mBluetoothA2dpConfigStore).setCodecType( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS); - } - - @Test - public void writeConfigurationValues_resetHighestConfig() { - BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX, - mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigOPUS}; - mCodecStatus = new BluetoothCodecStatus.Builder() - .setCodecConfig(mCodecConfigAAC) - .setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs)) - .build(); - when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); - mController.onBluetoothServiceConnected(mBluetoothA2dp); - mController.writeConfigurationValues(2); - - verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecPriority( - BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST); - verify(mBluetoothA2dpConfigStore, atLeastOnce()).setSampleRate( - BluetoothCodecConfig.SAMPLE_RATE_88200); - verify(mBluetoothA2dpConfigStore, atLeastOnce()).setBitsPerSample( - BluetoothCodecConfig.BITS_PER_SAMPLE_24); - verify(mBluetoothA2dpConfigStore, atLeastOnce()).setChannelMode( - BluetoothCodecConfig.CHANNEL_MODE_STEREO); - } - - @Test - public void getCurrentIndexByConfig_verifyIndex() { - assertThat(mController.getCurrentIndexByConfig(mCodecConfigAAC)).isEqualTo( - mController.convertCfgToBtnIndex(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)); - } - - @Test - public void getCurrentIndexByConfig_verifyOpusIndex() { - assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo( - mController.convertCfgToBtnIndex( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS)); - } - - - @Test - public void onIndexUpdated_notifyPreference() { - mController.onIndexUpdated(0); - - verify(mCallback).onBluetoothCodecChanged(); - } - - @Test - public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsOpus() { - List 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(BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS)); - } - - @Test - public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() { - List mCodecConfigs = Arrays.asList(mCodecConfigOPUS, - mCodecConfigAAC, mCodecConfigSBC); - mCodecStatus = new BluetoothCodecStatus.Builder() - .setCodecConfig(mCodecConfigAAC) - .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(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)); - } - @Test - public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() { - List mCodecConfigs = Arrays.asList(mCodecConfigOPUS, - mCodecConfigAAC, mCodecConfigSBC); - mCodecStatus = new BluetoothCodecStatus.Builder() - .setCodecConfig(mCodecConfigAAC) - .setCodecsSelectableCapabilities(mCodecConfigs) - .build(); - 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)); - } -} diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceTest.java deleted file mode 100644 index 4b8df164fe6..00000000000 --- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.development.bluetooth; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; - -import com.android.settings.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -@RunWith(RobolectricTestRunner.class) -public class BluetoothCodecDialogPreferenceTest { - - private BluetoothCodecDialogPreference mPreference; - private Context mContext; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - mContext = RuntimeEnvironment.application; - mPreference = new BluetoothCodecDialogPreference(mContext); - } - - @Test - public void getRadioButtonGroupId() { - assertThat(mPreference.getRadioButtonGroupId()) - .isEqualTo(R.id.bluetooth_audio_codec_radio_group); - } -} diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java index 4ac5dff1eef..a99dc2b1f55 100644 --- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecListPreferenceControllerTest.java @@ -18,7 +18,6 @@ package com.android.settings.development.bluetooth; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.atLeastOnce; @@ -35,14 +34,12 @@ import android.bluetooth.BluetoothCodecType; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.content.Context; -import android.platform.test.annotations.EnableFlags; import androidx.lifecycle.LifecycleOwner; import androidx.preference.ListPreference; import androidx.preference.PreferenceScreen; import com.android.settings.development.BluetoothA2dpConfigStore; -import com.android.settings.development.Flags; import com.android.settingslib.core.lifecycle.Lifecycle; import org.junit.Before; @@ -73,6 +70,7 @@ public class BluetoothCodecListPreferenceControllerTest { private BluetoothCodecType mCodecTypeAAC; private BluetoothCodecType mCodecTypeSBC; private BluetoothCodecType mCodecTypeAPTX; + private BluetoothCodecType mCodecTypeAPTXHD; private BluetoothCodecType mCodecTypeLDAC; private BluetoothCodecType mCodecTypeOPUS; private List mCodecTypes; @@ -114,6 +112,8 @@ public class BluetoothCodecListPreferenceControllerTest { BluetoothCodecType.createFromType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC); mCodecTypeAPTX = BluetoothCodecType.createFromType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX); + mCodecTypeAPTXHD = + BluetoothCodecType.createFromType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD); mCodecTypeLDAC = BluetoothCodecType.createFromType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC); mCodecTypeOPUS = @@ -125,6 +125,7 @@ public class BluetoothCodecListPreferenceControllerTest { mCodecTypeSBC, mCodecTypeAAC, mCodecTypeAPTX, + mCodecTypeAPTXHD, mCodecTypeLDAC, mCodecTypeOPUS)); @@ -212,6 +213,11 @@ public class BluetoothCodecListPreferenceControllerTest { mController.writeConfigurationValues(String.valueOf(mCodecTypeAPTX.getCodecId()))); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecTypeAPTX); + assertTrue( + mController.writeConfigurationValues(String.valueOf( + mCodecTypeAPTXHD.getCodecId()))); + verify(mBluetoothA2dpConfigStore).setCodecType(mCodecTypeAPTXHD); + assertTrue( mController.writeConfigurationValues(String.valueOf(mCodecTypeLDAC.getCodecId()))); verify(mBluetoothA2dpConfigStore).setCodecType(mCodecTypeLDAC); @@ -244,7 +250,6 @@ public class BluetoothCodecListPreferenceControllerTest { } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void onPreferenceChange_notifyPreference() { assertFalse( mController.onPreferenceChange( @@ -271,7 +276,6 @@ public class BluetoothCodecListPreferenceControllerTest { } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void onPreferenceChange_listPreferenceIsNull() { when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(null); assertFalse( @@ -280,13 +284,11 @@ public class BluetoothCodecListPreferenceControllerTest { } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void onPreferenceChange_unknownCodecId() { assertFalse(mController.onPreferenceChange(mPreference, String.valueOf(TEST_ENTRY_VALUE))); } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void onPreferenceChange_codecSelection() { when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)) @@ -325,6 +327,14 @@ public class BluetoothCodecListPreferenceControllerTest { assertTrue( mController.onPreferenceChange( mPreference, String.valueOf(mCodecTypeAPTX.getCodecId()))); + mCodecStatus = + new BluetoothCodecStatus.Builder() + .setCodecConfig(mCodecConfigAPTXHD) + .setCodecsSelectableCapabilities(mCodecConfigs) + .build(); + assertTrue( + mController.onPreferenceChange( + mPreference, String.valueOf(mCodecTypeAPTXHD.getCodecId()))); mCodecStatus = new BluetoothCodecStatus.Builder() .setCodecConfig(mCodecConfigOPUS) @@ -336,7 +346,6 @@ public class BluetoothCodecListPreferenceControllerTest { } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void updateState_notifyPreference() { assertFalse( mController.onPreferenceChange( @@ -437,7 +446,6 @@ public class BluetoothCodecListPreferenceControllerTest { } @Test - @EnableFlags(Flags.FLAG_A2DP_OFFLOAD_CODEC_EXTENSIBILITY_SETTINGS) public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus.Builder()