use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by LineageOS.
the class DevicePickerFragment method onDeviceBondStateChanged.
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
BluetoothDevice device = cachedDevice.getDevice();
if (!device.equals(mSelectedDevice)) {
return;
}
if (bondState == BluetoothDevice.BOND_BONDED) {
sendDevicePickedIntent(device);
finish();
} else if (bondState == BluetoothDevice.BOND_NONE) {
enableScanning();
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by LineageOS.
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));
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by LineageOS.
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);
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by omnirom.
the class BluetoothPermissionActivity method onNegative.
private void onNegative() {
if (DEBUG)
Log.d(TAG, "onNegative");
boolean always = true;
if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
LocalBluetoothManager bluetoothManager = Utils.getLocalBtManager(this);
CachedBluetoothDeviceManager cachedDeviceManager = bluetoothManager.getCachedDeviceManager();
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
if (cachedDevice == null) {
cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(), bluetoothManager.getProfileManager(), mDevice);
}
always = cachedDevice.checkAndIncreaseMessageRejectionCount();
}
sendReplyIntentToReceiver(false, always);
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by omnirom.
the class BluetoothSettings method initDevicePreference.
/**
* Add a listener, which enables the advanced settings icon.
*
* @param preference the newly added preference
*/
@Override
void initDevicePreference(BluetoothDevicePreference preference) {
preference.setOrder(PAIRED_DEVICE_ORDER);
CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
// Only paired device have an associated advanced settings screen
preference.setOnGearClickListener(mDeviceProfilesListener);
}
}
Aggregations