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
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index 7bbfb95..ce7c882 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -331,4 +331,28 @@
return seq;
}
+std::ostream& operator<<(std::ostream& out, const DispatchEntry& entry) {
+ out << "DispatchEntry{resolvedAction=";
+ switch (entry.eventEntry->type) {
+ case EventEntry::Type::KEY: {
+ out << KeyEvent::actionToString(entry.resolvedAction);
+ break;
+ }
+ case EventEntry::Type::MOTION: {
+ out << MotionEvent::actionToString(entry.resolvedAction);
+ break;
+ }
+ default: {
+ out << "<invalid, not a key or a motion>";
+ break;
+ }
+ }
+ std::string transform;
+ entry.transform.dump(transform, "transform");
+ out << ", resolvedFlags=" << entry.resolvedFlags
+ << ", targetFlags=" << entry.targetFlags.string() << ", transform=" << transform
+ << "} original =" << entry.eventEntry->getDescription();
+ return out;
+}
+
} // namespace android::inputdispatcher