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

Commit 04277955 authored by mmanjuna's avatar mmanjuna Committed by Meghana Manjunatha
Browse files

Response stats:counts are not updated sometimes

This problem occurs only when the timestamp of broadcast and the
notification event is exactly the same.
Though ideally they need to occur one after the other,
it is quite possible that they can occur immediately with the same
timestamp. Hence, we see flaky behaviour.
Fix is to process the events even if broadcast event's
timestamp is equal to the notification event.

Bug: 330844354

Test: atest tests/tests/app.usage/src/android/app/usage/cts/BroadcastResponse
StatsTest.java
Change-Id: I69398c1d15ed7a4ae39c31a2b56f19ef0b858614
parent 31753ee5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ class BroadcastResponseStatsTracker {
                // We only need to look at the broadcast events that occurred before
                // this notification related event.
                while (dispatchTimestampsMs.size() > 0
                        && dispatchTimestampsMs.peekFirst() < timestampMs) {
                        && dispatchTimestampsMs.peekFirst() <= timestampMs) {
                    final long dispatchTimestampMs = dispatchTimestampsMs.peekFirst();
                    final long elapsedDurationMs = timestampMs - dispatchTimestampMs;
                    // Only increment the counts if the broadcast was sent not too long ago, as