Gather latency metrics for key events
Currently, we are not gathering any latency data for key events. We want
to record latencies and report them using the new
InputEventLatencyReported atom.
In InputDispatcher, call LatencyTracker::trackListener from notifyKey to
gather latency statistics for key events. This will be done only if the
per device input latency metrics flag is enabled because We want to
gather these latency values using the new LatencyAggregator that uses
histograms.
Moved the sources resolution for motion events from InputDispatcher to
LatencyTracker.
Bug: 270049345
Test: atest inputflinger_tests
Flag: com.android.input.flags.enable_per_device_input_latency_metrics
Change-Id: Iadf7b7aecbb14db6f13e4c53ecc11d3ccccd646f
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 250e72c..7cb111a 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4511,6 +4511,14 @@
newEntry->traceTracker = mTracer->traceInboundEvent(*newEntry);
}
+ if (input_flags::enable_per_device_input_latency_metrics()) {
+ if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID &&
+ IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER &&
+ !mInputFilterEnabled) {
+ mLatencyTracker.trackNotifyKey(args);
+ }
+ }
+
needWake = enqueueInboundEventLocked(std::move(newEntry));
mLock.unlock();
} // release lock
@@ -4643,9 +4651,7 @@
if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID &&
IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER &&
!mInputFilterEnabled) {
- std::set<InputDeviceUsageSource> sources = getUsageSourcesForMotionArgs(args);
- mLatencyTracker.trackListener(args.id, args.eventTime, args.readTime, args.deviceId,
- sources, args.action, InputEventType::MOTION);
+ mLatencyTracker.trackNotifyMotion(args);
}
needWake = enqueueInboundEventLocked(std::move(newEntry));