OSDN Git Service

DO NOT MERGE Give PBAP permission only after user confirms am: e36ca3e96d
authorHansong Zhang <hsz@google.com>
Wed, 30 May 2018 20:32:52 +0000 (13:32 -0700)
committerandroid-build-merger <android-build-merger@google.com>
Wed, 30 May 2018 20:32:52 +0000 (13:32 -0700)
am: 48aa959b14

Change-Id: I13480b0bf786ddd05959cb597492041e273d920c

src/com/android/settings/bluetooth/BluetoothPairingController.java

index ce82612..d06cb7e 100644 (file)
@@ -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();
     }