BT keeps on asking me if I want to allow car to do stuff
Persist the "no" count
bug:11176511
Change-Id: I39674334fe8bf09d1f3f2b07c12513a6c46f053b
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 2fb434b..77a9462 100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -68,9 +68,9 @@
private int mMessagePermissionChoice;
- private int mPhonebookRejectedTimes = 0;
+ private int mPhonebookRejectedTimes;
- private int mMessageRejectedTimes = 0;
+ private int mMessageRejectedTimes;
private final Collection<Callback> mCallbacks = new ArrayList<Callback>();
@@ -87,6 +87,8 @@
private final static String PHONEBOOK_PREFS_NAME = "bluetooth_phonebook_permission";
private final static String MESSAGE_PREFS_NAME = "bluetooth_message_permission";
+ private final static String PHONEBOOK_REJECT_TIMES = "bluetooth_phonebook_reject";
+ private final static String MESSAGE_REJECT_TIMES = "bluetooth_message_reject";
/**
* When we connect to multiple profiles, we only want to display a single
@@ -372,6 +374,8 @@
updateProfiles();
fetchPhonebookPermissionChoice();
fetchMessagePermissionChoice();
+ fetchPhonebookRejectTimes();
+ fetchMessageRejectTimes();
mVisible = false;
dispatchAttributesChanged();
@@ -538,6 +542,10 @@
mConnectAfterPairing = false; // cancel auto-connect
setPhonebookPermissionChoice(ACCESS_UNKNOWN);
setMessagePermissionChoice(ACCESS_UNKNOWN);
+ mPhonebookRejectedTimes = 0;
+ savePhonebookRejectTimes();
+ mMessageRejectedTimes = 0;
+ saveMessageRejectTimes();
}
refresh();
@@ -657,6 +665,7 @@
// if user reject it, only save it when reject exceed limit.
if (permissionChoice == ACCESS_REJECTED) {
mPhonebookRejectedTimes++;
+ savePhonebookRejectTimes();
if (mPhonebookRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) {
return;
}
@@ -681,6 +690,23 @@
ACCESS_UNKNOWN);
}
+ private void fetchPhonebookRejectTimes() {
+ SharedPreferences preference = mContext.getSharedPreferences(PHONEBOOK_REJECT_TIMES,
+ Context.MODE_PRIVATE);
+ mPhonebookRejectedTimes = preference.getInt(mDevice.getAddress(), 0);
+ }
+
+ private void savePhonebookRejectTimes() {
+ SharedPreferences.Editor editor =
+ mContext.getSharedPreferences(PHONEBOOK_REJECT_TIMES,
+ Context.MODE_PRIVATE).edit();
+ if (mPhonebookRejectedTimes == 0) {
+ editor.remove(mDevice.getAddress());
+ } else {
+ editor.putInt(mDevice.getAddress(), mPhonebookRejectedTimes);
+ }
+ editor.commit();
+ }
int getMessagePermissionChoice() {
return mMessagePermissionChoice;
@@ -690,6 +716,7 @@
// if user reject it, only save it when reject exceed limit.
if (permissionChoice == ACCESS_REJECTED) {
mMessageRejectedTimes++;
+ saveMessageRejectTimes();
if (mMessageRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) {
return;
}
@@ -714,4 +741,21 @@
ACCESS_UNKNOWN);
}
+ private void fetchMessageRejectTimes() {
+ SharedPreferences preference = mContext.getSharedPreferences(MESSAGE_REJECT_TIMES,
+ Context.MODE_PRIVATE);
+ mMessageRejectedTimes = preference.getInt(mDevice.getAddress(), 0);
+ }
+
+ private void saveMessageRejectTimes() {
+ SharedPreferences.Editor editor =
+ mContext.getSharedPreferences(MESSAGE_REJECT_TIMES, Context.MODE_PRIVATE).edit();
+ if (mMessageRejectedTimes == 0) {
+ editor.remove(mDevice.getAddress());
+ } else {
+ editor.putInt(mDevice.getAddress(), mMessageRejectedTimes);
+ }
+ editor.commit();
+ }
+
}