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

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

Add dump for InputState and InputTarget

These are useful when you want to print these variables for debugging.
Currently, InputState isn't even shown in the dispatcher dump. Include
it there.

Also, update some types to use DeviceId.

Bug: 211379801
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
Change-Id: Ifc983a653d9f1f546b71b8404f67caa1c89d3b01
parent 227a7f8f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -119,6 +119,10 @@ inline nsecs_t now() {
    return systemTime(SYSTEM_TIME_MONOTONIC);
}

bool isEmpty(const std::stringstream& ss) {
    return ss.rdbuf()->in_avail() == 0;
}

inline const std::string binderToString(const sp<IBinder>& binder) {
    if (binder == nullptr) {
        return "<null>";
@@ -5779,6 +5783,12 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) const {
            } else {
                dump += INDENT3 "WaitQueue: <empty>\n";
            }
            std::stringstream inputStateDump;
            inputStateDump << connection->inputState;
            if (!isEmpty(inputStateDump)) {
                dump += INDENT3 "InputState: ";
                dump += inputStateDump.str() + "\n";
            }
        }
    } else {
        dump += INDENT "Connections: <none>\n";
+0 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include "InputDispatcherConfiguration.h"
#include "InputDispatcherInterface.h"
#include "InputDispatcherPolicyInterface.h"
#include "InputState.h"
#include "InputTarget.h"
#include "InputThread.h"
#include "LatencyAggregator.h"
+10 −0
Original line number Diff line number Diff line
@@ -525,4 +525,14 @@ bool InputState::shouldCancelMotion(const MotionMemento& memento,
    }
}

std::ostream& operator<<(std::ostream& out, const InputState& state) {
    if (!state.mMotionMementos.empty()) {
        out << "mMotionMementos: ";
        for (const InputState::MotionMemento& memento : state.mMotionMementos) {
            out << "{deviceId= " << memento.deviceId << ", hovering=" << memento.hovering << "}, ";
        }
    }
    return out;
}

} // namespace android::inputdispatcher
+3 −0
Original line number Diff line number Diff line
@@ -128,7 +128,10 @@ private:
    std::vector<std::unique_ptr<MotionEntry>> synthesizeCancelationEventsForPointers(
            const MotionMemento& memento, std::bitset<MAX_POINTER_ID + 1> pointerIds,
            nsecs_t currentTime);
    friend std::ostream& operator<<(std::ostream& out, const InputState& state);
};

std::ostream& operator<<(std::ostream& out, const InputState& state);

} // namespace inputdispatcher
} // namespace android
+20 −0
Original line number Diff line number Diff line
@@ -76,4 +76,24 @@ std::string InputTarget::getPointerInfoString() const {
    }
    return out;
}

std::ostream& operator<<(std::ostream& out, const InputTarget& target) {
    out << "{inputChannel=";
    if (target.inputChannel != nullptr) {
        out << target.inputChannel->getName();
    } else {
        out << "<null>";
    }
    out << ", windowHandle=";
    if (target.windowHandle != nullptr) {
        out << target.windowHandle->getName();
    } else {
        out << "<null>";
    }
    out << ", targetFlags=" << target.flags.string();
    out << ", pointers=" << target.getPointerInfoString();
    out << "}";
    return out;
}

} // namespace android::inputdispatcher
Loading