diff options
author | 2024-02-21 19:19:47 +0000 | |
---|---|---|
committer | 2024-03-14 19:55:46 +0000 | |
commit | 4b408beb74c6d9f561e36d4c416d2a94a46af29d (patch) | |
tree | 84a6d0b8d6c34f05c643f247864035349a29f8fe | |
parent | 8c3b143e1349ed443cc2cb660e45ebd666b5ffec (diff) |
InputTracer: Don't make WindowDispatchArgs an inner class
For consistency with other structs and definitions in the backend
interface, move WindowDispatchArgs outside of the interface class.
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I9fe98448bace259faa40b082981211fdf9b1e221
7 files changed, 24 insertions, 30 deletions
diff --git a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp index a61fa85d6e..cee741cfc7 100644 --- a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp +++ b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp @@ -72,8 +72,7 @@ void AndroidInputEventProtoConverter::toProtoKeyEvent(const TracedKeyEvent& even } void AndroidInputEventProtoConverter::toProtoWindowDispatchEvent( - const InputTracingBackendInterface::WindowDispatchArgs& args, - proto::AndroidWindowInputDispatchEvent& outProto) { + const WindowDispatchArgs& args, proto::AndroidWindowInputDispatchEvent& outProto) { std::visit([&](auto entry) { outProto.set_event_id(entry.id); }, args.eventEntry); outProto.set_vsync_id(args.vsyncId); outProto.set_window_id(args.windowId); diff --git a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.h b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.h index 8a46f1518b..ab5f9ca610 100644 --- a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.h +++ b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.h @@ -32,7 +32,7 @@ public: static void toProtoMotionEvent(const TracedMotionEvent& event, proto::AndroidMotionEvent& outProto); static void toProtoKeyEvent(const TracedKeyEvent& event, proto::AndroidKeyEvent& outProto); - static void toProtoWindowDispatchEvent(const InputTracingBackendInterface::WindowDispatchArgs&, + static void toProtoWindowDispatchEvent(const WindowDispatchArgs&, proto::AndroidWindowInputDispatchEvent& outProto); }; diff --git a/services/inputflinger/dispatcher/trace/InputTracer.h b/services/inputflinger/dispatcher/trace/InputTracer.h index 458f4aadc9..4ef6ca61ae 100644 --- a/services/inputflinger/dispatcher/trace/InputTracer.h +++ b/services/inputflinger/dispatcher/trace/InputTracer.h @@ -52,8 +52,6 @@ public: private: std::unique_ptr<InputTracingBackendInterface> mBackend; - using WindowDispatchArgs = InputTracingBackendInterface::WindowDispatchArgs; - // The state of a tracked event, shared across all events derived from the original event. struct EventState { explicit inline EventState(InputTracer& tracer) : tracer(tracer){}; diff --git a/services/inputflinger/dispatcher/trace/InputTracingBackendInterface.h b/services/inputflinger/dispatcher/trace/InputTracingBackendInterface.h index 865e8277c0..6eef12e536 100644 --- a/services/inputflinger/dispatcher/trace/InputTracingBackendInterface.h +++ b/services/inputflinger/dispatcher/trace/InputTracingBackendInterface.h @@ -80,6 +80,20 @@ struct TracedEventArgs { bool isSecure; }; +/** Additional information about an input event being dispatched to a window. */ +struct WindowDispatchArgs { + TracedEvent eventEntry; + nsecs_t deliveryTime; + int32_t resolvedFlags; + gui::Uid targetUid; + int64_t vsyncId; + int32_t windowId; + ui::Transform transform; + ui::Transform rawTransform; + std::array<uint8_t, 32> hmac; + int32_t resolvedKeyRepeatCount; +}; + /** * An interface for the tracing backend, used for setting a custom backend for testing. */ @@ -94,18 +108,6 @@ public: virtual void traceMotionEvent(const TracedMotionEvent&, const TracedEventArgs&) = 0; /** Trace an event being sent to a window. */ - struct WindowDispatchArgs { - TracedEvent eventEntry; - nsecs_t deliveryTime; - int32_t resolvedFlags; - gui::Uid targetUid; - int64_t vsyncId; - int32_t windowId; - ui::Transform transform; - ui::Transform rawTransform; - std::array<uint8_t, 32> hmac; - int32_t resolvedKeyRepeatCount; - }; virtual void traceWindowDispatch(const WindowDispatchArgs&, const TracedEventArgs&) = 0; }; diff --git a/services/inputflinger/dispatcher/trace/ThreadedBackend.h b/services/inputflinger/dispatcher/trace/ThreadedBackend.h index 5d4efbb7e9..cab47af1c1 100644 --- a/services/inputflinger/dispatcher/trace/ThreadedBackend.h +++ b/services/inputflinger/dispatcher/trace/ThreadedBackend.h @@ -53,8 +53,6 @@ private: TracedEventArgs>; std::vector<TraceEntry> mQueue GUARDED_BY(mLock); - using WindowDispatchArgs = InputTracingBackendInterface::WindowDispatchArgs; - void threadLoop(); }; diff --git a/services/inputflinger/tests/FakeInputTracingBackend.cpp b/services/inputflinger/tests/FakeInputTracingBackend.cpp index dc74f84d2c..069b50d051 100644 --- a/services/inputflinger/tests/FakeInputTracingBackend.cpp +++ b/services/inputflinger/tests/FakeInputTracingBackend.cpp @@ -37,10 +37,9 @@ inline auto getId(const trace::TracedEvent& v) { return std::visit([](const auto& event) { return event.id; }, v); } -MotionEvent toInputEvent( - const trace::TracedMotionEvent& e, - const trace::InputTracingBackendInterface::WindowDispatchArgs& dispatchArgs, - const std::array<uint8_t, 32>& hmac) { +MotionEvent toInputEvent(const trace::TracedMotionEvent& e, + const trace::WindowDispatchArgs& dispatchArgs, + const std::array<uint8_t, 32>& hmac) { MotionEvent traced; traced.initialize(e.id, e.deviceId, e.source, e.displayId, hmac, e.action, e.actionButton, dispatchArgs.resolvedFlags, e.edgeFlags, e.metaState, e.buttonState, @@ -51,8 +50,7 @@ MotionEvent toInputEvent( return traced; } -KeyEvent toInputEvent(const trace::TracedKeyEvent& e, - const trace::InputTracingBackendInterface::WindowDispatchArgs& dispatchArgs, +KeyEvent toInputEvent(const trace::TracedKeyEvent& e, const trace::WindowDispatchArgs& dispatchArgs, const std::array<uint8_t, 32>& hmac) { KeyEvent traced; traced.initialize(e.id, e.deviceId, e.source, e.displayId, hmac, e.action, @@ -120,7 +118,7 @@ base::Result<void> VerifyingTrace::verifyEventTraced(const Event& expectedEvent, auto tracedDispatchesIt = std::find_if(mTracedWindowDispatches.begin(), mTracedWindowDispatches.end(), - [&](const WindowDispatchArgs& args) { + [&](const trace::WindowDispatchArgs& args) { return args.windowId == expectedWindowId && getId(args.eventEntry) == expectedEvent.getId(); }); @@ -181,7 +179,7 @@ void FakeInputTracingBackend::traceMotionEvent(const trace::TracedMotionEvent& e mTrace->mEventTracedCondition.notify_all(); } -void FakeInputTracingBackend::traceWindowDispatch(const WindowDispatchArgs& args, +void FakeInputTracingBackend::traceWindowDispatch(const trace::WindowDispatchArgs& args, const trace::TracedEventArgs&) { { std::scoped_lock lock(mTrace->mLock); diff --git a/services/inputflinger/tests/FakeInputTracingBackend.h b/services/inputflinger/tests/FakeInputTracingBackend.h index b149ffe7d8..ab05d6b532 100644 --- a/services/inputflinger/tests/FakeInputTracingBackend.h +++ b/services/inputflinger/tests/FakeInputTracingBackend.h @@ -59,8 +59,7 @@ private: std::mutex mLock; std::condition_variable mEventTracedCondition; std::unordered_map<uint32_t /*eventId*/, trace::TracedEvent> mTracedEvents GUARDED_BY(mLock); - using WindowDispatchArgs = trace::InputTracingBackendInterface::WindowDispatchArgs; - std::vector<WindowDispatchArgs> mTracedWindowDispatches GUARDED_BY(mLock); + std::vector<trace::WindowDispatchArgs> mTracedWindowDispatches GUARDED_BY(mLock); std::vector<std::pair<std::variant<KeyEvent, MotionEvent>, int32_t /*windowId*/>> mExpectedEvents GUARDED_BY(mLock); @@ -86,7 +85,7 @@ private: void traceKeyEvent(const trace::TracedKeyEvent& entry, const trace::TracedEventArgs&) override; void traceMotionEvent(const trace::TracedMotionEvent& entry, const trace::TracedEventArgs&) override; - void traceWindowDispatch(const WindowDispatchArgs& entry, + void traceWindowDispatch(const trace::WindowDispatchArgs& entry, const trace::TracedEventArgs&) override; }; |