Loading src/com/android/settings/development/BluetoothA2dpConfigStore.java +11 −5 Original line number Diff line number Diff line Loading @@ -71,10 +71,16 @@ public class BluetoothA2dpConfigStore { } public BluetoothCodecConfig createCodecConfig() { return new BluetoothCodecConfig(mCodecType, mCodecPriority, mSampleRate, mBitsPerSample, mChannelMode, mCodecSpecific1Value, mCodecSpecific2Value, mCodecSpecific3Value, mCodecSpecific4Value); return new BluetoothCodecConfig.Builder() .setCodecType(mCodecType) .setCodecPriority(mCodecPriority) .setSampleRate(mSampleRate) .setBitsPerSample(mBitsPerSample) .setChannelMode(mChannelMode) .setCodecSpecific1(mCodecSpecific1Value) .setCodecSpecific2(mCodecSpecific2Value) .setCodecSpecific3(mCodecSpecific3Value) .setCodecSpecific4(mCodecSpecific4Value) .build(); } } src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +7 −9 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import androidx.preference.Preference; import com.android.settings.development.BluetoothA2dpConfigStore; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.List; /** * Abstract class for Bluetooth A2DP config dialog controller in developer option. */ Loading Loading @@ -170,7 +172,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends * * @return Array of {@link BluetoothCodecConfig}. */ protected BluetoothCodecConfig[] getSelectableConfigs(BluetoothDevice device) { protected List<BluetoothCodecConfig> getSelectableConfigs(BluetoothDevice device) { final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp; if (bluetoothA2dp == null) { return null; Loading Loading @@ -198,11 +200,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends Log.d(TAG, "Unable to get selectable config. No active device."); return null; } final BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice); if (configs == null) { Log.d(TAG, "Unable to get selectable config. Selectable configs is empty."); return null; } final List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice); for (BluetoothCodecConfig config : configs) { if (config.getCodecType() == codecTypeValue) { return config; Loading @@ -220,7 +218,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends public void onHDAudioEnabled(boolean enabled) {} static int getHighestCodec(BluetoothA2dp bluetoothA2dp, BluetoothDevice activeDevice, BluetoothCodecConfig[] configs) { List<BluetoothCodecConfig> configs) { if (configs == null) { Log.d(TAG, "Unable to get highest codec. Configs are empty"); return BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID; Loading @@ -231,8 +229,8 @@ public abstract class AbstractBluetoothDialogPreferenceController extends return BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; } for (int i = 0; i < CODEC_TYPES.length; i++) { for (int j = 0; j < configs.length; j++) { if ((configs[j].getCodecType() == CODEC_TYPES[i])) { for (BluetoothCodecConfig config : configs) { if (config.getCodecType() == CODEC_TYPES[i]) { return CODEC_TYPES[i]; } } Loading src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +4 −4 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class BluetoothCodecDialogPreferenceController extends // Check HD audio is enabled, display the available list. if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) { BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice); List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice); if (configs != null) { return getIndexFromConfig(configs); } Loading Loading @@ -153,10 +153,10 @@ public class BluetoothCodecDialogPreferenceController extends writeConfigurationValues(/* index= */ 0); } private List<Integer> getIndexFromConfig(BluetoothCodecConfig[] configs) { private List<Integer> getIndexFromConfig(List<BluetoothCodecConfig> configs) { List<Integer> indexArray = new ArrayList<>(); for (int i = 0; i < configs.length; i++) { indexArray.add(convertCfgToBtnIndex(configs[i].getCodecType())); for (BluetoothCodecConfig config : configs) { indexArray.add(convertCfgToBtnIndex(config.getCodecType())); } return indexArray; } Loading tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +16 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -85,8 +86,12 @@ public class AbstractBluetoothDialogPreferenceControllerTest { mBluetoothA2dpConfigStore)); mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext)); mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC); mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC); mCodecConfigAAC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) .build(); mCodecConfigSBC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) .build(); mCodecConfigs[0] = mCodecConfigAAC; mCodecConfigs[1] = mCodecConfigSBC; Loading Loading @@ -160,17 +165,19 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableConfigs_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); assertThat(mController.getSelectableConfigs(null)).isEqualTo(Arrays.asList(mCodecConfigs)); } @Test public void getSelectableByCodecType_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading @@ -181,7 +188,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading @@ -192,7 +200,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java +14 −14 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -80,25 +81,23 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest { mPreference = new BluetoothBitPerSampleDialogPreference(mContext); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); mController.displayPreference(mScreen); mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_NONE, BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24, BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0); mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_NONE, BluetoothCodecConfig.BITS_PER_SAMPLE_24, BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0); mCodecConfigAAC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24) .build(); mCodecConfigSBC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24) .build(); when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice); } @Test public void writeConfigurationValues_selectDefault_setHighest() { BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading Loading @@ -127,7 +126,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest { @Test public void getSelectableIndex_verifyList() { BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); List<Integer> indexList = new ArrayList<>(); Loading Loading
src/com/android/settings/development/BluetoothA2dpConfigStore.java +11 −5 Original line number Diff line number Diff line Loading @@ -71,10 +71,16 @@ public class BluetoothA2dpConfigStore { } public BluetoothCodecConfig createCodecConfig() { return new BluetoothCodecConfig(mCodecType, mCodecPriority, mSampleRate, mBitsPerSample, mChannelMode, mCodecSpecific1Value, mCodecSpecific2Value, mCodecSpecific3Value, mCodecSpecific4Value); return new BluetoothCodecConfig.Builder() .setCodecType(mCodecType) .setCodecPriority(mCodecPriority) .setSampleRate(mSampleRate) .setBitsPerSample(mBitsPerSample) .setChannelMode(mChannelMode) .setCodecSpecific1(mCodecSpecific1Value) .setCodecSpecific2(mCodecSpecific2Value) .setCodecSpecific3(mCodecSpecific3Value) .setCodecSpecific4(mCodecSpecific4Value) .build(); } }
src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java +7 −9 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import androidx.preference.Preference; import com.android.settings.development.BluetoothA2dpConfigStore; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.List; /** * Abstract class for Bluetooth A2DP config dialog controller in developer option. */ Loading Loading @@ -170,7 +172,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends * * @return Array of {@link BluetoothCodecConfig}. */ protected BluetoothCodecConfig[] getSelectableConfigs(BluetoothDevice device) { protected List<BluetoothCodecConfig> getSelectableConfigs(BluetoothDevice device) { final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp; if (bluetoothA2dp == null) { return null; Loading Loading @@ -198,11 +200,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends Log.d(TAG, "Unable to get selectable config. No active device."); return null; } final BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice); if (configs == null) { Log.d(TAG, "Unable to get selectable config. Selectable configs is empty."); return null; } final List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice); for (BluetoothCodecConfig config : configs) { if (config.getCodecType() == codecTypeValue) { return config; Loading @@ -220,7 +218,7 @@ public abstract class AbstractBluetoothDialogPreferenceController extends public void onHDAudioEnabled(boolean enabled) {} static int getHighestCodec(BluetoothA2dp bluetoothA2dp, BluetoothDevice activeDevice, BluetoothCodecConfig[] configs) { List<BluetoothCodecConfig> configs) { if (configs == null) { Log.d(TAG, "Unable to get highest codec. Configs are empty"); return BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID; Loading @@ -231,8 +229,8 @@ public abstract class AbstractBluetoothDialogPreferenceController extends return BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; } for (int i = 0; i < CODEC_TYPES.length; i++) { for (int j = 0; j < configs.length; j++) { if ((configs[j].getCodecType() == CODEC_TYPES[i])) { for (BluetoothCodecConfig config : configs) { if (config.getCodecType() == CODEC_TYPES[i]) { return CODEC_TYPES[i]; } } Loading
src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java +4 −4 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class BluetoothCodecDialogPreferenceController extends // Check HD audio is enabled, display the available list. if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice) == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) { BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice); List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice); if (configs != null) { return getIndexFromConfig(configs); } Loading Loading @@ -153,10 +153,10 @@ public class BluetoothCodecDialogPreferenceController extends writeConfigurationValues(/* index= */ 0); } private List<Integer> getIndexFromConfig(BluetoothCodecConfig[] configs) { private List<Integer> getIndexFromConfig(List<BluetoothCodecConfig> configs) { List<Integer> indexArray = new ArrayList<>(); for (int i = 0; i < configs.length; i++) { indexArray.add(convertCfgToBtnIndex(configs[i].getCodecType())); for (BluetoothCodecConfig config : configs) { indexArray.add(convertCfgToBtnIndex(config.getCodecType())); } return indexArray; } Loading
tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java +16 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -85,8 +86,12 @@ public class AbstractBluetoothDialogPreferenceControllerTest { mBluetoothA2dpConfigStore)); mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext)); mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC); mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC); mCodecConfigAAC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) .build(); mCodecConfigSBC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) .build(); mCodecConfigs[0] = mCodecConfigAAC; mCodecConfigs[1] = mCodecConfigSBC; Loading Loading @@ -160,17 +165,19 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableConfigs_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs); assertThat(mController.getSelectableConfigs(null)).isEqualTo(Arrays.asList(mCodecConfigs)); } @Test public void getSelectableByCodecType_verifyConfig() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading @@ -181,7 +188,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void getSelectableByCodecType_unavailable() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading @@ -192,7 +200,8 @@ public class AbstractBluetoothDialogPreferenceControllerTest { @Test public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() { mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus( mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading
tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java +14 −14 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @RunWith(RobolectricTestRunner.class) Loading Loading @@ -80,25 +81,23 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest { mPreference = new BluetoothBitPerSampleDialogPreference(mContext); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); mController.displayPreference(mScreen); mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_NONE, BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24, BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0); mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_NONE, BluetoothCodecConfig.BITS_PER_SAMPLE_24, BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0); mCodecConfigAAC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24) .build(); mCodecConfigSBC = new BluetoothCodecConfig.Builder() .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24) .build(); when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice); } @Test public void writeConfigurationValues_selectDefault_setHighest() { BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); Loading Loading @@ -127,7 +126,8 @@ public class BluetoothBitPerSampleDialogPreferenceControllerTest { @Test public void getSelectableIndex_verifyList() { BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC}; mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs); mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, Arrays.asList(mCodecConfigs)); when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); mController.onBluetoothServiceConnected(mBluetoothA2dp); List<Integer> indexList = new ArrayList<>(); Loading