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 Original line 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
        // Alternatively, maybe there's a gesture monitor that could handle this event
        std::vector<TouchedMonitor> gestureMonitors =
        std::vector<TouchedMonitor> gestureMonitors = findTouchedGestureMonitorsLocked(displayId);
                findTouchedGestureMonitorsLocked(displayId, {});
        for (TouchedMonitor& gestureMonitor : gestureMonitors) {
        for (TouchedMonitor& gestureMonitor : gestureMonitors) {
            sp<Connection> connection =
            sp<Connection> connection =
                    getConnectionLocked(gestureMonitor.monitor.inputChannel->getConnectionToken());
                    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,
sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t displayId, int32_t x,
                                                                 int32_t y, TouchState* touchState,
                                                                 int32_t y, TouchState* touchState,
                                                                 bool addOutsideTargets,
                                                                 bool addOutsideTargets,
                                                                 bool addPortalWindows,
                                                                 bool ignoreDragWindow) {
                                                                 bool ignoreDragWindow) {
    if ((addPortalWindows || addOutsideTargets) && touchState == nullptr) {
    if (addOutsideTargets && touchState == nullptr) {
        LOG_ALWAYS_FATAL(
        LOG_ALWAYS_FATAL("Must provide a valid touch state if adding outside targets");
                "Must provide a valid touch state if adding portal windows or outside targets");
    }
    }
    // Traverse windows from front to back to find touched window.
    // Traverse windows from front to back to find touched window.
    const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
    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) &&
                    bool isTouchModal = !flags.test(InputWindowInfo::Flag::NOT_FOCUSABLE) &&
                            !flags.test(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
                            !flags.test(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
                    if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
                    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.
                        // Found window.
                        return windowHandle;
                        return windowHandle;
                    }
                    }
@@ -1043,17 +1030,11 @@ sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t display
}
}


std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
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<TouchedMonitor> touchedMonitors;


    std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
    std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
    addGestureMonitors(monitors, touchedMonitors);
    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;
    return touchedMonitors;
}
}


@@ -1589,23 +1570,6 @@ bool InputDispatcher::dispatchMotionLocked(nsecs_t currentTime, std::shared_ptr<
    // Add monitor channels from event's or focused display.
    // Add monitor channels from event's or focused display.
    addGlobalMonitoringTargetsLocked(inputTargets, getTargetDisplayId(*entry));
    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.
    // Dispatch the motion.
    if (conflictingPointerActions) {
    if (conflictingPointerActions) {
        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
@@ -1993,12 +1957,11 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked(
            y = int32_t(entry.pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_Y));
            y = int32_t(entry.pointerCoords[pointerIndex].getAxisValue(AMOTION_EVENT_AXIS_Y));
        }
        }
        bool isDown = maskedAction == AMOTION_EVENT_ACTION_DOWN;
        bool isDown = maskedAction == AMOTION_EVENT_ACTION_DOWN;
        newTouchedWindowHandle =
        newTouchedWindowHandle = findTouchedWindowAtLocked(displayId, x, y, &tempTouchState,
                findTouchedWindowAtLocked(displayId, x, y, &tempTouchState,
                                                           isDown /*addOutsideTargets*/);
                                          isDown /*addOutsideTargets*/, true /*addPortalWindows*/);


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


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


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


        const InputWindowInfo* info = handle->getInfo();
        const InputWindowInfo* info = handle->getInfo();
        if ((getInputChannelLocked(handle->getToken()) == nullptr &&
        if (getInputChannelLocked(handle->getToken()) == nullptr) {
             info->portalToDisplayId == ADISPLAY_ID_NONE)) {
            const bool noInputChannel =
            const bool noInputChannel =
                    info->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
                    info->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
            const bool canReceiveInput = !info->flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE) ||
            const bool canReceiveInput = !info->flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE) ||
@@ -4989,14 +4949,6 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
            } else {
            } else {
                dump += INDENT3 "Windows: <none>\n";
                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 {
    } else {
        dump += INDENT "TouchStates: <no displays touched>\n";
        dump += INDENT "TouchStates: <no displays touched>\n";
@@ -5018,7 +4970,7 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) {
                    const InputWindowInfo* windowInfo = windowHandle->getInfo();
                    const InputWindowInfo* windowInfo = windowHandle->getInfo();


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


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


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


@@ -76,16 +74,6 @@ void TouchState::addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle, in
    windows.push_back(touchedWindow);
    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) {
void TouchState::addGestureMonitors(const std::vector<TouchedMonitor>& newMonitors) {
    const size_t newSize = gestureMonitors.size() + newMonitors.size();
    const size_t newSize = gestureMonitors.size() + newMonitors.size();
    gestureMonitors.reserve(newSize);
    gestureMonitors.reserve(newSize);
@@ -118,7 +106,6 @@ void TouchState::filterNonAsIsTouchWindows() {


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


sp<InputWindowHandle> TouchState::getFirstForegroundWindowHandle() const {
sp<InputWindowHandle> TouchState::getFirstForegroundWindowHandle() const {
+0 −5
Original line number Original line 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
    int32_t displayId; // id to the display that currently has a touch, others are rejected
    std::vector<TouchedWindow> windows;
    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;
    std::vector<TouchedMonitor> gestureMonitors;


    TouchState();
    TouchState();