use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.
the class AbstractBluetoothDialogPreferenceController method getSelectableConfigs.
/**
* To get the selectable A2DP configs.
*
* @return Array of {@link BluetoothCodecConfig}.
*/
protected BluetoothCodecConfig[] getSelectableConfigs(BluetoothDevice device) {
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
if (bluetoothA2dp == null) {
return null;
}
BluetoothDevice bluetoothDevice = (device != null) ? device : bluetoothA2dp.getActiveDevice();
if (bluetoothDevice == null) {
return null;
}
final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(bluetoothDevice);
if (codecStatus != null) {
return codecStatus.getCodecsSelectableCapabilities();
}
return null;
}
use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.
the class AbstractBluetoothDialogPreferenceController method getCurrentCodecConfig.
/**
* To get the current A2DP codec config.
*
* @return {@link BluetoothCodecConfig}.
*/
protected BluetoothCodecConfig getCurrentCodecConfig() {
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
if (bluetoothA2dp == null) {
return null;
}
BluetoothDevice activeDevice = bluetoothA2dp.getActiveDevice();
if (activeDevice == null) {
Log.d(TAG, "Unable to get current codec config. No active device.");
return null;
}
final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(activeDevice);
if (codecStatus == null) {
Log.d(TAG, "Unable to get current codec config. Codec status is null");
return null;
}
return codecStatus.getCodecConfig();
}
use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by crdroidandroid.
the class DevelopmentSettings method updateBluetoothA2dpConfigurationValues.
private void updateBluetoothA2dpConfigurationValues() {
int index;
String[] summaries;
BluetoothCodecStatus codecStatus = null;
BluetoothCodecConfig codecConfig = null;
BluetoothCodecConfig[] codecsLocalCapabilities = null;
BluetoothCodecConfig[] codecsSelectableCapabilities = null;
String streaming;
Resources resources = null;
synchronized (mBluetoothA2dpLock) {
if (mBluetoothA2dp != null) {
codecStatus = mBluetoothA2dp.getCodecStatus();
if (codecStatus != null) {
codecConfig = codecStatus.getCodecConfig();
codecsLocalCapabilities = codecStatus.getCodecsLocalCapabilities();
codecsSelectableCapabilities = codecStatus.getCodecsSelectableCapabilities();
}
}
}
if (codecConfig == null) {
return;
}
try {
resources = getResources();
} catch (IllegalStateException e) {
return;
}
if (resources == null) {
return;
}
// Update the Codec Type
index = -1;
switch(codecConfig.getCodecType()) {
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_INVALID:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpCodec != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpCodec.setSummary(streaming);
}
// Update the Sample Rate
index = -1;
switch(codecConfig.getSampleRate()) {
case BluetoothCodecConfig.SAMPLE_RATE_44100:
index = 1;
break;
case BluetoothCodecConfig.SAMPLE_RATE_48000:
index = 2;
break;
case BluetoothCodecConfig.SAMPLE_RATE_88200:
index = 3;
break;
case BluetoothCodecConfig.SAMPLE_RATE_96000:
index = 4;
break;
case BluetoothCodecConfig.SAMPLE_RATE_176400:
case BluetoothCodecConfig.SAMPLE_RATE_192000:
case BluetoothCodecConfig.SAMPLE_RATE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpSampleRate != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpSampleRate.setSummary(streaming);
}
// Update the Bits Per Sample
index = -1;
switch(codecConfig.getBitsPerSample()) {
case BluetoothCodecConfig.BITS_PER_SAMPLE_16:
index = 1;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_24:
index = 2;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_32:
index = 3;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpBitsPerSample != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpBitsPerSample.setSummary(streaming);
}
// Update the Channel Mode
index = -1;
switch(codecConfig.getChannelMode()) {
case BluetoothCodecConfig.CHANNEL_MODE_MONO:
index = 1;
break;
case BluetoothCodecConfig.CHANNEL_MODE_STEREO:
index = 2;
break;
case BluetoothCodecConfig.CHANNEL_MODE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpChannelMode != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpChannelMode.setSummary(streaming);
}
// Update the LDAC Playback Quality
// The actual values are 0, 1, 2 - those are extracted
// as mod-10 remainders of a larger value.
// The reason is because within BluetoothCodecConfig we cannot use
// a codec-specific value of zero.
index = (int) codecConfig.getCodecSpecific1();
if (index > 0) {
index %= 10;
} else {
index = -1;
}
switch(index) {
case 0:
case 1:
case 2:
case 3:
break;
default:
index = -1;
break;
}
if (index >= 0 && mBluetoothSelectA2dpLdacPlaybackQuality != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(streaming);
}
}
use of android.bluetooth.BluetoothCodecStatus in project platform_packages_apps_Settings by BlissRoms.
the class DevelopmentSettings method updateBluetoothA2dpConfigurationValues.
private void updateBluetoothA2dpConfigurationValues() {
int index;
String[] summaries;
BluetoothCodecStatus codecStatus = null;
BluetoothCodecConfig codecConfig = null;
BluetoothCodecConfig[] codecsLocalCapabilities = null;
BluetoothCodecConfig[] codecsSelectableCapabilities = null;
String streaming;
Resources resources = null;
synchronized (mBluetoothA2dpLock) {
if (mBluetoothA2dp != null) {
codecStatus = mBluetoothA2dp.getCodecStatus();
if (codecStatus != null) {
codecConfig = codecStatus.getCodecConfig();
codecsLocalCapabilities = codecStatus.getCodecsLocalCapabilities();
codecsSelectableCapabilities = codecStatus.getCodecsSelectableCapabilities();
}
}
}
if (codecConfig == null) {
return;
}
try {
resources = getResources();
} catch (IllegalStateException e) {
return;
}
if (resources == null) {
return;
}
// Update the Codec Type
index = -1;
switch(codecConfig.getCodecType()) {
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_INVALID:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpCodec != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpCodec.setSummary(streaming);
}
// Update the Sample Rate
index = -1;
switch(codecConfig.getSampleRate()) {
case BluetoothCodecConfig.SAMPLE_RATE_44100:
index = 1;
break;
case BluetoothCodecConfig.SAMPLE_RATE_48000:
index = 2;
break;
case BluetoothCodecConfig.SAMPLE_RATE_88200:
index = 3;
break;
case BluetoothCodecConfig.SAMPLE_RATE_96000:
index = 4;
break;
case BluetoothCodecConfig.SAMPLE_RATE_176400:
case BluetoothCodecConfig.SAMPLE_RATE_192000:
case BluetoothCodecConfig.SAMPLE_RATE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpSampleRate != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpSampleRate.setSummary(streaming);
}
// Update the Bits Per Sample
index = -1;
switch(codecConfig.getBitsPerSample()) {
case BluetoothCodecConfig.BITS_PER_SAMPLE_16:
index = 1;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_24:
index = 2;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_32:
index = 3;
break;
case BluetoothCodecConfig.BITS_PER_SAMPLE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpBitsPerSample != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpBitsPerSample.setSummary(streaming);
}
// Update the Channel Mode
index = -1;
switch(codecConfig.getChannelMode()) {
case BluetoothCodecConfig.CHANNEL_MODE_MONO:
index = 1;
break;
case BluetoothCodecConfig.CHANNEL_MODE_STEREO:
index = 2;
break;
case BluetoothCodecConfig.CHANNEL_MODE_NONE:
default:
break;
}
if (index >= 0 && mBluetoothSelectA2dpChannelMode != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpChannelMode.setSummary(streaming);
}
// Update the LDAC Playback Quality
// The actual values are 0, 1, 2 - those are extracted
// as mod-10 remainders of a larger value.
// The reason is because within BluetoothCodecConfig we cannot use
// a codec-specific value of zero.
index = (int) codecConfig.getCodecSpecific1();
if (index > 0) {
index %= 10;
} else {
index = -1;
}
switch(index) {
case 0:
case 1:
case 2:
case 3:
break;
default:
index = -1;
break;
}
if (index >= 0 && mBluetoothSelectA2dpLdacPlaybackQuality != null) {
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(streaming);
}
}
use of android.bluetooth.BluetoothCodecStatus in project android_packages_apps_Settings by omnirom.
the class BluetoothQualityDialogPreferenceControllerTest method updateState_codeTypeAAC_disablePreference.
@Test
public void updateState_codeTypeAAC_disablePreference() {
BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigLDAC };
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isFalse();
}
Aggregations