Search in sources :

Example 6 with A2dpProfile

use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by crdroidandroid.

the class BluetoothDetailsProfilesControllerTest method highQualityAudio_mediaAudioStartsDisabled.

@Test
public void highQualityAudio_mediaAudioStartsDisabled() {
    setupDevice(makeDefaultDeviceConfig());
    A2dpProfile audioProfile = addMockA2dpProfile(false, true, true);
    showScreen(mController);
    SwitchPreference audioPref = (SwitchPreference) mScreen.findPreference(audioProfile.toString());
    SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
    assertThat(audioPref).isNotNull();
    assertThat(audioPref.isChecked()).isFalse();
    assertThat(highQualityAudioPref).isNotNull();
    assertThat(highQualityAudioPref.isVisible()).isFalse();
}
Also used : A2dpProfile(com.android.settingslib.bluetooth.A2dpProfile) SwitchPreference(android.support.v14.preference.SwitchPreference) Test(org.junit.Test)

Example 7 with A2dpProfile

use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by crdroidandroid.

the class BluetoothDetailsProfilesControllerTest method highQualityAudio_mediaAudioDisabledAndReEnabled.

@Test
public void highQualityAudio_mediaAudioDisabledAndReEnabled() {
    setupDevice(makeDefaultDeviceConfig());
    A2dpProfile audioProfile = addMockA2dpProfile(true, true, true);
    showScreen(mController);
    assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
    // Disabling media audio should cause the high quality audio switch to disappear, but not
    // the regular audio one.
    SwitchPreference audioPref = (SwitchPreference) mScreen.findPreference(audioProfile.toString());
    audioPref.performClick();
    verify(audioProfile).setPreferred(mDevice, false);
    when(audioProfile.isPreferred(mDevice)).thenReturn(false);
    mController.onDeviceAttributesChanged();
    assertThat(audioPref.isVisible()).isTrue();
    SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
    assertThat(highQualityAudioPref.isVisible()).isFalse();
    // And re-enabling media audio should make high quality switch to reappear.
    audioPref.performClick();
    verify(audioProfile).setPreferred(mDevice, true);
    when(audioProfile.isPreferred(mDevice)).thenReturn(true);
    mController.onDeviceAttributesChanged();
    highQualityAudioPref = getHighQualityAudioPref();
    assertThat(highQualityAudioPref.isVisible()).isTrue();
}
Also used : A2dpProfile(com.android.settingslib.bluetooth.A2dpProfile) SwitchPreference(android.support.v14.preference.SwitchPreference) Test(org.junit.Test)

Example 8 with A2dpProfile

use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by SudaMod.

the class BluetoothDetailsProfilesControllerTest method highQualityAudio_mediaAudioStartsDisabled.

@Test
public void highQualityAudio_mediaAudioStartsDisabled() {
    setupDevice(makeDefaultDeviceConfig());
    A2dpProfile audioProfile = addMockA2dpProfile(false, true, true);
    showScreen(mController);
    SwitchPreference audioPref = (SwitchPreference) mScreen.findPreference(audioProfile.toString());
    SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
    assertThat(audioPref).isNotNull();
    assertThat(audioPref.isChecked()).isFalse();
    assertThat(highQualityAudioPref).isNotNull();
    assertThat(highQualityAudioPref.isVisible()).isFalse();
}
Also used : A2dpProfile(com.android.settingslib.bluetooth.A2dpProfile) SwitchPreference(android.support.v14.preference.SwitchPreference) Test(org.junit.Test)

Example 9 with A2dpProfile

use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by SudaMod.

the class BluetoothDetailsProfilesControllerTest method highQualityAudio_prefIsPresentWhenSupported.

@Test
public void highQualityAudio_prefIsPresentWhenSupported() {
    setupDevice(makeDefaultDeviceConfig());
    addMockA2dpProfile(true, true, true);
    showScreen(mController);
    SwitchPreference pref = getHighQualityAudioPref();
    assertThat(pref.getKey()).isEqualTo(BluetoothDetailsProfilesController.HIGH_QUALITY_AUDIO_PREF_TAG);
    // Make sure the preference works when clicked on.
    pref.performClick();
    A2dpProfile profile = (A2dpProfile) mConnectableProfiles.get(0);
    verify(profile).setHighQualityAudioEnabled(mDevice, false);
    pref.performClick();
    verify(profile).setHighQualityAudioEnabled(mDevice, true);
}
Also used : A2dpProfile(com.android.settingslib.bluetooth.A2dpProfile) SwitchPreference(android.support.v14.preference.SwitchPreference) Test(org.junit.Test)

Example 10 with A2dpProfile

use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by SudaMod.

the class BluetoothDetailsProfilesController method maybeAddHighQualityAudioPref.

/**
 * This is a helper method to be called after adding a Preference for a profile. If that
 * profile happened to be A2dp and the device supports high quality audio, it will add a
 * separate preference for controlling whether to actually use high quality audio.
 *
 * @param profile the profile just added
 */
private void maybeAddHighQualityAudioPref(LocalBluetoothProfile profile) {
    if (!(profile instanceof A2dpProfile)) {
        return;
    }
    BluetoothDevice device = mCachedDevice.getDevice();
    A2dpProfile a2dp = (A2dpProfile) profile;
    if (a2dp.supportsHighQualityAudio(device)) {
        SwitchPreference highQualityAudioPref = new SwitchPreference(mProfilesContainer.getContext());
        highQualityAudioPref.setKey(HIGH_QUALITY_AUDIO_PREF_TAG);
        highQualityAudioPref.setVisible(false);
        highQualityAudioPref.setOnPreferenceClickListener(clickedPref -> {
            boolean enable = ((SwitchPreference) clickedPref).isChecked();
            a2dp.setHighQualityAudioEnabled(mCachedDevice.getDevice(), enable);
            return true;
        });
        mProfilesContainer.addPreference(highQualityAudioPref);
    }
}
Also used : A2dpProfile(com.android.settingslib.bluetooth.A2dpProfile) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) SwitchPreference(android.support.v14.preference.SwitchPreference)

Aggregations

A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)57 BluetoothDevice (android.bluetooth.BluetoothDevice)29 CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)26 SwitchPreference (android.support.v14.preference.SwitchPreference)25 Test (org.junit.Test)21 MapProfile (com.android.settingslib.bluetooth.MapProfile)19 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)19 PanProfile (com.android.settingslib.bluetooth.PanProfile)13 CheckBox (android.widget.CheckBox)12 SwitchPreference (androidx.preference.SwitchPreference)10 View (android.view.View)6 TextView (android.widget.TextView)6 LocalBluetoothProfile (com.android.settingslib.bluetooth.LocalBluetoothProfile)6