Search in sources :

Example 1 with PanProfile

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

the class DeviceProfilesSettings method onProfileClicked.

private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) {
    BluetoothDevice device = mCachedDevice.getDevice();
    if (!profilePref.isChecked()) {
        // Recheck it, until the dialog is done.
        profilePref.setChecked(true);
        askDisconnect(mManager.getForegroundActivity(), profile);
    } else {
        if (profile instanceof MapProfile) {
            mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
        }
        if (profile instanceof PbapServerProfile) {
            mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
            refreshProfilePreference(profilePref, profile);
            return;
        }
        if (profile.isPreferred(device)) {
            // profile is preferred but not connected: disable auto-connect
            if (profile instanceof PanProfile) {
                mCachedDevice.connectProfile(profile);
            } else {
                profile.setPreferred(device, false);
            }
        } else {
            profile.setPreferred(device, true);
            mCachedDevice.connectProfile(profile);
        }
        refreshProfilePreference(profilePref, profile);
    }
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) PanProfile(com.android.settingslib.bluetooth.PanProfile)

Example 2 with PanProfile

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

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));
    }
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) PbapServerProfile(com.android.settingslib.bluetooth.PbapServerProfile) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) PanProfile(com.android.settingslib.bluetooth.PanProfile)

Aggregations

BluetoothDevice (android.bluetooth.BluetoothDevice)2 CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)2 MapProfile (com.android.settingslib.bluetooth.MapProfile)2 PanProfile (com.android.settingslib.bluetooth.PanProfile)2 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)2