use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by crdroidandroid.
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 crdroidandroid.
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(bluetoothManager.getBluetoothAdapter(), bluetoothManager.getProfileManager(), mDevice);
}
String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
int phonebookPermission = cachedDevice.getPhonebookPermissionChoice();
if (phonebookPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (phonebookPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (phonebookPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
sendReplyIntentToReceiver(false);
processed = true;
} else {
Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
}
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
int messagePermission = cachedDevice.getMessagePermissionChoice();
if (messagePermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (messagePermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (messagePermission == CachedBluetoothDevice.ACCESS_REJECTED) {
sendReplyIntentToReceiver(false);
processed = true;
} else {
Log.e(TAG, "Bad messagePermission: " + messagePermission);
}
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
int simPermission = cachedDevice.getSimPermissionChoice();
if (simPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
// Leave 'processed' as false.
} else if (simPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
sendReplyIntentToReceiver(true);
processed = true;
} else if (simPermission == CachedBluetoothDevice.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 android_packages_apps_Settings by crdroidandroid.
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);
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by crdroidandroid.
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 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);
}
Aggregations