Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 569becdb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use (the last existing timestamp in DB + 1) as the start time of usage...

Merge "Use (the last existing timestamp in DB + 1) as the start time of usage event query to avoid loading the same events repeatedly."
parents 4ef920e9 6da66f9a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -125,7 +125,9 @@ public final class DatabaseUtils {
        Log.d(TAG, String.format(
                "getAppUsageStartTimestampOfUser() userId=%d latestTimestamp=%d in %d/ms",
                userId, latestTimestamp, (System.currentTimeMillis() - startTime)));
        return Math.max(latestTimestamp, earliestTimestamp);
        // Use (latestTimestamp + 1) here to avoid loading the events of the latestTimestamp
        // repeatedly.
        return Math.max(latestTimestamp + 1, earliestTimestamp);
    }

    /** Returns the current user data in app usage event table. */
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public final class DatabaseUtilsTest {

        final long earliestTimestamp1 = 1001L;
        assertThat(DatabaseUtils.getAppUsageStartTimestampOfUser(
                mContext, /*userId=*/ 0, earliestTimestamp1)).isEqualTo(returnedTimestamp);
                mContext, /*userId=*/ 0, earliestTimestamp1)).isEqualTo(returnedTimestamp + 1);
        final long earliestTimestamp2 = 100001L;
        assertThat(DatabaseUtils.getAppUsageStartTimestampOfUser(
                mContext, /*userId=*/ 0, earliestTimestamp2)).isEqualTo(earliestTimestamp2);