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

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

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
parent d5095e76
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -550,6 +550,8 @@ protected:
    nsecs_t mEventTime;
};

std::ostream& operator<<(std::ostream& out, const KeyEvent& event);

/*
 * Motion events.
 */
+22 −0
Original line number Diff line number Diff line
@@ -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 {
+3 −0
Original line number Diff line number Diff line
@@ -37,4 +37,7 @@ enum InputEventInjectionResult {

    /* Injection failed due to a timeout. */
    TIMED_OUT = 3,

    ftl_first=PENDING,
    ftl_last=TIMED_OUT,
}
+24 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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);
Loading