From 500c83c1bc214f1075ac69debb50f489ab35e26c Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 17 May 2018 13:54:00 -0700 Subject: [PATCH] Give PBAP permission only after user confirms Bug: 72872376 Test: manual Change-Id: I9617e3c10bf19e22f9a8f172332a83bbbebaf4a4 --- .../bluetooth/BluetoothPairingController.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java index 7d2d7b48c30..5120cc0ff9b 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingController.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java @@ -57,6 +57,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener, private int mPasskey; private String mDeviceName; private LocalBluetoothProfile mPbapClientProfile; + private boolean mPbapAllowed; /** * Creates an instance of a BluetoothPairingController. @@ -87,15 +88,20 @@ public class BluetoothPairingController implements OnCheckedChangeListener, @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); @@ -104,6 +110,7 @@ public class BluetoothPairingController implements OnCheckedChangeListener, @Override public void onDialogNegativeClick(BluetoothPairingDialogFragment dialog) { + mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED); onCancel(); }