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

Commit d4d1816c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Associate the displayId with the input_interaction" into main

parents b8337c6f 9ac502b3
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;