Add full action printout to MotionEvent
Currently, not all actions are being printed in the input dump. This
results in hard-to-debug cases like the hover issue with multi-finger
operation before screen off.
Add printouts for all known action values, and add a number printout in
case an invalid value is received.
Bug: 169785626
Bug: 164506345
Test: adb shell dumpsys input
Change-Id: I885bf311eb28cca153887ebb382528927a736041
diff --git a/include/input/Input.h b/include/input/Input.h
index 7d81fed..ced1d0e 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -730,7 +730,7 @@
static const char* getLabel(int32_t axis);
static int32_t getAxisFromLabel(const char* label);
- static const char* actionToString(int32_t action);
+ static std::string actionToString(int32_t action);
protected:
int32_t mAction;
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index fb2f186..c6604cb 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -19,9 +19,11 @@
#include <attestation/HmacKeyManager.h>
#include <cutils/compiler.h>
+#include <inttypes.h>
#include <limits.h>
#include <string.h>
+#include <android-base/stringprintf.h>
#include <input/Input.h>
#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
@@ -31,6 +33,8 @@
#include <sys/random.h>
#endif
+using android::base::StringPrintf;
+
namespace android {
const char* motionClassificationToString(MotionClassification classification) {
@@ -700,23 +704,37 @@
return InputEventLookup::getAxisByLabel(label);
}
-const char* MotionEvent::actionToString(int32_t action) {
+std::string MotionEvent::actionToString(int32_t action) {
// Convert MotionEvent action to string
switch (action & AMOTION_EVENT_ACTION_MASK) {
case AMOTION_EVENT_ACTION_DOWN:
return "DOWN";
- case AMOTION_EVENT_ACTION_MOVE:
- return "MOVE";
case AMOTION_EVENT_ACTION_UP:
return "UP";
+ case AMOTION_EVENT_ACTION_MOVE:
+ return "MOVE";
case AMOTION_EVENT_ACTION_CANCEL:
return "CANCEL";
+ case AMOTION_EVENT_ACTION_OUTSIDE:
+ return "OUTSIDE";
case AMOTION_EVENT_ACTION_POINTER_DOWN:
return "POINTER_DOWN";
case AMOTION_EVENT_ACTION_POINTER_UP:
return "POINTER_UP";
+ case AMOTION_EVENT_ACTION_HOVER_MOVE:
+ return "HOVER_MOVE";
+ case AMOTION_EVENT_ACTION_SCROLL:
+ return "SCROLL";
+ case AMOTION_EVENT_ACTION_HOVER_ENTER:
+ return "HOVER_ENTER";
+ case AMOTION_EVENT_ACTION_HOVER_EXIT:
+ return "HOVER_EXIT";
+ case AMOTION_EVENT_ACTION_BUTTON_PRESS:
+ return "BUTTON_PRESS";
+ case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
+ return "BUTTON_RELEASE";
}
- return "UNKNOWN";
+ return android::base::StringPrintf("%" PRId32, action);
}
// --- FocusEvent ---
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index 5103b4c..29df00b 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -207,10 +207,10 @@
"buttonState=0x%08x, "
"classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, "
"xCursorPosition=%0.1f, yCursorPosition=%0.1f, pointers=[",
- deviceId, eventTime, source, displayId, MotionEvent::actionToString(action),
- actionButton, flags, metaState, buttonState,
- motionClassificationToString(classification), edgeFlags, xPrecision,
- yPrecision, xCursorPosition, yCursorPosition);
+ deviceId, eventTime, source, displayId,
+ MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState,
+ buttonState, motionClassificationToString(classification), edgeFlags,
+ xPrecision, yPrecision, xCursorPosition, yCursorPosition);
for (uint32_t i = 0; i < pointerCount; i++) {
if (i) {