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

Commit 25e2af10 authored by Arthur Hung's avatar Arthur Hung
Browse files

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

This reverts commit 2d112c5f.

Reason for revert: Inject event may take too long if no animation.

Change-Id: Ie101f881363cf088a73a8b106fd242c15c7788bf
parent 2d112c5f
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -111,10 +111,8 @@ void InputManager::setInputWindows(const std::vector<InputWindowInfo>& infos,
        handlesPerDisplay.emplace(info.displayId, std::vector<sp<InputWindowHandle>>());
        handlesPerDisplay[info.displayId].push_back(new BinderWindowHandle(info));
    }
    mDispatcher->setInputWindows(handlesPerDisplay);

    if (setInputWindowsListener) {
        setInputWindowsListener->onSetInputWindowsFinished();
    for (auto const& i : handlesPerDisplay) {
        mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener);
    }
}

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

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

    NotifyMotionArgs motionArgs = generateMotionArgs();

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

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

    for (auto _ : state) {
        MotionEvent event = generateMotionEvent();
+87 −86
Original line number Diff line number Diff line
@@ -3621,18 +3621,6 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
    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.
 * A window handle contains information about InputChannel, Touch Region, Types, Focused,...
@@ -3640,8 +3628,9 @@ void InputDispatcher::setInputWindows(
 * 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.
 */
void InputDispatcher::setInputWindowsLocked(
        const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) {
void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
                                      int32_t displayId,
                                      const sp<ISetInputWindowsListener>& setInputWindowsListener) {
    if (DEBUG_FOCUS) {
        std::string windowList;
        for (const sp<InputWindowHandle>& iwh : inputWindowHandles) {
@@ -3649,9 +3638,12 @@ void InputDispatcher::setInputWindowsLocked(
        }
        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.
    const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId);
        const std::vector<sp<InputWindowHandle>> oldWindowHandles =
                getWindowHandlesLocked(displayId);

        updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId);

@@ -3720,7 +3712,8 @@ void InputDispatcher::setInputWindowsLocked(
                    if (touchedInputChannel != nullptr) {
                        CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
                                                   "touched window was removed");
                    synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options);
                        synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel,
                                                                         options);
                    }
                    state.windows.erase(state.windows.begin() + i);
                } else {
@@ -3741,6 +3734,14 @@ void InputDispatcher::setInputWindowsLocked(
                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(
+2 −4
Original line number Diff line number Diff line
@@ -109,8 +109,8 @@ public:
    virtual std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override;

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

    std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
            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.
    std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const
            REQUIRES(mLock);
+3 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

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

namespace android {

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

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

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