Search in sources :

Example 21 with LocalBluetoothProfile

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

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

Example 22 with LocalBluetoothProfile

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

the class DeviceProfilesSettings method refreshProfiles.

private void refreshProfiles() {
    for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
        CheckBox profilePref = findProfile(profile.toString());
        if (profilePref == null) {
            profilePref = createProfilePreference(profile);
            mProfileContainer.addView(profilePref);
        } else {
            refreshProfilePreference(profilePref, profile);
        }
    }
    for (LocalBluetoothProfile profile : mCachedDevice.getRemovedProfiles()) {
        CheckBox profilePref = findProfile(profile.toString());
        if (profilePref != null) {
            Log.d(TAG, "Removing " + profile.toString() + " from profile list");
            mProfileContainer.removeView(profilePref);
        }
    }
    showOrHideProfileGroup();
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) CheckBox(android.widget.CheckBox)

Example 23 with LocalBluetoothProfile

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

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

Example 24 with LocalBluetoothProfile

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

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()) {
        if (!profile.isProfileReady()) {
            continue;
        }
        SwitchPreference pref = 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()) {
        final SwitchPreference pref = mProfilesContainer.findPreference(removedProfile.toString());
        if (pref != null) {
            mProfilesContainer.removePreference(pref);
        }
    }
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) SwitchPreference(androidx.preference.SwitchPreference)

Example 25 with LocalBluetoothProfile

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

the class DeviceProfilesSettings method addPreferencesForProfiles.

private void addPreferencesForProfiles() {
    mProfileContainer.removeAllViews();
    for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
        // MAP and PBAP profiles would be added based on permission access
        if (!((profile instanceof PbapServerProfile) || (profile instanceof MapProfile))) {
            CheckBox pref = createProfilePreference(profile);
            mProfileContainer.addView(pref);
        }
    }
    final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
    Log.d(TAG, "addPreferencesForProfiles: pbapPermission = " + pbapPermission);
    // 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();
    Log.d(TAG, "addPreferencesForProfiles: mapPermission = " + mapPermission);
    if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
        CheckBox mapPreference = createProfilePreference(mapProfile);
        mProfileContainer.addView(mapPreference);
    }
    showOrHideProfileGroup();
}
Also used : LocalBluetoothProfile(com.android.settingslib.bluetooth.LocalBluetoothProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) MapProfile(com.android.settingslib.bluetooth.MapProfile) CheckBox(android.widget.CheckBox)

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)12 BluetoothClass (android.bluetooth.BluetoothClass)7 Pair (android.util.Pair)7 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)6 SwitchPreference (androidx.preference.SwitchPreference)2