From d010b014dc42f55b5973c8329ab10dd69da92c77 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 18 Jan 2023 15:00:53 -0800 Subject: Improve debug prints in InputDispatcher It's useful sometimes to print out the events produced by the dispatcher. In this CL: - Switch (partially) to the C++-style prints from android-base - Add a way to print keyevents, motionevent into a stream - Add InputEventInjectionResult print Also, improve the debug prints for outgoing events. When an entry is getting dispatched, the dispatcher may modify its action, among other variables. With this CL, this will be observable in the logs. Bug: 211379801 Test: atest AccessibilityEndToEndTest Change-Id: I221161af7903ae4da77733265c67a426a3e5b557 --- libs/input/Input.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libs/input/Input.cpp') diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index c7964393e0..c356c2e5e9 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -343,6 +343,28 @@ const char* KeyEvent::actionToString(int32_t action) { return "UNKNOWN"; } +std::ostream& operator<<(std::ostream& out, const KeyEvent& event) { + out << "KeyEvent { action=" << KeyEvent::actionToString(event.getAction()); + + out << ", keycode=" << event.getKeyCode() << "(" << KeyEvent::getLabel(event.getKeyCode()) + << ")"; + + if (event.getMetaState() != 0) { + out << ", metaState=" << event.getMetaState(); + } + + out << ", eventTime=" << event.getEventTime(); + out << ", downTime=" << event.getDownTime(); + out << ", flags=" << std::hex << event.getFlags() << std::dec; + out << ", repeatCount=" << event.getRepeatCount(); + out << ", deviceId=" << event.getDeviceId(); + out << ", source=" << inputEventSourceToString(event.getSource()); + out << ", displayId=" << event.getDisplayId(); + out << ", eventId=" << event.getId(); + out << "}"; + return out; +} + // --- PointerCoords --- float PointerCoords::getAxisValue(int32_t axis) const { -- cgit v1.2.3-59-g8ed1b