Fix b/273175976: Screen time counts the time before full charge.

Use the raw start timestamp instead of the first timestamp in the level
map to query app usage time.

Bug: 273175976
Fix: 273175976
Test: manual
Change-Id: Idb43b2bd5378e2f34ec722354408754f4a439c6d
This commit is contained in:
Zaiyue Xue
2023-03-13 15:34:28 +08:00
parent 3a4c6feb0a
commit a528f1e382
5 changed files with 27 additions and 71 deletions

View File

@@ -139,13 +139,13 @@ public final class DatabaseUtils {
Context context,
final Calendar calendar,
final List<Integer> userIds,
final long startTimestampOfLevelData) {
final long rawStartTimestamp) {
final long startTime = System.currentTimeMillis();
final long sixDaysAgoTimestamp = getTimestampSixDaysAgo(calendar);
// Query a longer time period and then trim to the original time period in order to make
// sure the app usage calculation near the boundaries is correct.
final long queryTimestamp =
Math.max(startTimestampOfLevelData, sixDaysAgoTimestamp) - USAGE_QUERY_BUFFER_HOURS;
Math.max(rawStartTimestamp, sixDaysAgoTimestamp) - USAGE_QUERY_BUFFER_HOURS;
Log.d(TAG, "sixDayAgoTimestamp: " + sixDaysAgoTimestamp);
final String queryUserIdString = userIds.stream()
.map(userId -> String.valueOf(userId))