aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLiefu Liu <liefuliu@google.com>2021-04-27 00:05:42 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-27 00:05:42 +0000
commit8eff5f8a2294e1e433dca06996eb91bbf100b6a8 (patch)
treeb57b1a2267a76f75542bb3b6a25991410f284241 /src
parent22857e4d28dc8f0574c8127f26523098ab36f413 (diff)
parent5945232ae2490f681ceb08b5c11f6da4f5cbcc51 (diff)
downloadContactsProvider-8eff5f8a2294e1e433dca06996eb91bbf100b6a8.tar.gz
Minor name convention and comment update, for better readability. am: 5945232ae2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/ContactsProvider/+/14315160 Change-Id: I8583850d289cc60d8c685a4d2339a766efd3c1cc
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 7cc6b933..fee76800 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -2633,16 +2633,22 @@ public class ContactsProvider2 extends AbstractContactsProvider
syncToNetwork);
} else {
// Rate limit the changes which are not to sync to network.
- long uptimeMillis = System.currentTimeMillis();
+ long currentTimeMillis = System.currentTimeMillis();
mHandler.removeCallbacks(mChangeNotifier);
- if (uptimeMillis > mLastNotifyChange + NOTIFY_CHANGE_RATE_LIMIT) {
+ if (currentTimeMillis > mLastNotifyChange + NOTIFY_CHANGE_RATE_LIMIT) {
// Notify change immediately, since it has been a while since last notify.
- mLastNotifyChange = uptimeMillis;
+ mLastNotifyChange = currentTimeMillis;
getContext().getContentResolver().notifyChange(ContactsContract.AUTHORITY_URI, null,
false);
} else {
- // Schedule a deleyed notify, to ensure the very last notifyChange will be executed.
+ // Schedule a delayed notification, to ensure the very last notifyChange will be
+ // executed.
+ // Delay is set to two-fold of rate limit, and the subsequent notifyChange called
+ // (if ever) between the (NOTIFY_CHANGE_RATE_LIMIT, 2 * NOTIFY_CHANGE_RATE_LIMIT)
+ // time window, will cancel this delayed notification.
+ // The delayed notification is only expected to run if notifyChange is not invoked
+ // between the above time window.
mHandler.postDelayed(mChangeNotifier, NOTIFY_CHANGE_RATE_LIMIT * 2);
}
}