use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project platform_packages_apps_Settings by BlissRoms.
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 platform_packages_apps_Settings by BlissRoms.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDeviceUpdater method removePreference.
/**
* Remove the {@link Preference} that represents the {@code cachedDevice}
*/
protected void removePreference(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
final CachedBluetoothDevice subCachedDevice = cachedDevice.getSubDevice();
if (mPreferenceMap.containsKey(device)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(device));
mPreferenceMap.remove(device);
} else if (subCachedDevice != null) {
// When doing remove, to check if preference maps to sub device.
// This would happen when connection state is changed in detail page that there is no
// callback from SettingsLib.
final BluetoothDevice subDevice = subCachedDevice.getDevice();
if (mPreferenceMap.containsKey(subDevice)) {
mDevicePreferenceCallback.onDeviceRemoved(mPreferenceMap.get(subDevice));
mPreferenceMap.remove(subDevice);
}
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothPermissionRequest method checkUserChoice.
/**
* @return true user had made a choice, this method replies to the request according
* to user's previous decision
* false user hadnot made any choice on this device
*/
private boolean checkUserChoice() {
boolean processed = false;
// ignore if it is something else than phonebook/message settings it wants us to remember
if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS && mRequestType != BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
if (DEBUG)
Log.d(TAG, "checkUserChoice(): Unknown RequestType " + mRequestType);
return processed;
}
LocalBluetoothManager bluetoothManager = Utils.getLocalBtManager(mContext);
CachedBluetoothDeviceManager cachedDeviceManager = bluetoothManager.getCachedDeviceManager();
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
if (cachedDevice == null) {
cachedDevice = cachedDeviceManager.addDevice(mDevice);
}
String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
int phonebookPermission = mDevice.getPhonebookAccessPermission();
if (phonebookPermission == BluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (phonebookPermission == BluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (phonebookPermission == BluetoothDevice.ACCESS_REJECTED) {
sendReplyIntentToReceiver(false);
processed = true;
} else {
Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
}
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
int messagePermission = mDevice.getMessageAccessPermission();
if (messagePermission == BluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (messagePermission == BluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (messagePermission == BluetoothDevice.ACCESS_REJECTED) {
sendReplyIntentToReceiver(false);
processed = true;
} else {
Log.e(TAG, "Bad messagePermission: " + messagePermission);
}
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
int simPermission = mDevice.getSimAccessPermission();
if (simPermission == BluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (simPermission == BluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (simPermission == BluetoothDevice.ACCESS_REJECTED) {
sendReplyIntentToReceiver(false);
processed = true;
} else {
Log.e(TAG, "Bad simPermission: " + simPermission);
}
}
if (DEBUG)
Log.d(TAG, "checkUserChoice(): returning " + processed);
return processed;
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceListPreferenceFragment method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (KEY_BT_SCAN.equals(preference.getKey())) {
startScanning();
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);
}
Aggregations