Search in sources :

Example 36 with BluetoothCodecConfig

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

the class BluetoothQualityDialogPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    // Enable preference when current codec type is LDAC. For other cases, disable it.
    final BluetoothCodecConfig currentConfig = getCurrentCodecConfig();
    if (currentConfig != null && currentConfig.getCodecType() == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) {
        preference.setEnabled(true);
    } else {
        preference.setEnabled(false);
        preference.setSummary("");
    }
}
Also used : BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Example 37 with BluetoothCodecConfig

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

the class AbstractBluetoothA2dpPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
    if (activeDevice == null || getCodecConfig(activeDevice) == null || mPreference == null) {
        return;
    }
    BluetoothCodecConfig codecConfig;
    synchronized (mBluetoothA2dpConfigStore) {
        codecConfig = getCodecConfig(activeDevice);
    }
    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 : BluetoothDevice(android.bluetooth.BluetoothDevice) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig)

Example 38 with BluetoothCodecConfig

use of android.bluetooth.BluetoothCodecConfig 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();
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Test(org.junit.Test)

Example 39 with BluetoothCodecConfig

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

the class BluetoothSampleRateDialogPreferenceControllerTest method getSelectableIndex_verifyList.

@Test
public void getSelectableIndex_verifyList() {
    BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigSBC };
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    List<Integer> indexList = new ArrayList<>();
    indexList.add(mController.getDefaultIndex());
    indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.SAMPLE_RATE_48000));
    indexList.add(mController.convertCfgToBtnIndex(BluetoothCodecConfig.SAMPLE_RATE_88200));
    assertThat(mController.getSelectableIndex().containsAll(indexList)).isTrue();
    assertThat(indexList.containsAll(mController.getSelectableIndex())).isTrue();
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 40 with BluetoothCodecConfig

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

the class BluetoothBitPerSampleDialogPreferenceControllerTest method writeConfigurationValues_selectDefault_setHighest.

@Test
public void writeConfigurationValues_selectDefault_setHighest() {
    BluetoothCodecConfig[] mCodecConfigs = { mCodecConfigAAC, mCodecConfigSBC };
    mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
    when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
    mController.onBluetoothServiceConnected(mBluetoothA2dp);
    mController.writeConfigurationValues(0);
    verify(mBluetoothA2dpConfigStore).setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24);
}
Also used : BluetoothCodecStatus(android.bluetooth.BluetoothCodecStatus) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Test(org.junit.Test)

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