use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by DirtyUnicorns.
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 DirtyUnicorns.
the class BluetoothDetailsProfilesController method refreshProfilePreference.
/**
* Refreshes the state for an existing SwitchPreference for a profile.
*/
private void refreshProfilePreference(SwitchPreference profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
if (profile instanceof A2dpProfile) {
A2dpProfile a2dp = (A2dpProfile) profile;
SwitchPreference highQualityPref = (SwitchPreference) mProfilesContainer.findPreference(HIGH_QUALITY_AUDIO_PREF_TAG);
if (highQualityPref != null) {
if (a2dp.isPreferred(device) && a2dp.supportsHighQualityAudio(device)) {
highQualityPref.setVisible(true);
highQualityPref.setTitle(a2dp.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dp.isHighQualityAudioEnabled(device));
highQualityPref.setEnabled(!mCachedDevice.isBusy());
} else {
highQualityPref.setVisible(false);
}
}
}
}
use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by DirtyUnicorns.
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();
}
use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by DirtyUnicorns.
the class DeviceProfilesSettings method refreshProfilePreference.
private void refreshProfilePreference(CheckBox profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
// Gray out checkbox while connecting and disconnecting.
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
if (profile instanceof A2dpProfile) {
A2dpProfile a2dpProfile = (A2dpProfile) profile;
View v = mProfileContainer.findViewWithTag(HIGH_QUALITY_AUDIO_PREF_TAG);
if (v instanceof CheckBox) {
CheckBox highQualityPref = (CheckBox) v;
highQualityPref.setText(a2dpProfile.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dpProfile.isHighQualityAudioEnabled(device));
if (a2dpProfile.isPreferred(device)) {
v.setVisibility(View.VISIBLE);
v.setEnabled(!mCachedDevice.isBusy());
} else {
v.setVisibility(View.GONE);
}
}
}
}
use of com.android.settingslib.bluetooth.A2dpProfile in project android_packages_apps_Settings by crdroidandroid.
the class DeviceProfilesSettings method refreshProfilePreference.
private void refreshProfilePreference(CheckBox profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
// Gray out checkbox while connecting and disconnecting.
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
if (profile instanceof A2dpProfile) {
A2dpProfile a2dpProfile = (A2dpProfile) profile;
View v = mProfileContainer.findViewWithTag(HIGH_QUALITY_AUDIO_PREF_TAG);
if (v instanceof CheckBox) {
CheckBox highQualityPref = (CheckBox) v;
highQualityPref.setText(a2dpProfile.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dpProfile.isHighQualityAudioEnabled(device));
if (a2dpProfile.isPreferred(device)) {
v.setVisibility(View.VISIBLE);
v.setEnabled(!mCachedDevice.isBusy());
} else {
v.setVisibility(View.GONE);
}
}
}
}
Aggregations