Search in sources :

Example 71 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by omnirom.

the class DeviceProfilesSettings method askDisconnect.

private void askDisconnect(Context context, final LocalBluetoothProfile profile) {
    // local reference for callback
    final CachedBluetoothDevice device = mCachedDevice;
    String name = device.getName();
    if (TextUtils.isEmpty(name)) {
        name = context.getString(R.string.bluetooth_device);
    }
    String profileName = context.getString(profile.getNameResource(device.getDevice()));
    String title = context.getString(R.string.bluetooth_disable_profile_title);
    String message = context.getString(R.string.bluetooth_disable_profile_message, profileName, name);
    DialogInterface.OnClickListener disconnectListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            device.disconnect(profile);
            profile.setPreferred(device.getDevice(), false);
            if (profile instanceof MapProfile) {
                device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
            }
            refreshProfilePreference(findProfile(profile.toString()), profile);
        }
    };
    mDisconnectDialog = Utils.showDisconnectDialog(context, mDisconnectDialog, disconnectListener, title, Html.fromHtml(message));
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener)

Example 72 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by DirtyUnicorns.

the class ForgetDeviceDialogFragment method getDevice.

@VisibleForTesting
CachedBluetoothDevice getDevice(Context context) {
    String deviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
    LocalBluetoothManager manager = Utils.getLocalBtManager(context);
    BluetoothDevice device = manager.getBluetoothAdapter().getRemoteDevice(deviceAddress);
    return manager.getCachedDeviceManager().findDevice(device);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 73 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by DirtyUnicorns.

the class RemoteDeviceNameDialogFragment method getDevice.

@VisibleForTesting
CachedBluetoothDevice getDevice(Context context) {
    String deviceAddress = getArguments().getString(KEY_CACHED_DEVICE_ADDRESS);
    LocalBluetoothManager manager = Utils.getLocalBtManager(context);
    BluetoothDevice device = manager.getBluetoothAdapter().getRemoteDevice(deviceAddress);
    return manager.getCachedDeviceManager().findDevice(device);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 74 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by DirtyUnicorns.

the class DeviceProfilesSettings method askDisconnect.

private void askDisconnect(Context context, final LocalBluetoothProfile profile) {
    // local reference for callback
    final CachedBluetoothDevice device = mCachedDevice;
    String name = device.getName();
    if (TextUtils.isEmpty(name)) {
        name = context.getString(R.string.bluetooth_device);
    }
    String profileName = context.getString(profile.getNameResource(device.getDevice()));
    String title = context.getString(R.string.bluetooth_disable_profile_title);
    String message = context.getString(R.string.bluetooth_disable_profile_message, profileName, name);
    DialogInterface.OnClickListener disconnectListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            device.disconnect(profile);
            profile.setPreferred(device.getDevice(), false);
            if (profile instanceof MapProfile) {
                device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
            }
            refreshProfilePreference(findProfile(profile.toString()), profile);
        }
    };
    mDisconnectDialog = Utils.showDisconnectDialog(context, mDisconnectDialog, disconnectListener, title, Html.fromHtml(message));
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener)

Example 75 with CachedBluetoothDevice

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

the class DeviceListPreferenceFragment method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (KEY_BT_SCAN.equals(preference.getKey())) {
        mLocalAdapter.startScanning(true);
        return true;
    }
    if (preference instanceof BluetoothDevicePreference) {
        BluetoothDevicePreference btPreference = (BluetoothDevicePreference) preference;
        CachedBluetoothDevice device = btPreference.getCachedDevice();
        mSelectedDevice = device.getDevice();
        onDevicePreferenceClick(btPreference);
        return true;
    }
    return super.onPreferenceTreeClick(preference);
}
Also used : CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice)

Aggregations

CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)104 BluetoothDevice (android.bluetooth.BluetoothDevice)38 LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)30 CachedBluetoothDeviceManager (com.android.settingslib.bluetooth.CachedBluetoothDeviceManager)15 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)12 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 DialogInterface (android.content.DialogInterface)7 OnClickListener (android.view.View.OnClickListener)7 MapProfile (com.android.settingslib.bluetooth.MapProfile)7 VisibleForTesting (androidx.annotation.VisibleForTesting)6 Intent (android.content.Intent)5 Preference (androidx.preference.Preference)4 Bundle (android.os.Bundle)2 ListBuilder (androidx.slice.builders.ListBuilder)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 GearPreference (com.android.settings.widget.GearPreference)2 LocalBluetoothProfile (com.android.settingslib.bluetooth.LocalBluetoothProfile)2 Iterator (java.util.Iterator)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2