Make BluetoothCodecConfig and BluetoothCodecStatus public
Tag: #feature Bug: 200202780 Test: make RunSettingsRoboTests Change-Id: I2a81216de050b143cee5c537d899a699d5012330
This commit is contained in:
@@ -71,10 +71,16 @@ public class BluetoothA2dpConfigStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BluetoothCodecConfig createCodecConfig() {
|
public BluetoothCodecConfig createCodecConfig() {
|
||||||
return new BluetoothCodecConfig(mCodecType, mCodecPriority,
|
return new BluetoothCodecConfig.Builder()
|
||||||
mSampleRate, mBitsPerSample,
|
.setCodecType(mCodecType)
|
||||||
mChannelMode, mCodecSpecific1Value,
|
.setCodecPriority(mCodecPriority)
|
||||||
mCodecSpecific2Value, mCodecSpecific3Value,
|
.setSampleRate(mSampleRate)
|
||||||
mCodecSpecific4Value);
|
.setBitsPerSample(mBitsPerSample)
|
||||||
|
.setChannelMode(mChannelMode)
|
||||||
|
.setCodecSpecific1(mCodecSpecific1Value)
|
||||||
|
.setCodecSpecific2(mCodecSpecific2Value)
|
||||||
|
.setCodecSpecific3(mCodecSpecific3Value)
|
||||||
|
.setCodecSpecific4(mCodecSpecific4Value)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,8 @@ import androidx.preference.Preference;
|
|||||||
import com.android.settings.development.BluetoothA2dpConfigStore;
|
import com.android.settings.development.BluetoothA2dpConfigStore;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for Bluetooth A2DP config dialog controller in developer option.
|
* Abstract class for Bluetooth A2DP config dialog controller in developer option.
|
||||||
*/
|
*/
|
||||||
@@ -170,7 +172,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
*
|
*
|
||||||
* @return Array of {@link BluetoothCodecConfig}.
|
* @return Array of {@link BluetoothCodecConfig}.
|
||||||
*/
|
*/
|
||||||
protected BluetoothCodecConfig[] getSelectableConfigs(BluetoothDevice device) {
|
protected List<BluetoothCodecConfig> getSelectableConfigs(BluetoothDevice device) {
|
||||||
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
|
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
|
||||||
if (bluetoothA2dp == null) {
|
if (bluetoothA2dp == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -198,11 +200,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
Log.d(TAG, "Unable to get selectable config. No active device.");
|
Log.d(TAG, "Unable to get selectable config. No active device.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
|
final List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice);
|
||||||
if (configs == null) {
|
|
||||||
Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (BluetoothCodecConfig config : configs) {
|
for (BluetoothCodecConfig config : configs) {
|
||||||
if (config.getCodecType() == codecTypeValue) {
|
if (config.getCodecType() == codecTypeValue) {
|
||||||
return config;
|
return config;
|
||||||
@@ -220,7 +218,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
public void onHDAudioEnabled(boolean enabled) {}
|
public void onHDAudioEnabled(boolean enabled) {}
|
||||||
|
|
||||||
static int getHighestCodec(BluetoothA2dp bluetoothA2dp, BluetoothDevice activeDevice,
|
static int getHighestCodec(BluetoothA2dp bluetoothA2dp, BluetoothDevice activeDevice,
|
||||||
BluetoothCodecConfig[] configs) {
|
List<BluetoothCodecConfig> configs) {
|
||||||
if (configs == null) {
|
if (configs == null) {
|
||||||
Log.d(TAG, "Unable to get highest codec. Configs are empty");
|
Log.d(TAG, "Unable to get highest codec. Configs are empty");
|
||||||
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID;
|
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID;
|
||||||
@@ -231,8 +229,8 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
|||||||
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC;
|
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < CODEC_TYPES.length; i++) {
|
for (int i = 0; i < CODEC_TYPES.length; i++) {
|
||||||
for (int j = 0; j < configs.length; j++) {
|
for (BluetoothCodecConfig config : configs) {
|
||||||
if ((configs[j].getCodecType() == CODEC_TYPES[i])) {
|
if (config.getCodecType() == CODEC_TYPES[i]) {
|
||||||
return CODEC_TYPES[i];
|
return CODEC_TYPES[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
// Check HD audio is enabled, display the available list.
|
// Check HD audio is enabled, display the available list.
|
||||||
if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
|
if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
|
||||||
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
|
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
|
||||||
BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
|
List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice);
|
||||||
if (configs != null) {
|
if (configs != null) {
|
||||||
return getIndexFromConfig(configs);
|
return getIndexFromConfig(configs);
|
||||||
}
|
}
|
||||||
@@ -153,10 +153,10 @@ public class BluetoothCodecDialogPreferenceController extends
|
|||||||
writeConfigurationValues(/* index= */ 0);
|
writeConfigurationValues(/* index= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getIndexFromConfig(BluetoothCodecConfig[] configs) {
|
private List<Integer> getIndexFromConfig(List<BluetoothCodecConfig> configs) {
|
||||||
List<Integer> indexArray = new ArrayList<>();
|
List<Integer> indexArray = new ArrayList<>();
|
||||||
for (int i = 0; i < configs.length; i++) {
|
for (BluetoothCodecConfig config : configs) {
|
||||||
indexArray.add(convertCfgToBtnIndex(configs[i].getCodecType()));
|
indexArray.add(convertCfgToBtnIndex(config.getCodecType()));
|
||||||
}
|
}
|
||||||
return indexArray;
|
return indexArray;
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -85,8 +86,12 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
mBluetoothA2dpConfigStore));
|
mBluetoothA2dpConfigStore));
|
||||||
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
|
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
|
||||||
|
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
|
.build();
|
||||||
|
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
|
.build();
|
||||||
mCodecConfigs[0] = mCodecConfigAAC;
|
mCodecConfigs[0] = mCodecConfigAAC;
|
||||||
mCodecConfigs[1] = mCodecConfigSBC;
|
mCodecConfigs[1] = mCodecConfigSBC;
|
||||||
|
|
||||||
@@ -160,17 +165,19 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSelectableConfigs_verifyConfig() {
|
public void getSelectableConfigs_verifyConfig() {
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
|
||||||
assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
|
assertThat(mController.getSelectableConfigs(null)).isEqualTo(Arrays.asList(mCodecConfigs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSelectableByCodecType_verifyConfig() {
|
public void getSelectableByCodecType_verifyConfig() {
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
@@ -181,7 +188,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSelectableByCodecType_unavailable() {
|
public void getSelectableByCodecType_unavailable() {
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
@@ -192,7 +200,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
|
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -80,25 +81,23 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
|
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
| BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
.build();
|
||||||
0, 0, 0, 0);
|
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
.build();
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
|
||||||
0, 0, 0, 0);
|
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
|
||||||
@@ -127,7 +126,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSelectableIndex_verifyList() {
|
public void getSelectableIndex_verifyList() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
List<Integer> indexList = new ArrayList<>();
|
List<Integer> indexList = new ArrayList<>();
|
||||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -80,25 +81,23 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothChannelModeDialogPreference(mContext);
|
mPreference = new BluetoothChannelModeDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
.build();
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
0, 0, 0, 0);
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_NONE,
|
.build();
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
|
||||||
0, 0, 0, 0);
|
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
|
||||||
@@ -124,7 +123,8 @@ public class BluetoothChannelModeDialogPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSelectableIndex_verifyList() {
|
public void getSelectableIndex_verifyList() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
List<Integer> indexList = new ArrayList<>();
|
List<Integer> indexList = new ArrayList<>();
|
||||||
|
@@ -45,6 +45,9 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class BluetoothCodecDialogPreferenceControllerTest {
|
public class BluetoothCodecDialogPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -85,29 +88,41 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothCodecDialogPreference(mContext);
|
mPreference = new BluetoothCodecDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_96000 | BluetoothCodecConfig.SAMPLE_RATE_176400,
|
.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_32,
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
| BluetoothCodecConfig.SAMPLE_RATE_176400)
|
||||||
0, 0, 0, 0);
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_32)
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
.setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
|
| BluetoothCodecConfig.CHANNEL_MODE_STEREO)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
.build();
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_STEREO,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
0, 0, 0, 0);
|
.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
|
||||||
mCodecConfigAPTX = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX);
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||||
mCodecConfigAPTXHD = new BluetoothCodecConfig(
|
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD);
|
.setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
|
||||||
mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
| 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();
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
||||||
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
|
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
|
||||||
@@ -121,7 +136,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
public void writeConfigurationValues_checkCodec() {
|
public void writeConfigurationValues_checkCodec() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
|
|
||||||
@@ -148,7 +164,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
public void writeConfigurationValues_resetHighestConfig() {
|
public void writeConfigurationValues_resetHighestConfig() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
mController.writeConfigurationValues(2);
|
mController.writeConfigurationValues(2);
|
||||||
@@ -178,7 +195,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
|
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
||||||
/* codecsLocalCapabilities= */ null,
|
/* codecsLocalCapabilities= */ null,
|
||||||
mCodecConfigs);
|
mCodecConfigs);
|
||||||
@@ -194,7 +211,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
|
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
|
||||||
/* codecsLocalCapabilities= */ null,
|
/* codecsLocalCapabilities= */ null,
|
||||||
mCodecConfigs);
|
mCodecConfigs);
|
||||||
|
@@ -43,6 +43,8 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class BluetoothQualityDialogPreferenceControllerTest {
|
public class BluetoothQualityDialogPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -77,18 +79,16 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothQualityDialogPreference(mContext);
|
mPreference = new BluetoothQualityDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
.build();
|
||||||
0, 0, 0, 0);
|
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||||
mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_96000,
|
.setCodecSpecific1(1001)
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
.build();
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
|
||||||
1001, 0, 0, 0);
|
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_codeTypeIsLDAC_enablePreference() {
|
public void updateState_codeTypeIsLDAC_enablePreference() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
@@ -127,7 +128,8 @@ public class BluetoothQualityDialogPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateState_codeTypeAAC_disablePreference() {
|
public void updateState_codeTypeAAC_disablePreference() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
@@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -81,26 +82,26 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
|||||||
mPreference = new BluetoothSampleRateDialogPreference(mContext);
|
mPreference = new BluetoothSampleRateDialogPreference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
mCodecConfigAAC = new BluetoothCodecConfig.Builder()
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
| BluetoothCodecConfig.SAMPLE_RATE_88200)
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
.build();
|
||||||
0, 0, 0, 0);
|
mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
|
.setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
|
||||||
BluetoothCodecConfig.SAMPLE_RATE_96000,
|
.build();
|
||||||
BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
|
|
||||||
BluetoothCodecConfig.CHANNEL_MODE_NONE,
|
|
||||||
0, 0, 0, 0);
|
|
||||||
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||||
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
|
BluetoothCodecConfig mCodecConfigSBC = new BluetoothCodecConfig.Builder()
|
||||||
|
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
|
||||||
|
.build();
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
|
||||||
|
Arrays.asList(mCodecConfigs));
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||||
@@ -132,7 +133,10 @@ public class BluetoothSampleRateDialogPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSelectableIndex_verifyList() {
|
public void getSelectableIndex_verifyList() {
|
||||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
List<BluetoothCodecConfig> mCodecConfigs = new ArrayList() {{
|
||||||
|
add(mCodecConfigAAC);
|
||||||
|
add(mCodecConfigSBC);
|
||||||
|
}};
|
||||||
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
|
||||||
when(mBluetoothA2dp.getCodecStatus(
|
when(mBluetoothA2dp.getCodecStatus(
|
||||||
mActiveDevice)).thenReturn(mCodecStatus);
|
mActiveDevice)).thenReturn(mCodecStatus);
|
||||||
|
Reference in New Issue
Block a user