Search in sources :

Example 31 with BluetoothCodecConfig

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]);
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Example 32 with BluetoothCodecConfig

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);
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Example 33 with BluetoothCodecConfig

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;
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList)

Example 34 with BluetoothCodecConfig

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;
}
Also used : BluetoothA2dp(android.bluetooth.BluetoothA2dp) BluetoothDevice(android.bluetooth.BluetoothDevice) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList)

Example 35 with BluetoothCodecConfig

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));
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Aggregations

BluetoothCodecConfig (android.bluetooth.BluetoothCodecConfig)45 BluetoothCodecStatus (android.bluetooth.BluetoothCodecStatus)17 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)7 Resources (android.content.res.Resources)6 BluetoothA2dpConfigStore (com.android.settings.development.BluetoothA2dpConfigStore)6 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)6 Before (org.junit.Before)6 BluetoothDevice (android.bluetooth.BluetoothDevice)5 BluetoothA2dp (android.bluetooth.BluetoothA2dp)2