Search in sources :

Example 11 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.

the class BluetoothCodecDialogPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
    mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
    mController = new BluetoothCodecDialogPreferenceController(mContext, mLifecycle, mBluetoothA2dpConfigStore, mCallback);
    mPreference = new BluetoothCodecDialogPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mController.displayPreference(mScreen);
    mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST, BluetoothCodecConfig.SAMPLE_RATE_96000 | BluetoothCodecConfig.SAMPLE_RATE_176400, BluetoothCodecConfig.BITS_PER_SAMPLE_32, BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO, 0, 0, 0, 0);
    mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST, BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200, BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24, BluetoothCodecConfig.CHANNEL_MODE_STEREO, 0, 0, 0, 0);
    mCodecConfigAPTX = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX);
    mCodecConfigAPTXHD = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD);
    mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
    when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
Also used : BluetoothA2dpConfigStore(com.android.settings.development.BluetoothA2dpConfigStore) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Before(org.junit.Before)

Example 12 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.

the class AbstractBluetoothDialogPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
    mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
    mController = spy(new AbstractBluetoothDialogPreferenceControllerImpl(mContext, mLifecycle, mBluetoothA2dpConfigStore));
    mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
    mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
    mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
    mCodecConfigs[0] = mCodecConfigAAC;
    mCodecConfigs[1] = mCodecConfigSBC;
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mController.displayPreference(mScreen);
    mCurrentConfig = mController.getCurrentConfigIndex();
    when(mPreference.generateSummary(mCurrentConfig)).thenReturn(SUMMARY);
    when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
Also used : BluetoothA2dpConfigStore(com.android.settings.development.BluetoothA2dpConfigStore) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Before(org.junit.Before)

Example 13 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.

the class BluetoothSampleRateDialogPreferenceController method writeConfigurationValues.

@Override
protected void writeConfigurationValues(final int index) {
    // default
    int sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_NONE;
    switch(index) {
        case 0:
            final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
            if (currentConfig != null) {
                sampleRateValue = getHighestSampleRate(getSelectableByCodecType(currentConfig.getCodecType()));
            }
            break;
        case 1:
            sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_44100;
            break;
        case 2:
            sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_48000;
            break;
        case 3:
            sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_88200;
            break;
        case 4:
            sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_96000;
            break;
        default:
            break;
    }
    mBluetoothA2dpConfigStore.setSampleRate(sampleRateValue);
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Example 14 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.

the class BluetoothSampleRateDialogPreferenceController 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()).getSampleRate();
        for (int sampleRate : SAMPLE_RATES) {
            if ((configs & sampleRate) != 0) {
                selectableIndex.add(convertCfgToBtnIndex(sampleRate));
            }
        }
    }
    return selectableIndex;
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList)

Example 15 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig in project android_packages_apps_Settings by omnirom.

the class BluetoothBitPerSampleDialogPreferenceController 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()).getBitsPerSample();
        for (int i = 0; i < BITS_PER_SAMPLES.length; i++) {
            if ((configs & BITS_PER_SAMPLES[i]) != 0) {
                selectableIndex.add(convertCfgToBtnIndex(BITS_PER_SAMPLES[i]));
            }
        }
    }
    return selectableIndex;
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList)

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