Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c68fdeca authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

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
parent 2a32108a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ public:
    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;
+23 −5
Original line number Diff line number Diff line
@@ -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 @@ int32_t MotionEvent::getAxisFromLabel(const char* label) {
    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";
    }
    return "UNKNOWN";
        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 android::base::StringPrintf("%" PRId32, action);
}

// --- FocusEvent ---
+4 −4
Original line number Diff line number Diff line
@@ -207,10 +207,10 @@ std::string MotionEntry::getDescription() const {
                        "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) {