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

Commit 9ac502b3 authored by Linnan Li's avatar Linnan Li Committed by Cherrypicker Worker
Browse files

Associate the displayId with the input_interaction



Currently, the InputDispatcher supports the scenario where two displays
can be interacted with simultaneously. In this scenario, the
input_interaction logs will be printed frequently due to the
simultaneous interaction on the two displays, which will make the logs
completely unreadable.

Here, we associate the interaction state with the displays to optimize
the log output in this scenario and ensure that we can conduct normal
debugging.

Bug: 420517013
Test: Manual
Flag: EXEMPT bugfix

Signed-off-by: default avatarLinnan Li <lilinnan@xiaomi.corp-partner.google.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:5b2004ed9dda314829d772bb068c10a23a6b64c7)
Merged-In: I6ab30b33e57ad22e522390f7ebeafc953614141a
Change-Id: I6ab30b33e57ad22e522390f7ebeafc953614141a
parent e56409f2
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -3671,19 +3671,23 @@ void InputDispatcher::processInteractionsLocked(const EventEntry& entry,
                           };
    postCommandLocked(std::move(command));

    if (newConnectionTokens == mInteractionConnectionTokens) {
    const ui::LogicalDisplayId displayId = getTargetDisplayId(entry);
    if (const auto& it = mInteractionConnectionTokensByDisplay.find(displayId);
        it != mInteractionConnectionTokensByDisplay.end() && newConnectionTokens == it->second) {
        return; // no change
    }
    mInteractionConnectionTokens = newConnectionTokens;
    mInteractionConnectionTokensByDisplay[displayId] = newConnectionTokens;

    std::string targetList;
    std::string targetList = "[";
    for (const std::shared_ptr<Connection>& connection : newConnections) {
        targetList += connection->getInputChannelName() + ",";
    }
    std::string message = "Interaction with: " + targetList;
    if (targetList.empty()) {
        message += "<none>";
    if (!newConnections.empty()) {
        targetList.pop_back();
    }
    targetList += "]";
    const std::string message =
            "Interaction with: " + targetList + ", on displayId " + displayId.toString();
    android_log_event_list(LOGTAG_INPUT_INTERACTION) << message << LOG_ID_EVENTS;
}

@@ -5820,7 +5824,7 @@ bool InputDispatcher::setInTouchMode(bool inTouchMode, gui::Pid pid, gui::Uid ui
        }
        if (!hasPermission) {
            if (!focusedWindowIsOwnedByLocked(pid, uid) &&
                !recentWindowsAreOwnedByLocked(pid, uid)) {
                !recentWindowsAreOwnedByLocked(displayId, pid, uid)) {
                ALOGD("Touch mode switch rejected, caller (pid=%s, uid=%s) doesn't own the focused "
                      "window nor none of the previously interacted window",
                      pid.toString().c_str(), uid.toString().c_str());
@@ -5848,13 +5852,19 @@ bool InputDispatcher::focusedWindowIsOwnedByLocked(gui::Pid pid, gui::Uid uid) {
    return isWindowOwnedBy(windowHandle, pid, uid);
}

bool InputDispatcher::recentWindowsAreOwnedByLocked(gui::Pid pid, gui::Uid uid) {
    return std::find_if(mInteractionConnectionTokens.begin(), mInteractionConnectionTokens.end(),
bool InputDispatcher::recentWindowsAreOwnedByLocked(ui::LogicalDisplayId displayId, gui::Pid pid,
                                                    gui::Uid uid) {
    const auto& it = mInteractionConnectionTokensByDisplay.find(displayId);
    if (it == mInteractionConnectionTokensByDisplay.end()) {
        return false;
    }
    const auto& interactionConnectionTokens = it->second;
    return std::find_if(interactionConnectionTokens.begin(), interactionConnectionTokens.end(),
                        [&](const sp<IBinder>& connectionToken) REQUIRES(mLock) {
                            const sp<WindowInfoHandle> windowHandle =
                                    mWindowInfos.findWindowHandle(connectionToken);
                            return isWindowOwnedBy(windowHandle, pid, uid);
                        }) != mInteractionConnectionTokens.end();
                        }) != interactionConnectionTokens.end();
}

void InputDispatcher::setMaximumObscuringOpacityForTouch(float opacity) {
@@ -7120,6 +7130,7 @@ void InputDispatcher::displayRemoved(ui::LogicalDisplayId displayId) {
        mTouchModePerDisplay.erase(displayId);
        mVerifiersByDisplay.erase(displayId);
        mInputFilterVerifiersByDisplay.erase(displayId);
        mInteractionConnectionTokensByDisplay.erase(displayId);
    } // release lock

    // Wake up poll loop since it may need to make new input dispatching choices.
+6 −3
Original line number Diff line number Diff line
@@ -711,8 +711,10 @@ private:

    // The connection tokens of the channels that the user last interacted (used for debugging and
    // when switching touch mode state).
    std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>> mInteractionConnectionTokens
            GUARDED_BY(mLock);
    std::unordered_map<ui::LogicalDisplayId,
                       std::unordered_set<sp<IBinder>, StrongPointerHash<IBinder>>>
            mInteractionConnectionTokensByDisplay GUARDED_BY(mLock);

    void processInteractionsLocked(const EventEntry& entry, const std::vector<InputTarget>& targets)
            REQUIRES(mLock);

@@ -941,7 +943,8 @@ private:

    // Check window ownership
    bool focusedWindowIsOwnedByLocked(gui::Pid pid, gui::Uid uid) REQUIRES(mLock);
    bool recentWindowsAreOwnedByLocked(gui::Pid pid, gui::Uid uid) REQUIRES(mLock);
    bool recentWindowsAreOwnedByLocked(ui::LogicalDisplayId displayId, gui::Pid pid, gui::Uid uid)
            REQUIRES(mLock);

    sp<InputReporterInterface> mReporter;