use of android.bluetooth.BluetoothCodecConfig in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AbstractBluetoothA2dpPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (getCodecConfig(null) == null || mPreference == null) {
// Use current active device
return;
}
BluetoothCodecConfig codecConfig;
synchronized (mBluetoothA2dpConfigStore) {
// Use current active device
codecConfig = getCodecConfig(null);
}
final int index = getCurrentA2dpSettingIndex(codecConfig);
mPreference.setValue(mListValues[index]);
// We only want to append "Streaming" if not using default
if (index == getDefaultIndex()) {
mPreference.setSummary(mListSummaries[index]);
} else {
mPreference.setSummary(mContext.getResources().getString(STREAMING_LABEL_ID, mListSummaries[index]));
}
writeConfigurationValues(mListValues[index]);
}
use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.
the class BluetoothChannelModeDialogPreferenceController method writeConfigurationValues.
@Override
protected void writeConfigurationValues(final int index) {
// default
int channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_NONE;
switch(index) {
case 0:
final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
if (currentConfig != null) {
channelModeValue = getHighestChannelMode(getSelectableByCodecType(currentConfig.getCodecType()));
}
break;
case 1:
channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_MONO;
break;
case 2:
channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_STEREO;
break;
default:
break;
}
mBluetoothA2dpConfigStore.setChannelMode(channelModeValue);
}
use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.
the class BluetoothChannelModeDialogPreferenceController method getSelectableIndex.
@Override
public List<Integer> getSelectableIndex() {
List<Integer> selectableIndex = new ArrayList<>();
selectableIndex.add(getDefaultIndex());
final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
if (currentConfig != null) {
final int configs = getSelectableByCodecType(currentConfig.getCodecType()).getChannelMode();
for (int i = 0; i < CHANNEL_MODES.length; i++) {
if ((configs & CHANNEL_MODES[i]) != 0) {
selectableIndex.add(convertCfgToBtnIndex(CHANNEL_MODES[i]));
}
}
}
return selectableIndex;
}
use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.
the class BluetoothCodecDialogPreferenceController method getSelectableIndex.
@Override
public List<Integer> getSelectableIndex() {
List<Integer> index = new ArrayList<>();
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
index.add(getDefaultIndex());
if (bluetoothA2dp == null) {
return index;
}
final BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
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) {
BluetoothCodecConfig[] 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;
}
use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.
the class BluetoothCodecDialogPreferenceController method writeConfigurationValues.
@Override
protected void writeConfigurationValues(final int index) {
// default
int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC;
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
switch(index) {
case 0:
codecTypeValue = getHighestCodec(getSelectableConfigs(mBluetoothA2dp.getActiveDevice()));
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;
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));
}
Aggregations