private int mPasskey;
private String mDeviceName;
private LocalBluetoothProfile mPbapClientProfile;
+ private boolean mPbapAllowed;
/**
* Creates an instance of a BluetoothPairingController.
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
- mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
+ mPbapAllowed = true;
} else {
- mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
+ mPbapAllowed = false;
}
}
@Override
public void onDialogPositiveClick(BluetoothPairingDialogFragment dialog) {
if (getDialogType() == USER_ENTRY_DIALOG) {
+ if (mPbapAllowed) {
+ mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
+ } else {
+ mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
+ }
onPair(mUserInput);
} else {
onPair(null);
@Override
public void onDialogNegativeClick(BluetoothPairingDialogFragment dialog) {
+ mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
onCancel();
}
}
/**
+ * Update Phone book permission
+ *
+ */
+ public void setContactSharingState() {
+ if ((mDevice.getPhonebookAccessPermission() != BluetoothDevice.ACCESS_ALLOWED)
+ && (mDevice.getPhonebookAccessPermission() != BluetoothDevice.ACCESS_REJECTED)) {
+ if (mDevice.getBluetoothClass().getDeviceClass()
+ == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
+ onCheckedChanged(null, true);
+ } else {
+ onCheckedChanged(null, false);
+ }
+ }
+ }
+
+ /**
* A method for querying if the provided editable is a valid passkey/pin format for this device.
*
* @param s - The passkey/pin