Search in sources :

Example 51 with LocalBluetoothProfile

use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project platform_packages_apps_Settings by BlissRoms.

the class BluetoothDetailsProfilesController method getProfiles.

/**
 * Helper to get the list of connectable and special profiles.
 */
private List<LocalBluetoothProfile> getProfiles() {
    List<LocalBluetoothProfile> result = mCachedDevice.getConnectableProfiles();
    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();
        result.add(psp);
    }
    final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
    final int mapPermission = mCachedDevice.getMessagePermissionChoice();
    if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
        result.add(mapProfile);
    }
    return result;
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) MapProfile(com.android.settingslib.bluetooth.MapProfile)

Example 52 with LocalBluetoothProfile

use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project platform_packages_apps_Settings by BlissRoms.

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);
        }
    }
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) SwitchPreference(android.support.v14.preference.SwitchPreference)

Example 53 with LocalBluetoothProfile

use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project platform_packages_apps_Settings by BlissRoms.

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));
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) BluetoothClass(android.bluetooth.BluetoothClass) Pair(android.util.Pair)

Example 54 with LocalBluetoothProfile

use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothDetailsProfilesController method getProfiles.

/**
 * Helper to get the list of connectable and special profiles.
 */
private List<LocalBluetoothProfile> getProfiles() {
    List<LocalBluetoothProfile> result = mCachedDevice.getConnectableProfiles();
    final BluetoothDevice device = mCachedDevice.getDevice();
    final int pbapPermission = device.getPhonebookAccessPermission();
    // Only provide PBAP cabability if the client device has requested PBAP.
    if (pbapPermission != BluetoothDevice.ACCESS_UNKNOWN) {
        final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
        result.add(psp);
    }
    final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
    final int mapPermission = device.getMessageAccessPermission();
    if (mapPermission != BluetoothDevice.ACCESS_UNKNOWN) {
        result.add(mapProfile);
    }
    return result;
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) MapProfile(com.android.settingslib.bluetooth.MapProfile) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice)

Example 55 with LocalBluetoothProfile

use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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;
    if (profilePref.isChecked()) {
        enableProfile(profile);
    } else {
        disableProfile(profile);
    }
    refreshProfilePreference(profilePref, profile);
    return true;
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) SwitchPreference(androidx.preference.SwitchPreference)

Aggregations

LocalBluetoothProfile (com.android.settingslib.bluetooth.LocalBluetoothProfile)57 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)22 CheckBox (android.widget.CheckBox)20 CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)15 MapProfile (com.android.settingslib.bluetooth.MapProfile)15 BluetoothDevice (android.bluetooth.BluetoothDevice)13 SwitchPreference (android.support.v14.preference.SwitchPreference)10 BluetoothClass (android.bluetooth.BluetoothClass)7 Pair (android.util.Pair)7 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)6 SwitchPreference (androidx.preference.SwitchPreference)4 Preference (androidx.preference.Preference)1