From 46c746551f5e3df58f12ce43bb0da3dd611b5944 Mon Sep 17 00:00:00 2001 From: Edward Jee Date: Thu, 19 Sep 2013 01:12:12 -0700 Subject: [PATCH] Once the user allows PBAP phonebook access, do not ask again. Bug: 9876209 Change-Id: I8d9dcfa03e8d85577af4c4664fa34b3830e3d8f6 --- res/layout/bluetooth_access.xml | 11 +---- res/layout/bluetooth_connection_access.xml | 40 ------------------ .../BluetoothPermissionActivity.java | 42 ++++++------------- 3 files changed, 14 insertions(+), 79 deletions(-) delete mode 100644 res/layout/bluetooth_connection_access.xml diff --git a/res/layout/bluetooth_access.xml b/res/layout/bluetooth_access.xml index f398ceffded..7f42177c9ca 100644 --- a/res/layout/bluetooth_access.xml +++ b/res/layout/bluetooth_access.xml @@ -1,7 +1,7 @@ - - - - - - - - - diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java index 012aff0798b..e73857a0bd8 100755 --- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java @@ -55,8 +55,6 @@ public class BluetoothPermissionActivity extends AlertActivity implements private String mReturnPackage = null; private String mReturnClass = null; - private CheckBox mRememberChoice; - private boolean mRememberChoiceValue = false; private int mRequestType = 0; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override @@ -156,64 +154,50 @@ public class BluetoothPermissionActivity extends AlertActivity implements return mRemoteName; } + // TODO(edjee): createConnectionDialogView, createPhonebookDialogView and createMapDialogView + // are similar. Refactor them into one method. + // Also, the string resources bluetooth_remember_choice and bluetooth_pb_remember_choice should + // be removed. private View createConnectionDialogView() { String mRemoteName = createRemoteName(); - mView = getLayoutInflater().inflate(R.layout.bluetooth_connection_access, null); + mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_connection_dialog_text, mRemoteName)); return mView; } - private void createCheckbox(int viewId) - { - mRememberChoice = (CheckBox)mView.findViewById(viewId); - mRememberChoice.setChecked(false); - mRememberChoice.setOnCheckedChangeListener(new OnCheckedChangeListener() { - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked) { - mRememberChoiceValue = true; - } else { - mRememberChoiceValue = false; - } - } - }); - } private View createPhonebookDialogView() { String mRemoteName = createRemoteName(); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_pb_acceptance_dialog_text, mRemoteName, mRemoteName)); - createCheckbox(R.id.bluetooth_remember_choice); return mView; } + private View createMapDialogView() { String mRemoteName = createRemoteName(); mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null); messageView = (TextView)mView.findViewById(R.id.message); messageView.setText(getString(R.string.bluetooth_map_acceptance_dialog_text, mRemoteName, mRemoteName)); - createCheckbox(R.id.bluetooth_remember_choice); return mView; } private void onPositive() { - if (DEBUG) Log.d(TAG, "onPositive mRememberChoiceValue: " + mRememberChoiceValue); - if (mRememberChoiceValue) - savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_ALLOWED); - + if (DEBUG) Log.d(TAG, "onPositive"); + savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_ALLOWED); + // TODO(edjee): Now that we always save the user's choice, + // we can get rid of BluetoothDevice#EXTRA_ALWAYS_ALLOWED. sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, true, - BluetoothDevice.EXTRA_ALWAYS_ALLOWED, mRememberChoiceValue); + BluetoothDevice.EXTRA_ALWAYS_ALLOWED, true); finish(); } private void onNegative() { - if (DEBUG) Log.d(TAG, "onNegative mRememberChoiceValue: " + mRememberChoiceValue); - - if (mRememberChoiceValue) - savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_REJECTED); - + if (DEBUG) Log.d(TAG, "onNegative"); + savePermissionChoice(mRequestType, CachedBluetoothDevice.ACCESS_UNKNOWN); sendIntentToReceiver(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY, false, null, false // dummy value, no effect since last param is null );