diff options
author | Danning Chen <danningc@google.com> | 2020-02-19 13:29:14 -0800 |
---|---|---|
committer | Danning Chen <danningc@google.com> | 2020-02-19 21:40:06 +0000 |
commit | 6fb9750619433b18d0cb17803586625de762aaf7 (patch) | |
tree | 74c6025ed029d84ce2b4adba1507a44fe6f54bd4 /services/people | |
parent | cb7f6ffe034819acd03f977202d4fc0b47688365 (diff) |
Keep the event information in EventIndex for at most 63 days instead of 64 days
Bug: 149758587
Bug: 146522621
Test: atest com.android.server.people.data.EventIndexTest
Change-Id: I0cae2a5c958d88aab9f76a7ee198fc2e6d69971c
Diffstat (limited to 'services/people')
-rw-r--r-- | services/people/java/com/android/server/people/data/EventIndex.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/services/people/java/com/android/server/people/data/EventIndex.java b/services/people/java/com/android/server/people/data/EventIndex.java index b74a3fae98a5..069ec0e80ee4 100644 --- a/services/people/java/com/android/server/people/data/EventIndex.java +++ b/services/people/java/com/android/server/people/data/EventIndex.java @@ -61,7 +61,7 @@ import java.util.function.Function; */ public class EventIndex { - private static final int LONG_SIZE_BITS = 64; + private static final int RETENTION_DAYS = 63; private static final int TIME_SLOT_ONE_DAY = 0; @@ -202,7 +202,7 @@ public class EventIndex { updateEventBitmaps(currentTime); for (int slotType = 0; slotType < TIME_SLOT_TYPES_COUNT; slotType++) { int offset = diffTimeSlots(slotType, eventTime, currentTime); - if (offset < LONG_SIZE_BITS) { + if (offset < Long.SIZE) { mEventBitmaps[slotType] |= (1L << offset); } } @@ -236,12 +236,16 @@ public class EventIndex { private void updateEventBitmaps(long currentTimeMillis) { for (int slotType = 0; slotType < TIME_SLOT_TYPES_COUNT; slotType++) { int offset = diffTimeSlots(slotType, mLastUpdatedTime, currentTimeMillis); - if (offset < LONG_SIZE_BITS) { + if (offset < Long.SIZE) { mEventBitmaps[slotType] <<= offset; } else { mEventBitmaps[slotType] = 0L; } } + + int bitsToClear = Long.SIZE - RETENTION_DAYS; + mEventBitmaps[TIME_SLOT_ONE_DAY] <<= bitsToClear; + mEventBitmaps[TIME_SLOT_ONE_DAY] >>>= bitsToClear; mLastUpdatedTime = currentTimeMillis; } |