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

Commit c3da1b01 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6357023 from e8a88834 to rvc-release

Change-Id: Id9179eebd776abc96ef92a3c3479d7fae7d7263c
parents 313c1122 e8a88834
Loading
Loading
Loading
Loading
+4 −2
Original line number 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[info.displayId].push_back(new BinderWindowHandle(info));
    }
    for (auto const& i : handlesPerDisplay) {
        mDispatcher->setInputWindows(i.second, i.first, setInputWindowsListener);
    mDispatcher->setInputWindows(handlesPerDisplay);

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

+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({window}, ADISPLAY_ID_DEFAULT);
    dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});

    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({window}, ADISPLAY_ID_DEFAULT);
    dispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});

    for (auto _ : state) {
        MotionEvent event = generateMotionEvent();
+86 −87
Original line number Diff line number Diff line
@@ -3621,6 +3621,18 @@ 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,...
@@ -3628,9 +3640,8 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
 * 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::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
                                      int32_t displayId,
                                      const sp<ISetInputWindowsListener>& setInputWindowsListener) {
void InputDispatcher::setInputWindowsLocked(
        const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) {
    if (DEBUG_FOCUS) {
        std::string windowList;
        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());
    }
    { // 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);

@@ -3712,8 +3720,7 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>&
                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 {
@@ -3734,14 +3741,6 @@ void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>&
            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(
+4 −2
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::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId,
            const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override;
            const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
                    handlesPerDisplay) override;
    virtual void setFocusedApplication(
            int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override;
    virtual void setFocusedDisplay(int32_t displayId) override;
@@ -278,6 +278,8 @@ 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);
+4 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

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

namespace android {

@@ -99,13 +100,13 @@ public:
     */
    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).
     */
    virtual void setInputWindows(
            const std::vector<sp<InputWindowHandle> >& inputWindowHandles, int32_t displayId,
            const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) = 0;
            const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
                    handlesPerDisplay) = 0;

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