diff options
-rw-r--r-- | include/input/Input.h | 2 | ||||
-rw-r--r-- | libs/input/Input.cpp | 22 | ||||
-rw-r--r-- | libs/input/android/os/InputEventInjectionResult.aidl | 3 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/Entry.cpp | 24 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/Entry.h | 2 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 18 |
6 files changed, 69 insertions, 2 deletions
diff --git a/include/input/Input.h b/include/input/Input.h index e281675a33..30b0d6a67a 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -550,6 +550,8 @@ protected: nsecs_t mEventTime; }; +std::ostream& operator<<(std::ostream& out, const KeyEvent& event); + /* * Motion events. */ 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 { diff --git a/libs/input/android/os/InputEventInjectionResult.aidl b/libs/input/android/os/InputEventInjectionResult.aidl index 3bc7068f3c..e80c2a52dc 100644 --- a/libs/input/android/os/InputEventInjectionResult.aidl +++ b/libs/input/android/os/InputEventInjectionResult.aidl @@ -37,4 +37,7 @@ enum InputEventInjectionResult { /* Injection failed due to a timeout. */ TIMED_OUT = 3, + + ftl_first=PENDING, + ftl_last=TIMED_OUT, } diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp index 7bbfb95b88..ce7c882f7d 100644 --- a/services/inputflinger/dispatcher/Entry.cpp +++ b/services/inputflinger/dispatcher/Entry.cpp @@ -331,4 +331,28 @@ uint32_t DispatchEntry::nextSeq() { 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 diff --git a/services/inputflinger/dispatcher/Entry.h b/services/inputflinger/dispatcher/Entry.h index 3799814f67..8dc2a2a221 100644 --- a/services/inputflinger/dispatcher/Entry.h +++ b/services/inputflinger/dispatcher/Entry.h @@ -254,6 +254,8 @@ private: static uint32_t nextSeq(); }; +std::ostream& operator<<(std::ostream& out, const DispatchEntry& entry); + VerifiedKeyEvent verifiedKeyEventFromKeyEntry(const KeyEntry& entry); VerifiedMotionEvent verifiedMotionEventFromMotionEntry(const MotionEntry& entry, const ui::Transform& rawTransform); diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 37a451b3dd..204fff4566 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -20,6 +20,7 @@ #define LOG_NDEBUG 1 #include <android-base/chrono_utils.h> +#include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android/os/IInputConstants.h> @@ -3382,6 +3383,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, case EventEntry::Type::KEY: { const KeyEntry& keyEntry = static_cast<const KeyEntry&>(eventEntry); std::array<uint8_t, 32> hmac = getSignature(keyEntry, *dispatchEntry); + if (DEBUG_OUTBOUND_EVENT_DETAILS) { + LOG(DEBUG) << "Publishing " << *dispatchEntry << " to " + << connection->getInputChannelName(); + } // Publish the key event. status = connection->inputPublisher @@ -3397,6 +3402,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, } case EventEntry::Type::MOTION: { + if (DEBUG_OUTBOUND_EVENT_DETAILS) { + LOG(DEBUG) << "Publishing " << *dispatchEntry << " to " + << connection->getInputChannelName(); + } status = publishMotionEvent(*connection, *dispatchEntry); break; } @@ -4448,6 +4457,9 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev bool needWake = false; while (!injectedEntries.empty()) { + if (DEBUG_INJECTION) { + LOG(DEBUG) << "Injecting " << injectedEntries.front()->getDescription(); + } needWake |= enqueueInboundEventLocked(std::move(injectedEntries.front())); injectedEntries.pop(); } @@ -4510,7 +4522,8 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev } // release lock if (DEBUG_INJECTION) { - ALOGD("injectInputEvent - Finished with result %d.", injectionResult); + LOG(DEBUG) << "injectInputEvent - Finished with result " + << ftl::enum_string(injectionResult); } return injectionResult; @@ -4554,7 +4567,8 @@ void InputDispatcher::setInjectionResult(EventEntry& entry, InjectionState* injectionState = entry.injectionState; if (injectionState) { if (DEBUG_INJECTION) { - ALOGD("Setting input event injection result to %d.", injectionResult); + LOG(DEBUG) << "Setting input event injection result to " + << ftl::enum_string(injectionResult); } if (injectionState->injectionIsAsync && !(entry.policyFlags & POLICY_FLAG_FILTERED)) { |