use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by SudaMod.
the class BluetoothDetailsProfilesControllerTest method addMockA2dpProfile.
private A2dpProfile addMockA2dpProfile(boolean preferred, boolean supportsHighQualityAudio, boolean highQualityAudioEnabled) {
A2dpProfile profile = mock(A2dpProfile.class);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
when(profile.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_a2dp);
when(profile.getHighQualityAudioOptionLabel(mDevice)).thenReturn(mContext.getString(R.string.bluetooth_profile_a2dp_high_quality_unknown_codec));
when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
when(profile.isPreferred(mDevice)).thenReturn(preferred);
mConnectableProfiles.add(profile);
return profile;
}
use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by SudaMod.
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();
}
use of com.android.settingslib.bluetooth.A2dpProfile in project platform_packages_apps_Settings by BlissRoms.
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();
}
use of com.android.settingslib.bluetooth.A2dpProfile in project platform_packages_apps_Settings by BlissRoms.
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);
}
use of com.android.settingslib.bluetooth.A2dpProfile in project platform_packages_apps_Settings by BlissRoms.
the class DeviceProfilesSettings method addPreferencesForProfiles.
private void addPreferencesForProfiles() {
mProfileContainer.removeAllViews();
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
CheckBox pref = createProfilePreference(profile);
mProfileContainer.addView(pref);
if (profile instanceof A2dpProfile) {
BluetoothDevice device = mCachedDevice.getDevice();
A2dpProfile a2dpProfile = (A2dpProfile) profile;
if (a2dpProfile.supportsHighQualityAudio(device)) {
CheckBox highQualityPref = new CheckBox(getActivity());
highQualityPref.setTag(HIGH_QUALITY_AUDIO_PREF_TAG);
highQualityPref.setOnClickListener(v -> {
a2dpProfile.setHighQualityAudioEnabled(device, highQualityPref.isChecked());
});
highQualityPref.setVisibility(View.GONE);
mProfileContainer.addView(highQualityPref);
}
refreshProfilePreference(pref, profile);
}
}
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
// Only provide PBAP cabability if the client device has requested PBAP.
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
CheckBox pbapPref = createProfilePreference(psp);
mProfileContainer.addView(pbapPref);
}
final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
CheckBox mapPreference = createProfilePreference(mapProfile);
mProfileContainer.addView(mapPreference);
}
showOrHideProfileGroup();
}
Aggregations