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

Commit 0a94f463 authored by Arpit Singh's avatar Arpit Singh
Browse files

[4/n InputDispatcher refactor] Make findTouchedForegroundWindow static

Bug: 367661487
Bug: 245989146
Test: atest inputflinger_tests
Flag: EXEMPT refactor
Change-Id: I121cfa10077d158b79fc61d71ccb559e3ee537c5
parent a923bd4b
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -5931,10 +5931,11 @@ bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const s
 * Return null if there are no windows touched on that display, or if more than one foreground
 * window is being touched.
 */
sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(
        ui::LogicalDisplayId displayId) const {
    auto stateIt = mTouchStatesByDisplay.find(displayId);
    if (stateIt == mTouchStatesByDisplay.end()) {
sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindow(
        const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay,
        ui::LogicalDisplayId displayId) {
    const auto stateIt = touchStatesByDisplay.find(displayId);
    if (stateIt == touchStatesByDisplay.end()) {
        ALOGI("No touch state on display %s", displayId.toString().c_str());
        return nullptr;
    }
@@ -5970,7 +5971,7 @@ bool InputDispatcher::transferTouchOnDisplay(const sp<IBinder>& destChannelToken
            return false;
        }

        sp<WindowInfoHandle> from = findTouchedForegroundWindowLocked(displayId);
        sp<WindowInfoHandle> from = findTouchedForegroundWindow(mTouchStatesByDisplay, displayId);
        if (from == nullptr) {
            ALOGE("Could not find a source window in %s for %p", __func__, destChannelToken.get());
            return false;
+3 −2
Original line number Diff line number Diff line
@@ -260,8 +260,9 @@ private:
            ui::LogicalDisplayId displayId, float x, float y, bool isStylus,
            DeviceId deviceId) const REQUIRES(mLock);

    sp<android::gui::WindowInfoHandle> findTouchedForegroundWindowLocked(
            ui::LogicalDisplayId displayId) const REQUIRES(mLock);
    static sp<android::gui::WindowInfoHandle> findTouchedForegroundWindow(
            const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay,
            ui::LogicalDisplayId displayId);

    std::shared_ptr<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const
            REQUIRES(mLock);