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

Commit 64452933 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Remove portalToDisplay functionality

There should not be any more users of the portal to display
functionality. We can now delete this unused code.

Bug: 167946720
Test: atest inputflinger_tests
Change-Id: I9e9a2e7d6c3e5d5fe969ae6207f7c1f2db169f04
parent d0961a2f
Loading
Loading
Loading
Loading
+12 −61
Original line number Diff line number Diff line
@@ -900,8 +900,7 @@ bool InputDispatcher::shouldPruneInboundQueueLocked(const MotionEntry& motionEnt
        }

        // Alternatively, maybe there's a gesture monitor that could handle this event
        std::vector<TouchedMonitor> gestureMonitors =
                findTouchedGestureMonitorsLocked(displayId, {});
        std::vector<TouchedMonitor> gestureMonitors = findTouchedGestureMonitorsLocked(displayId);
        for (TouchedMonitor& gestureMonitor : gestureMonitors) {
            sp<Connection> connection =
                    getConnectionLocked(gestureMonitor.monitor.inputChannel->getConnectionToken());
@@ -995,11 +994,9 @@ void InputDispatcher::addRecentEventLocked(std::shared_ptr<EventEntry> entry) {
sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t displayId, int32_t x,
                                                                 int32_t y, TouchState* touchState,
                                                                 bool addOutsideTargets,
                                                                 bool addPortalWindows,
                                                                 bool ignoreDragWindow) {
    if ((addPortalWindows || addOutsideTargets) && touchState == nullptr) {
        LOG_ALWAYS_FATAL(
                "Must provide a valid touch state if adding portal windows or outside targets");
    if (addOutsideTargets && touchState == nullptr) {
        LOG_ALWAYS_FATAL("Must provide a valid touch state if adding outside targets");
    }
    // Traverse windows from front to back to find touched window.
    const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
@@ -1016,16 +1013,6 @@ sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t display
                    bool isTouchModal = !flags.test(InputWindowInfo::Flag::NOT_FOCUSABLE) &&
                            !flags.test(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
                    if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
                        int32_t portalToDisplayId = windowInfo->portalToDisplayId;
                        if (portalToDisplayId != ADISPLAY_ID_NONE &&
                            portalToDisplayId != displayId) {
                            if (addPortalWindows) {
                                // For the monitoring channels of the display.
                                touchState->addPortalWindow(windowHandle);
                            }
                            return findTouchedWindowAtLocked(portalToDisplayId, x, y, touchState,
                                                             addOutsideTargets, addPortalWindows);
                        }
                        // Found window.
                        return windowHandle;
                    }
@@ -1043,17 +1030,11 @@ sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t display
}

std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
        int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const {
        int32_t displayId) const {
    std::vector<TouchedMonitor> touchedMonitors;

    std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
    addGestureMonitors(monitors, touchedMonitors);
    for (const sp<InputWindowHandle>& portalWindow : portalWindows) {
        const InputWindowInfo* windowInfo = portalWindow->getInfo();
        monitors = getValueByKey(mGestureMonitorsByDisplay, windowInfo->portalToDisplayId);
        addGestureMonitors(monitors, touchedMonitors, -windowInfo->frameLeft,
                           -windowInfo->frameTop);
    }
    return touchedMonitors;
}

@@ -1589,23 +1570,6 @@ bool InputDispatcher::dispatchMotionLocked(nsecs_t currentTime, std::shared_ptr<
    // Add monitor channels from event's or focused display.
    addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(*entry));

    if (isPointerEvent) {
        std::unordered_map<int32_t, TouchState>::iterator it =
                mTouchStatesByDisplay.find(entry->displayId);
        if (it != mTouchStatesByDisplay.end()) {
            const TouchState& state = it->second;
            if (!state.portalWindows.empty()) {
                // The event has gone through these portal windows, so we add monitoring targets of
                // the corresponding displays as well.
                for (size_t i = 0; i < state.portalWindows.size(); i++) {
                    const InputWindowInfo* windowInfo = state.portalWindows[i]->getInfo();
                    addGlobalMonitoringTargetsLocked(inputTargets, windowInfo->portalToDisplayId,
                                                     -windowInfo->frameLeft, -windowInfo->frameTop);
                }
            }
        }
    }

    // Dispatch the motion.
    if (conflictingPointerActions) {
        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
@@ -1993,12 +1957,11 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked(
            y = int32_t(entry.pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_Y));
        }
        bool isDown = maskedAction == AMOTION_EVENT_ACTION_DOWN;
        newTouchedWindowHandle =
                findTouchedWindowAtLocked(displayId, x, y, &tempTouchState,
                                          isDown /*addOutsideTargets*/, true /*addPortalWindows*/);
        newTouchedWindowHandle = findTouchedWindowAtLocked(displayId, x, y, &tempTouchState,
                                                           isDown /*addOutsideTargets*/);

        std::vector<TouchedMonitor> newGestureMonitors = isDown
                ? findTouchedGestureMonitorsLocked(displayId, tempTouchState.portalWindows)
                ? findTouchedGestureMonitorsLocked(displayId)
                : std::vector<TouchedMonitor>{};

        // Figure out whether splitting will be allowed for this window.
@@ -2369,8 +2332,7 @@ Failed:
void InputDispatcher::finishDragAndDrop(int32_t displayId, float x, float y) {
    const sp<InputWindowHandle> dropWindow =
            findTouchedWindowAtLocked(displayId, x, y, nullptr /*touchState*/,
                                      false /*addOutsideTargets*/, false /*addPortalWindows*/,
                                      true /*ignoreDragWindow*/);
                                      false /*addOutsideTargets*/, true /*ignoreDragWindow*/);
    if (dropWindow) {
        vec2 local = dropWindow->getInfo()->transform.transform(x, y);
        notifyDropWindowLocked(dropWindow->getToken(), local.x, local.y);
@@ -2404,8 +2366,7 @@ void InputDispatcher::addDragEventLocked(const MotionEntry& entry) {

        const sp<InputWindowHandle> hoverWindowHandle =
                findTouchedWindowAtLocked(entry.displayId, x, y, nullptr /*touchState*/,
                                          false /*addOutsideTargets*/, false /*addPortalWindows*/,
                                          true /*ignoreDragWindow*/);
                                          false /*addOutsideTargets*/, true /*ignoreDragWindow*/);
        // enqueue drag exit if needed.
        if (hoverWindowHandle != mDragState->dragHoverWindowHandle &&
            !haveSameToken(hoverWindowHandle, mDragState->dragHoverWindowHandle)) {
@@ -4436,8 +4397,7 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
        }

        const InputWindowInfo* info = handle->getInfo();
        if ((getInputChannelLocked(handle->getToken()) == nullptr &&
             info->portalToDisplayId == ADISPLAY_ID_NONE)) {
        if (getInputChannelLocked(handle->getToken()) == nullptr) {
            const bool noInputChannel =
                    info->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
            const bool canReceiveInput = !info->flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE) ||
@@ -4989,14 +4949,6 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
            } else {
                dump += INDENT3 "Windows: <none>\n";
            }
            if (!state.portalWindows.empty()) {
                dump += INDENT3 "Portal windows:\n";
                for (size_t i = 0; i < state.portalWindows.size(); i++) {
                    const sp<InputWindowHandle> portalWindowHandle = state.portalWindows[i];
                    dump += StringPrintf(INDENT4 "%zu: name='%s'\n", i,
                                         portalWindowHandle->getName().c_str());
                }
            }
        }
    } else {
        dump += INDENT "TouchStates: <no displays touched>\n";
@@ -5018,7 +4970,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
                    const InputWindowInfo* windowInfo = windowHandle->getInfo();

                    dump += StringPrintf(INDENT3 "%zu: name='%s', id=%" PRId32 ", displayId=%d, "
                                                 "portalToDisplayId=%d, paused=%s, focusable=%s, "
                                                 "paused=%s, focusable=%s, "
                                                 "hasWallpaper=%s, visible=%s, alpha=%.2f, "
                                                 "flags=%s, type=%s, "
                                                 "frame=[%d,%d][%d,%d], globalScale=%f, "
@@ -5026,8 +4978,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
                                                 "applicationInfo.token=%s, "
                                                 "touchableRegion=",
                                         i, windowInfo->name.c_str(), windowInfo->id,
                                         windowInfo->displayId, windowInfo->portalToDisplayId,
                                         toString(windowInfo->paused),
                                         windowInfo->displayId, toString(windowInfo->paused),
                                         toString(windowInfo->focusable),
                                         toString(windowInfo->hasWallpaper),
                                         toString(windowInfo->visible), windowInfo->alpha,
+1 −3
Original line number Diff line number Diff line
@@ -211,7 +211,6 @@ private:
    sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x, int32_t y,
                                                    TouchState* touchState,
                                                    bool addOutsideTargets = false,
                                                    bool addPortalWindows = false,
                                                    bool ignoreDragWindow = false) REQUIRES(mLock);

    sp<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const
@@ -489,8 +488,7 @@ private:
    android::os::InputEventInjectionResult findTouchedWindowTargetsLocked(
            nsecs_t currentTime, const MotionEntry& entry, std::vector<InputTarget>& inputTargets,
            nsecs_t* nextWakeupTime, bool* outConflictingPointerActions) REQUIRES(mLock);
    std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked(
            int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const
    std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked(int32_t displayId) const
            REQUIRES(mLock);
    std::vector<TouchedMonitor> selectResponsiveMonitorsLocked(
            const std::vector<TouchedMonitor>& gestureMonitors) const REQUIRES(mLock);
+0 −13
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ void TouchState::reset() {
    source = 0;
    displayId = ADISPLAY_ID_NONE;
    windows.clear();
    portalWindows.clear();
    gestureMonitors.clear();
}

@@ -47,7 +46,6 @@ void TouchState::copyFrom(const TouchState& other) {
    source = other.source;
    displayId = other.displayId;
    windows = other.windows;
    portalWindows = other.portalWindows;
    gestureMonitors = other.gestureMonitors;
}

@@ -76,16 +74,6 @@ void TouchState::addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle, in
    windows.push_back(touchedWindow);
}

void TouchState::addPortalWindow(const sp<InputWindowHandle>& windowHandle) {
    size_t numWindows = portalWindows.size();
    for (size_t i = 0; i < numWindows; i++) {
        if (portalWindows[i] == windowHandle) {
            return;
        }
    }
    portalWindows.push_back(windowHandle);
}

void TouchState::addGestureMonitors(const std::vector<TouchedMonitor>& newMonitors) {
    const size_t newSize = gestureMonitors.size() + newMonitors.size();
    gestureMonitors.reserve(newSize);
@@ -118,7 +106,6 @@ void TouchState::filterNonAsIsTouchWindows() {

void TouchState::filterNonMonitors() {
    windows.clear();
    portalWindows.clear();
}

sp<InputWindowHandle> TouchState::getFirstForegroundWindowHandle() const {
+0 −5
Original line number Diff line number Diff line
@@ -34,11 +34,6 @@ struct TouchState {
    int32_t displayId; // id to the display that currently has a touch, others are rejected
    std::vector<TouchedWindow> windows;

    // This collects the portal windows that the touch has gone through. Each portal window
    // targets a display (embedded display for most cases). With this info, we can add the
    // monitoring channels of the displays touched.
    std::vector<sp<android::InputWindowHandle>> portalWindows;

    std::vector<TouchedMonitor> gestureMonitors;

    TouchState();