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

Commit f020081f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix input infos are inconsistent between WMS and InputFlinger (2/2)"...

Merge "Fix input infos are inconsistent between WMS and InputFlinger (2/2)" into rvc-dev am: f4f7283f am: bddd93ac

Change-Id: I5f70475daf5eb0c003bb53ffe65de4aa941aaace
parents ed965518 bddd93ac
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -111,8 +111,10 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& infos,
        handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>());
        handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>());
        handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info));
        handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info));
    }
    }
    for (auto const& i : handlesPerDisplay) {
    mDispatcher->setInputWindows(handlesPerDisplay);
        mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener);

    if (setInputWindowsListener) {
        setInputWindowsListener->onSetInputWindowsFinished();
    }
    }
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -252,7 +252,7 @@ static void benchmarkNotifyMotion(benchmark::State& state) {
    sp<FakeApplicationHandle> application = new FakeApplicationHandle();
    sp<FakeApplicationHandle> application = new FakeApplicationHandle();
    sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window");
    sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window");


    dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT);
    dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});


    NotifyMotionArgs motionArgs = generateMotionArgs();
    NotifyMotionArgs motionArgs = generateMotionArgs();


@@ -288,7 +288,7 @@ static void benchmarkInjectMotion(benchmark::State& state) {
    sp<FakeApplicationHandle> application = new FakeApplicationHandle();
    sp<FakeApplicationHandle> application = new FakeApplicationHandle();
    sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window");
    sp<FakeWindowHandle> window = new FakeWindowHandle(application, dispatcher, "Fake Window");


    dispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT);
    dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});


    for (auto _ : state) {
    for (auto _ : state) {
        MotionEvent event = generateMotionEvent();
        MotionEvent event = generateMotionEvent();
+86 −87
Original line number Original line Diff line number Diff line
@@ -3621,6 +3621,18 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
    mWindowHandlesByDisplay[displayId] = newHandles;
    mWindowHandlesByDisplay[displayId] = newHandles;
}
}


void InputDispatcher::setInputWindows(
        const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) {
    { // acquire lock
        std::scoped_lock _l(mLock);
        for (auto const& i : handlesPerDisplay) {
            setInputWindowsLocked(i.second, i.first);
        }
    }
    // Wake up poll loop since it may need to make new input dispatching choices.
    mLooper->wake();
}

/**
/**
 * Called from InputManagerService, update window handle list by displayId that can receive input.
 * Called from InputManagerService, update window handle list by displayId that can receive input.
 * A window handle contains information about InputChannel, Touch Region, Types, Focused,...
 * A window handle contains information about InputChannel, Touch Region, Types, Focused,...
@@ -3628,9 +3640,8 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
 * For focused handle, check if need to change and send a cancel event to previous one.
 * For focused handle, check if need to change and send a cancel event to previous one.
 * For removed handle, check if need to send a cancel event if already in touch.
 * For removed handle, check if need to send a cancel event if already in touch.
 */
 */
void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
void InputDispatcher::setInputWindowsLocked(
                                      int32_t displayId,
        const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) {
                                      const sp<ISetInputWindowsListener>& setInputWindowsListener) {
    if (DEBUG_FOCUS) {
    if (DEBUG_FOCUS) {
        std::string windowList;
        std::string windowList;
        for (const sp<InputWindowHandle>& iwh : inputWindowHandles) {
        for (const sp<InputWindowHandle>& iwh : inputWindowHandles) {
@@ -3638,12 +3649,9 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>&
        }
        }
        ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str());
        ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str());
    }
    }
    { // acquire lock
        std::scoped_lock _l(mLock);


    // Copy old handles for release if they are no longer present.
    // Copy old handles for release if they are no longer present.
        const std::vector<sp<InputWindowHandle>> oldWindowHandles =
    const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId);
                getWindowHandlesLocked(displayId);


    updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId);
    updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId);


@@ -3712,8 +3720,7 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>&
                if (touchedInputChannel != nullptr) {
                if (touchedInputChannel != nullptr) {
                    CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
                    CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
                                               "touched window was removed");
                                               "touched window was removed");
                        synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel,
                    synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options);
                                                                         options);
                }
                }
                state.windows.erase(state.windows.begin() + i);
                state.windows.erase(state.windows.begin() + i);
            } else {
            } else {
@@ -3734,14 +3741,6 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>&
            oldWindowHandle->releaseChannel();
            oldWindowHandle->releaseChannel();
        }
        }
    }
    }
    } // release lock

    // Wake up poll loop since it may need to make new input dispatching choices.
    mLooper->wake();

    if (setInputWindowsListener) {
        setInputWindowsListener->onSetInputWindowsFinished();
    }
}
}


void InputDispatcher::setFocusedApplication(
void InputDispatcher::setFocusedApplication(
+4 −2
Original line number Original line Diff line number Diff line
@@ -109,8 +109,8 @@ public:
    virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override;
    virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override;


    virtual void setInputWindows(
    virtual void setInputWindows(
            const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId,
            const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
            const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override;
                    handlesPerDisplay) override;
    virtual void setFocusedApplication(
    virtual void setFocusedApplication(
            int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override;
            int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override;
    virtual void setFocusedDisplay(int32_t displayId) override;
    virtual void setFocusedDisplay(int32_t displayId) override;
@@ -278,6 +278,8 @@ private:


    std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
    std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
            GUARDED_BY(mLock);
            GUARDED_BY(mLock);
    void setInputWindowsLocked(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
                               int32_t displayId) REQUIRES(mLock);
    // Get window handles by display, return an empty vector if not found.
    // Get window handles by display, return an empty vector if not found.
    std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const
    std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const
            REQUIRES(mLock);
            REQUIRES(mLock);
+4 −3
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@


#include <InputListener.h>
#include <InputListener.h>
#include <input/ISetInputWindowsListener.h>
#include <input/ISetInputWindowsListener.h>
#include <unordered_map>


namespace android {
namespace android {


@@ -99,13 +100,13 @@ public:
     */
     */
    virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0;
    virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) = 0;


    /* Sets the list of input windows.
    /* Sets the list of input windows per display.
     *
     *
     * This method may be called on any thread (usually by the input manager).
     * This method may be called on any thread (usually by the input manager).
     */
     */
    virtual void setInputWindows(
    virtual void setInputWindows(
            const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId,
            const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
            const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0;
                    handlesPerDisplay) = 0;


    /* Sets the focused application on the given display.
    /* Sets the focused application on the given display.
     *
     *
Loading