InputTracer: Minor readability improvements
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I8f97648dc7ce926aec9f84423fc1ef603ca57eae
diff --git a/services/inputflinger/dispatcher/trace/InputTracer.h b/services/inputflinger/dispatcher/trace/InputTracer.h
index c8b25c9..1acac6d 100644
--- a/services/inputflinger/dispatcher/trace/InputTracer.h
+++ b/services/inputflinger/dispatcher/trace/InputTracer.h
@@ -51,13 +51,16 @@
// The state of a tracked event.
struct EventState {
+ explicit inline EventState(TracedEvent event) : event(std::move(event)){};
+
const TracedEvent event;
+ bool isEventProcessingComplete{false};
// TODO(b/210460522): Add additional args for tracking event sensitivity and
// dispatch target UIDs.
};
// Get the event state associated with a tracking cookie.
- std::optional<EventState>& getState(const EventTrackerInterface&);
+ EventState& getState(const EventTrackerInterface&);
// Implementation of the event tracker cookie. The cookie holds the event state directly for
// convenience to avoid the overhead of tracking the state separately in InputTracer.
@@ -68,11 +71,9 @@
private:
InputTracer& mTracer;
- // This event tracker cookie will only hold the state as long as it has not been written
- // to the trace. The state is released when the event is written to the trace.
- mutable std::optional<EventState> mState;
+ mutable EventState mState;
- friend std::optional<EventState>& InputTracer::getState(const EventTrackerInterface&);
+ friend EventState& InputTracer::getState(const EventTrackerInterface&);
};
};