summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmanjuna <meghana.manjunatha@amd.com>2024-03-22 12:46:15 -0400
committerMeghana Manjunatha <meghana.manjunatha@amd.com>2024-03-25 14:28:30 +0000
commit042779557870acb272c6b132cd2314e53c35317a (patch)
tree4833f197de123e4ea9a592a68ebfe383c87e8e0b
parent31753ee5e33dd766e49effe6efc93c6c7e58c38c (diff)
downloadbase-042779557870acb272c6b132cd2314e53c35317a.tar.gz
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
-rw-r--r--services/usage/java/com/android/server/usage/BroadcastResponseStatsTracker.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/usage/java/com/android/server/usage/BroadcastResponseStatsTracker.java b/services/usage/java/com/android/server/usage/BroadcastResponseStatsTracker.java
index d9cbea95e563..ed89190f8473 100644
--- a/services/usage/java/com/android/server/usage/BroadcastResponseStatsTracker.java
+++ b/services/usage/java/com/android/server/usage/BroadcastResponseStatsTracker.java
@@ -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