From 5b84cfae44792be649f059e8815f5f6a5b395e66 Mon Sep 17 00:00:00 2001 From: Hemant Gupta Date: Fri, 22 Sep 2017 12:24:14 +0530 Subject: [PATCH] Bluetooth: Give PBAP permission only if device is AUDIO_VIDEO_HANDSFREE Step by step: 1. Pair and connect with BTHS (e.g. SBH50). 2. Click the settings icon of paired device, and check "Use for" items. ----------------------------------------------------------------- Expected Result: After step 2, "Contact sharing" should not be checked. Actual Result: After step 2, "Contact sharing" is checked. Fix: Set phone book permission as REJECTED if class of Device is not AUDIO_VIDEO_HANDSFREE Test: Checked above usecase and issue is not observed Bug: 64372703 Change-Id: I178a09dd9e76d67c461c4b04d9b2ee0078ed24c9 --- .../bluetooth/BluetoothPairingController.java | 16 ++++++++++++++++ .../BluetoothPairingDialogFragment.java | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java index ce82612685b..7d2d7b48c30 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingController.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java @@ -171,6 +171,22 @@ public class BluetoothPairingController implements OnCheckedChangeListener, } } + /** + * 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. * diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java index f95ce46d51c..068d86a2fef 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java @@ -224,6 +224,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i contactSharing.setVisibility(mPairingController.isProfileReady() ? View.GONE : View.VISIBLE); + mPairingController.setContactSharingState(); contactSharing.setOnCheckedChangeListener(mPairingController); contactSharing.setChecked(mPairingController.getContactSharingState()); @@ -314,6 +315,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i contactSharing.setVisibility( mPairingController.isProfileReady() ? View.GONE : View.VISIBLE); + mPairingController.setContactSharingState(); contactSharing.setChecked(mPairingController.getContactSharingState()); contactSharing.setOnCheckedChangeListener(mPairingController);