Make BluetoothCodecConfig and BluetoothCodecStatus public

Tag: #feature
Bug: 200202780
Test: make RunSettingsRoboTests
Change-Id: I2a81216de050b143cee5c537d899a699d5012330
This commit is contained in:
Etienne Ruffieux
2021-10-07 16:40:15 +00:00
parent 9d0eba50aa
commit e004eaa51b
9 changed files with 139 additions and 103 deletions

View File

@@ -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.
*/
@@ -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;
@@ -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;
@@ -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;
@@ -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];
}
}

View File

@@ -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);
}
@@ -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;
}