InputTracer: Trace resolved key repeat count during dispatch
Since the repeatCount in KeyEntry is mutable, it can change after an
event is traced, which is not ideal.
Until we change this behavior, we should trace the resolved repeat count
during dispatch to account for changed repeat counts.
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I86cdb2cbbd77b7bb834b9d8e66176837c113c1ca
diff --git a/services/inputflinger/dispatcher/trace/InputTracer.cpp b/services/inputflinger/dispatcher/trace/InputTracer.cpp
index 0be64e6..10f6b0f 100644
--- a/services/inputflinger/dispatcher/trace/InputTracer.cpp
+++ b/services/inputflinger/dispatcher/trace/InputTracer.cpp
@@ -107,6 +107,10 @@
void InputTracer::traceEventDispatch(const DispatchEntry& dispatchEntry,
const EventTrackerInterface* cookie) {
const EventEntry& entry = *dispatchEntry.eventEntry;
+ // TODO(b/328618922): Remove resolved key repeats after making repeatCount non-mutable.
+ // The KeyEntry's repeatCount is mutable and can be modified after an event is initially traced,
+ // so we need to find the repeatCount at the time of dispatching to trace it accurately.
+ int32_t resolvedKeyRepeatCount = 0;
TracedEvent traced;
if (entry.type == EventEntry::Type::MOTION) {
@@ -114,6 +118,7 @@
traced = createTracedEvent(motion);
} else if (entry.type == EventEntry::Type::KEY) {
const auto& key = static_cast<const KeyEntry&>(entry);
+ resolvedKeyRepeatCount = key.repeatCount;
traced = createTracedEvent(key);
} else {
LOG(FATAL) << "Cannot trace EventEntry of type: " << ftl::enum_string(entry.type);
@@ -133,7 +138,7 @@
mBackend->traceWindowDispatch({std::move(traced), dispatchEntry.deliveryTime,
dispatchEntry.resolvedFlags, dispatchEntry.targetUid, vsyncId,
windowId, dispatchEntry.transform, dispatchEntry.rawTransform,
- /*hmac=*/{}});
+ /*hmac=*/{}, resolvedKeyRepeatCount});
}
InputTracer::EventState& InputTracer::getState(const EventTrackerInterface& cookie) {