Loading src/com/android/settings/bluetooth/CachedBluetoothDevice.java +46 −2 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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>(); Loading @@ -87,6 +87,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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 Loading Loading @@ -372,6 +374,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { updateProfiles(); fetchPhonebookPermissionChoice(); fetchMessagePermissionChoice(); fetchPhonebookRejectTimes(); fetchMessageRejectTimes(); mVisible = false; dispatchAttributesChanged(); Loading Loading @@ -538,6 +542,10 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { mConnectAfterPairing = false; // cancel auto-connect setPhonebookPermissionChoice(ACCESS_UNKNOWN); setMessagePermissionChoice(ACCESS_UNKNOWN); mPhonebookRejectedTimes = 0; savePhonebookRejectTimes(); mMessageRejectedTimes = 0; saveMessageRejectTimes(); } refresh(); Loading Loading @@ -657,6 +665,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // if user reject it, only save it when reject exceed limit. if (permissionChoice == ACCESS_REJECTED) { mPhonebookRejectedTimes++; savePhonebookRejectTimes(); if (mPhonebookRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) { return; } Loading @@ -681,6 +690,23 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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; Loading @@ -690,6 +716,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // if user reject it, only save it when reject exceed limit. if (permissionChoice == ACCESS_REJECTED) { mMessageRejectedTimes++; saveMessageRejectTimes(); if (mMessageRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) { return; } Loading @@ -714,4 +741,21 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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(); } } Loading
src/com/android/settings/bluetooth/CachedBluetoothDevice.java +46 −2 Original line number Diff line number Diff line Loading @@ -68,9 +68,9 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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>(); Loading @@ -87,6 +87,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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 Loading Loading @@ -372,6 +374,8 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { updateProfiles(); fetchPhonebookPermissionChoice(); fetchMessagePermissionChoice(); fetchPhonebookRejectTimes(); fetchMessageRejectTimes(); mVisible = false; dispatchAttributesChanged(); Loading Loading @@ -538,6 +542,10 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { mConnectAfterPairing = false; // cancel auto-connect setPhonebookPermissionChoice(ACCESS_UNKNOWN); setMessagePermissionChoice(ACCESS_UNKNOWN); mPhonebookRejectedTimes = 0; savePhonebookRejectTimes(); mMessageRejectedTimes = 0; saveMessageRejectTimes(); } refresh(); Loading Loading @@ -657,6 +665,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // if user reject it, only save it when reject exceed limit. if (permissionChoice == ACCESS_REJECTED) { mPhonebookRejectedTimes++; savePhonebookRejectTimes(); if (mPhonebookRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) { return; } Loading @@ -681,6 +690,23 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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; Loading @@ -690,6 +716,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { // if user reject it, only save it when reject exceed limit. if (permissionChoice == ACCESS_REJECTED) { mMessageRejectedTimes++; saveMessageRejectTimes(); if (mMessageRejectedTimes < PERSIST_REJECTED_TIMES_LIMIT) { return; } Loading @@ -714,4 +741,21 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> { 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(); } }