Skip to content

Commit e0226c5

Browse files
author
Asmita Poddar
committed
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
1 parent 00488b0 commit e0226c5

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,7 @@ void InputDispatcher::dispatchOnce() {
10311031
nextWakeupTime = std::min(nextWakeupTime, nextAnrCheck);
10321032

10331033
if (mPerDeviceInputLatencyMetricsFlag) {
1034-
const nsecs_t nextStatisticsPush = processLatencyStatisticsLocked();
1035-
nextWakeupTime = std::min(nextWakeupTime, nextStatisticsPush);
1034+
processLatencyStatisticsLocked();
10361035
}
10371036

10381037
// We are about to enter an infinitely long sleep, because we have no commands or
@@ -1117,17 +1116,15 @@ nsecs_t InputDispatcher::processAnrsLocked() {
11171116

11181117
/**
11191118
* Check if enough time has passed since the last latency statistics push.
1120-
* Return the time at which we should wake up next.
11211119
*/
1122-
nsecs_t InputDispatcher::processLatencyStatisticsLocked() {
1120+
void InputDispatcher::processLatencyStatisticsLocked() {
11231121
const nsecs_t currentTime = now();
11241122
// Log the atom recording latency statistics if more than 6 hours passed from the last
11251123
// push
11261124
if (currentTime - mLastStatisticPushTime >= LATENCY_STATISTICS_PUSH_INTERVAL) {
11271125
mInputEventTimelineProcessor->pushLatencyStatistics();
11281126
mLastStatisticPushTime = currentTime;
11291127
}
1130-
return mLastStatisticPushTime + LATENCY_STATISTICS_PUSH_INTERVAL;
11311128
}
11321129

11331130
std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(

services/inputflinger/dispatcher/InputDispatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class InputDispatcher : public android::InputDispatcherInterface {
329329
std::chrono::nanoseconds mMonitorDispatchingTimeout GUARDED_BY(mLock);
330330

331331
nsecs_t processAnrsLocked() REQUIRES(mLock);
332-
nsecs_t processLatencyStatisticsLocked() REQUIRES(mLock);
332+
void processLatencyStatisticsLocked() REQUIRES(mLock);
333333
std::chrono::nanoseconds getDispatchingTimeoutLocked(
334334
const std::shared_ptr<Connection>& connection) REQUIRES(mLock);
335335

0 commit comments

Comments
 (0)