Make EventEntry const throughout the Dispatcher pipieline
This will help ensure that parts of the event do not change throughout
the dispatching pipieline after they are traced, and that the parts that
do change during dispatch are explicitly tracked.
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I2738d1a37da7ce72525d59c65f910a6fec09f862
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index 2d1a22b..ebc04cf 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -139,15 +139,15 @@
source(source),
displayId(displayId),
action(action),
- flags(flags),
keyCode(keyCode),
scanCode(scanCode),
metaState(metaState),
- repeatCount(repeatCount),
downTime(downTime),
syntheticRepeat(false),
interceptKeyResult(KeyEntry::InterceptKeyResult::UNKNOWN),
- interceptKeyWakeupTime(0) {
+ interceptKeyWakeupTime(0),
+ flags(flags),
+ repeatCount(repeatCount) {
EventEntry::injectionState = std::move(injectionState);
}
@@ -276,7 +276,7 @@
volatile int32_t DispatchEntry::sNextSeqAtomic;
-DispatchEntry::DispatchEntry(std::shared_ptr<EventEntry> eventEntry,
+DispatchEntry::DispatchEntry(std::shared_ptr<const EventEntry> eventEntry,
ftl::Flags<InputTarget::Flags> targetFlags,
const ui::Transform& transform, const ui::Transform& rawTransform,
float globalScaleFactor)
@@ -291,7 +291,7 @@
resolvedFlags(0) {
switch (this->eventEntry->type) {
case EventEntry::Type::KEY: {
- const KeyEntry& keyEntry = static_cast<KeyEntry&>(*this->eventEntry);
+ const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*this->eventEntry);
resolvedEventId = keyEntry.id;
resolvedAction = keyEntry.action;
resolvedFlags = keyEntry.flags;
@@ -299,7 +299,7 @@
break;
}
case EventEntry::Type::MOTION: {
- const MotionEntry& motionEntry = static_cast<MotionEntry&>(*this->eventEntry);
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*this->eventEntry);
resolvedEventId = motionEntry.id;
resolvedAction = motionEntry.action;
resolvedFlags = motionEntry.flags;