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

Commit d76a77a2 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Iterate over vector in pilferPointersLocked" into main

parents 64fc1fc8 8384e0d7
Loading
Loading
Loading
Loading
+37 −33
Original line number Diff line number Diff line
@@ -5918,14 +5918,16 @@ status_t InputDispatcher::pilferPointers(const sp<IBinder>& token) {
status_t InputDispatcher::pilferPointersLocked(const sp<IBinder>& token) {
    const std::shared_ptr<InputChannel> requestingChannel = getInputChannelLocked(token);
    if (!requestingChannel) {
        ALOGW("Attempted to pilfer pointers from an un-registered channel or invalid token");
        LOG(WARNING)
                << "Attempted to pilfer pointers from an un-registered channel or invalid token";
        return BAD_VALUE;
    }

    auto [statePtr, windowPtr, displayId] = findTouchStateWindowAndDisplayLocked(token);
    if (statePtr == nullptr || windowPtr == nullptr) {
        ALOGW("Attempted to pilfer points from a channel without any on-going pointer streams."
              " Ignoring.");
        LOG(WARNING)
                << "Attempted to pilfer points from a channel without any on-going pointer streams."
                   " Ignoring.";
        return BAD_VALUE;
    }
    std::set<int32_t> deviceIds = windowPtr->getTouchingDeviceIds();
@@ -5934,8 +5936,8 @@ status_t InputDispatcher::pilferPointersLocked(const sp<IBinder>& token) {
                     << " in window: " << windowPtr->dump();
        return BAD_VALUE;
    }
    const int32_t deviceId = *deviceIds.begin();

    for (const DeviceId deviceId : deviceIds) {
        TouchState& state = *statePtr;
        TouchedWindow& window = *windowPtr;
        // Send cancel events to all the input channels we're stealing from.
@@ -5956,14 +5958,16 @@ status_t InputDispatcher::pilferPointersLocked(const sp<IBinder>& token) {
            }
        }
        canceledWindows += canceledWindows.empty() ? "[]" : "]";
    ALOGI("Channel %s is stealing touch from %s", requestingChannel->getName().c_str(),
          canceledWindows.c_str());
        LOG(INFO) << "Channel " << requestingChannel->getName()
                  << " is stealing input gesture for device " << deviceId << " from "
                  << canceledWindows;

        // Prevent the gesture from being sent to any other windows.
        // This only blocks relevant pointers to be sent to other windows
        window.addPilferingPointers(deviceId, pointerIds);

        state.cancelPointersForWindowsExcept(deviceId, pointerIds, token);
    }
    return OK;
}