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

Commit 6e1e987e authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Dump TouchState and TouchedWindow

These dumps will be expanded in the future as move state is moved into
these structures.

Bug: 211379801
Test: m inputflinger_tests && adb sync data && adb shell -t /data/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: Ic945e254f5e765ccb3c8b61e6a8e3f44095d07bf
parent 40b8fbd1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ filegroup {
        "LatencyAggregator.cpp",
        "LatencyTracker.cpp",
        "Monitor.cpp",
        "TouchedWindow.cpp",
        "TouchState.cpp",
    ],
}
+10 −28
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <gui/SurfaceComposerClient.h>
#endif
#include <input/InputDevice.h>
#include <input/PrintTools.h>
#include <powermanager/PowerManager.h>
#include <unistd.h>
#include <utils/Trace.h>
@@ -2232,11 +2233,10 @@ std::vector<TouchedWindow> InputDispatcher::findTouchedWindowTargetsLocked(

        // If the pointer is not currently down, then ignore the event.
        if (!tempTouchState.isDown()) {
            if (DEBUG_FOCUS) {
                ALOGD("Dropping event because the pointer is not down or we previously "
                      "dropped the pointer down event in display %" PRId32,
                      displayId);
            }
            ALOGD_IF(DEBUG_FOCUS,
                     "Dropping event because the pointer is not down or we previously "
                     "dropped the pointer down event in display %" PRId32 ": %s",
                     displayId, entry.getDescription().c_str());
            outInjectionResult = InputEventInjectionResult::FAILED;
            goto Failed;
        }
@@ -2443,10 +2443,8 @@ Failed:
    if (isHoverAction) {
        // Started hovering, therefore no longer down.
        if (oldState && oldState->isDown()) {
            if (DEBUG_FOCUS) {
                ALOGD("Conflicting pointer actions: Hover received while pointer was "
                      "down.");
            }
            ALOGD_IF(DEBUG_FOCUS,
                     "Conflicting pointer actions: Hover received while pointer was down.");
            *outConflictingPointerActions = true;
        }
        tempTouchState.reset();
@@ -2462,9 +2460,7 @@ Failed:
    } else if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
        // First pointer went down.
        if (oldState && oldState->isDown()) {
            if (DEBUG_FOCUS) {
            ALOGD("Conflicting pointer actions: Down received while already down.");
            }
            *outConflictingPointerActions = true;
        }
    } else if (maskedAction == AMOTION_EVENT_ACTION_POINTER_UP) {
@@ -5320,22 +5316,8 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
    if (!mTouchStatesByDisplay.empty()) {
        dump += StringPrintf(INDENT "TouchStatesByDisplay:\n");
        for (const auto& [displayId, state] : mTouchStatesByDisplay) {
            dump += StringPrintf(INDENT2 "%d: deviceId=%d, source=0x%08x\n", displayId,
                                 state.deviceId, state.source);
            if (!state.windows.empty()) {
                dump += INDENT3 "Windows:\n";
                for (size_t i = 0; i < state.windows.size(); i++) {
                    const TouchedWindow& touchedWindow = state.windows[i];
                    dump += StringPrintf(INDENT4 "%zu: name='%s', pointerIds=0x%0x, "
                                                 "targetFlags=0x%x, firstDownTimeInTarget=%" PRId64
                                                 "ms\n",
                                         i, touchedWindow.windowHandle->getName().c_str(),
                                         touchedWindow.pointerIds.value, touchedWindow.targetFlags,
                                         ns2ms(touchedWindow.firstDownTimeInTarget.value_or(0)));
                }
            } else {
                dump += INDENT3 "Windows: <none>\n";
            }
            std::string touchStateDump = addLinePrefix(state.dump(), INDENT2);
            dump += INDENT2 + std::to_string(displayId) + " : " + touchStateDump;
        }
    } else {
        dump += INDENT "TouchStates: <no displays touched>\n";
+17 −1
Original line number Diff line number Diff line
@@ -14,12 +14,13 @@
 * limitations under the License.
 */

#include <android-base/stringprintf.h>
#include <gui/WindowInfo.h>

#include "InputTarget.h"

#include "TouchState.h"

using android::base::StringPrintf;
using android::gui::WindowInfo;
using android::gui::WindowInfoHandle;

@@ -143,4 +144,19 @@ bool TouchState::isDown() const {
                       [](const TouchedWindow& window) { return !window.pointerIds.isEmpty(); });
}

std::string TouchState::dump() const {
    std::string out;
    out += StringPrintf("deviceId=%d, source=0x%08x\n", deviceId, source);
    if (!windows.empty()) {
        out += "  Windows:\n";
        for (size_t i = 0; i < windows.size(); i++) {
            const TouchedWindow& touchedWindow = windows[i];
            out += StringPrintf("    %zu : ", i) + touchedWindow.dump();
        }
    } else {
        out += "  Windows: <none>\n";
    }
    return out;
}

} // namespace android::inputdispatcher
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

#pragma once

#include "Monitor.h"
#include "TouchedWindow.h"

namespace android {
@@ -57,6 +56,7 @@ struct TouchState {
    sp<android::gui::WindowInfoHandle> getWallpaperWindow() const;
    // Whether any of the windows are currently being touched
    bool isDown() const;
    std::string dump() const;
};

} // namespace inputdispatcher
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "TouchedWindow.h"

#include <android-base/stringprintf.h>
#include <input/PrintTools.h>

using android::base::StringPrintf;

namespace android {

namespace inputdispatcher {

std::string TouchedWindow::dump() const {
    return StringPrintf("name='%s', pointerIds=0x%0x, "
                        "targetFlags=0x%x, firstDownTimeInTarget=%s\n",
                        windowHandle->getName().c_str(), pointerIds.value, targetFlags,
                        toString(firstDownTimeInTarget).c_str());
}

} // namespace inputdispatcher
} // namespace android
Loading