Allow dispatcher to be idle after metrics push
Earlier, the dispatcher was not being allowed to enter idle state
since processLatencyStatisticsLocked() would always wake it up in 6 hours,
causing many of the dispatcher tests to fail.
Now, the dispatcher will be idle after the latency statistics are
pushed. After the statistics push is complete, the next push will occur
after 6 hours upon the next input event being received by the
dispatcher.
Bug: 270049345
Test: atest inputflinger_tests
Flag: com.android.input.flags.enable_per_device_input_latency_metrics
Change-Id: I1cdb6df6110bff9e4fcb6cbfdc91c16c8e386f0b
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 4b43c27..cbc0790 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -1031,8 +1031,7 @@
nextWakeupTime = std::min(nextWakeupTime, nextAnrCheck);
if (mPerDeviceInputLatencyMetricsFlag) {
- const nsecs_t nextStatisticsPush = processLatencyStatisticsLocked();
- nextWakeupTime = std::min(nextWakeupTime, nextStatisticsPush);
+ processLatencyStatisticsLocked();
}
// We are about to enter an infinitely long sleep, because we have no commands or
@@ -1117,9 +1116,8 @@
/**
* Check if enough time has passed since the last latency statistics push.
- * Return the time at which we should wake up next.
*/
-nsecs_t InputDispatcher::processLatencyStatisticsLocked() {
+void InputDispatcher::processLatencyStatisticsLocked() {
const nsecs_t currentTime = now();
// Log the atom recording latency statistics if more than 6 hours passed from the last
// push
@@ -1127,7 +1125,6 @@
mInputEventTimelineProcessor->pushLatencyStatistics();
mLastStatisticPushTime = currentTime;
}
- return mLastStatisticPushTime + LATENCY_STATISTICS_PUSH_INTERVAL;
}
std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(