use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by omnirom.
the class BluetoothDetailsProfilesController method onPreferenceClick.
/**
* When the pref for a bluetooth profile is clicked on, we want to toggle the enabled/disabled
* state for that profile.
*/
@Override
public boolean onPreferenceClick(Preference preference) {
LocalBluetoothProfile profile = mProfileManager.getProfileByName(preference.getKey());
if (profile == null) {
// It might be the PbapServerProfile, which is not stored by name.
PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
if (TextUtils.equals(preference.getKey(), psp.toString())) {
profile = psp;
} else {
return false;
}
}
SwitchPreference profilePref = (SwitchPreference) preference;
BluetoothDevice device = mCachedDevice.getDevice();
if (profilePref.isChecked()) {
enableProfile(profile, device, profilePref);
} else {
disableProfile(profile, device, profilePref);
}
refreshProfilePreference(profilePref, profile);
return true;
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by omnirom.
the class BluetoothDetailsProfilesController method refresh.
/**
* Refreshes the state of the switches for all profiles, possibly adding or removing switches as
* needed.
*/
@Override
protected void refresh() {
for (LocalBluetoothProfile profile : getProfiles()) {
SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(profile.toString());
if (pref == null) {
pref = createProfilePreference(mProfilesContainer.getContext(), profile);
mProfilesContainer.addPreference(pref);
maybeAddHighQualityAudioPref(profile);
}
refreshProfilePreference(pref, profile);
}
for (LocalBluetoothProfile removedProfile : mCachedDevice.getRemovedProfiles()) {
SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(removedProfile.toString());
if (pref != null) {
mProfilesContainer.removePreference(pref);
}
}
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by omnirom.
the class Utils method getBtClassDrawableWithDescription.
static Pair<Drawable, String> getBtClassDrawableWithDescription(Context context, CachedBluetoothDevice cachedDevice, float iconScale) {
BluetoothClass btClass = cachedDevice.getBtClass();
final int level = cachedDevice.getBatteryLevel();
if (btClass != null) {
switch(btClass.getMajorDeviceClass()) {
case BluetoothClass.Device.Major.COMPUTER:
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_bt_laptop, level, iconScale), context.getString(R.string.bluetooth_talkback_computer));
case BluetoothClass.Device.Major.PHONE:
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_bt_cellphone, level, iconScale), context.getString(R.string.bluetooth_talkback_phone));
case BluetoothClass.Device.Major.PERIPHERAL:
return new Pair<>(getBluetoothDrawable(context, HidProfile.getHidClassDrawable(btClass), level, iconScale), context.getString(R.string.bluetooth_talkback_input_peripheral));
case BluetoothClass.Device.Major.IMAGING:
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_settings_print, level, iconScale), context.getString(R.string.bluetooth_talkback_imaging));
default:
}
}
List<LocalBluetoothProfile> profiles = cachedDevice.getProfiles();
for (LocalBluetoothProfile profile : profiles) {
int resId = profile.getDrawableResource(btClass);
if (resId != 0) {
return new Pair<>(getBluetoothDrawable(context, resId, level, iconScale), null);
}
}
if (btClass != null) {
if (btClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET)) {
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_bt_headset_hfp, level, iconScale), context.getString(R.string.bluetooth_talkback_headset));
}
if (btClass.doesClassMatch(BluetoothClass.PROFILE_A2DP)) {
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_bt_headphones_a2dp, level, iconScale), context.getString(R.string.bluetooth_talkback_headphone));
}
}
return new Pair<>(getBluetoothDrawable(context, R.drawable.ic_settings_bluetooth, level, iconScale), context.getString(R.string.bluetooth_talkback_bluetooth));
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by crdroidandroid.
the class BluetoothDetailsProfilesControllerTest method addFakeProfile.
/**
* Creates and adds a mock LocalBluetoothProfile to the list of connectable profiles for the
* device.
* @param profileNameResId the resource id for the name used by this profile
* @param deviceIsPreferred whether this profile should start out as enabled for the device
*/
private LocalBluetoothProfile addFakeProfile(int profileNameResId, boolean deviceIsPreferred) {
LocalBluetoothProfile profile = new FakeBluetoothProfile(mContext, profileNameResId);
profile.setPreferred(mDevice, deviceIsPreferred);
mConnectableProfiles.add(profile);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
return profile;
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by SudaMod.
the class DeviceProfilesSettings method onClick.
@Override
public void onClick(View v) {
if (v instanceof CheckBox) {
LocalBluetoothProfile prof = getProfileOf(v);
onProfileClicked(prof, (CheckBox) v);
}
}
Aggregations