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

Commit 4c9d6ffc authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Add const annotations to dispatcher

These allow us to dump the dispatcher state from other const dispatcher
methods.

Bug: 274073185
Test: m
Change-Id: I483d957b243bca595c147656d8305fdc4f43fb33
parent 5f141a03
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1297,7 +1297,7 @@ bool InputDispatcher::isAppSwitchKeyEvent(const KeyEntry& keyEntry) {
            (keyEntry.policyFlags & POLICY_FLAG_PASS_TO_USER);
}

bool InputDispatcher::isAppSwitchPendingLocked() {
bool InputDispatcher::isAppSwitchPendingLocked() const {
    return mAppSwitchDueTime != LLONG_MAX;
}

@@ -5411,7 +5411,7 @@ void InputDispatcher::resetAndDropEverythingLocked(const char* reason) {
    mReplacedKeys.clear();
}

void InputDispatcher::logDispatchStateLocked() {
void InputDispatcher::logDispatchStateLocked() const {
    std::string dump;
    dumpDispatchStateLocked(dump);

@@ -5423,7 +5423,7 @@ void InputDispatcher::logDispatchStateLocked() {
    }
}

std::string InputDispatcher::dumpPointerCaptureStateLocked() {
std::string InputDispatcher::dumpPointerCaptureStateLocked() const {
    std::string dump;

    dump += StringPrintf(INDENT "Pointer Capture Requested: %s\n",
@@ -5441,7 +5441,7 @@ std::string InputDispatcher::dumpPointerCaptureStateLocked() {
    return dump;
}

void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
void InputDispatcher::dumpDispatchStateLocked(std::string& dump) const {
    dump += StringPrintf(INDENT "DispatchEnabled: %s\n", toString(mDispatchEnabled));
    dump += StringPrintf(INDENT "DispatchFrozen: %s\n", toString(mDispatchFrozen));
    dump += StringPrintf(INDENT "InputFilterEnabled: %s\n", toString(mInputFilterEnabled));
@@ -5544,7 +5544,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
    // Dump recently dispatched or dropped events from oldest to newest.
    if (!mRecentQueue.empty()) {
        dump += StringPrintf(INDENT "RecentQueue: length=%zu\n", mRecentQueue.size());
        for (std::shared_ptr<EventEntry>& entry : mRecentQueue) {
        for (const std::shared_ptr<EventEntry>& entry : mRecentQueue) {
            dump += INDENT2;
            dump += entry->getDescription();
            dump += StringPrintf(", age=%" PRId64 "ms\n", ns2ms(currentTime - entry->eventTime));
@@ -5567,7 +5567,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
    // Dump inbound events from oldest to newest.
    if (!mInboundQueue.empty()) {
        dump += StringPrintf(INDENT "InboundQueue: length=%zu\n", mInboundQueue.size());
        for (std::shared_ptr<EventEntry>& entry : mInboundQueue) {
        for (const std::shared_ptr<EventEntry>& entry : mInboundQueue) {
            dump += INDENT2;
            dump += entry->getDescription();
            dump += StringPrintf(", age=%" PRId64 "ms\n", ns2ms(currentTime - entry->eventTime));
@@ -5649,7 +5649,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
    dump += mLatencyAggregator.dump(INDENT2);
}

void InputDispatcher::dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors) {
void InputDispatcher::dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors) const {
    const size_t numMonitors = monitors.size();
    for (size_t i = 0; i < numMonitors; i++) {
        const Monitor& monitor = monitors[i];
+5 −5
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ private:
    nsecs_t mAppSwitchDueTime GUARDED_BY(mLock);

    bool isAppSwitchKeyEvent(const KeyEntry& keyEntry);
    bool isAppSwitchPendingLocked() REQUIRES(mLock);
    bool isAppSwitchPendingLocked() const REQUIRES(mLock);
    void resetPendingAppSwitchLocked(bool handled) REQUIRES(mLock);

    // Blocked event latency optimization.  Drops old events when the user intends
@@ -647,10 +647,10 @@ private:
    void resetAndDropEverythingLocked(const char* reason) REQUIRES(mLock);

    // Dump state.
    void dumpDispatchStateLocked(std::string& dump) REQUIRES(mLock);
    void dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors);
    void logDispatchStateLocked() REQUIRES(mLock);
    std::string dumpPointerCaptureStateLocked() REQUIRES(mLock);
    void dumpDispatchStateLocked(std::string& dump) const REQUIRES(mLock);
    void dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors) const;
    void logDispatchStateLocked() const REQUIRES(mLock);
    std::string dumpPointerCaptureStateLocked() const REQUIRES(mLock);

    // Registration.
    void removeMonitorChannelLocked(const sp<IBinder>& connectionToken) REQUIRES(mLock);
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ void LatencyAggregator::processSlowEvent(const InputEventTimeline& timeline) {
    }
}

std::string LatencyAggregator::dump(const char* prefix) {
std::string LatencyAggregator::dump(const char* prefix) const {
    std::string sketchDump = StringPrintf("%s  Sketches:\n", prefix);
    for (size_t i = 0; i < SketchIndex::SIZE; i++) {
        const int64_t numDown = mDownSketches[i]->num_values();
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public:
     */
    void processTimeline(const InputEventTimeline& timeline) override;

    std::string dump(const char* prefix);
    std::string dump(const char* prefix) const;

    ~LatencyAggregator();

+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ void LatencyTracker::reportAndPruneMatureRecords(nsecs_t newEventTime) {
    }
}

std::string LatencyTracker::dump(const char* prefix) {
std::string LatencyTracker::dump(const char* prefix) const {
    return StringPrintf("%sLatencyTracker:\n", prefix) +
            StringPrintf("%s  mTimelines.size() = %zu\n", prefix, mTimelines.size()) +
            StringPrintf("%s  mEventTimes.size() = %zu\n", prefix, mEventTimes.size());
Loading