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

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

Merge "Wait for dispatcher idle before asserting policy callbacks" into udc-qpr-dev am: 11512800

parents f1a41bf9 11512800
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6598,7 +6598,7 @@ void InputDispatcher::monitor() {
 * this method can be safely called from any thread, as long as you've ensured that
 * the work you are interested in completing has already been queued.
 */
bool InputDispatcher::waitForIdle() {
bool InputDispatcher::waitForIdle() const {
    /**
     * Timeout should represent the longest possible time that a device might spend processing
     * events and commands.
+3 −3
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public:

    void dump(std::string& dump) override;
    void monitor() override;
    bool waitForIdle() override;
    bool waitForIdle() const override;
    status_t start() override;
    status_t stop() override;

@@ -169,10 +169,10 @@ private:
    InputDispatcherPolicyInterface& mPolicy;
    android::InputDispatcherConfiguration mConfig GUARDED_BY(mLock);

    std::mutex mLock;
    mutable std::mutex mLock;

    std::condition_variable mDispatcherIsAlive;
    std::condition_variable mDispatcherEnteredIdle;
    mutable std::condition_variable mDispatcherEnteredIdle;

    sp<Looper> mLooper;

+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ public:
     * Return true if the dispatcher is idle.
     * Return false if the timeout waiting for the dispatcher to become idle has expired.
     */
    virtual bool waitForIdle() = 0;
    virtual bool waitForIdle() const = 0;

    /* Make the dispatcher start processing events.
     *
+9 −7
Original line number Diff line number Diff line
@@ -383,7 +383,9 @@ public:
        mPointerCaptureRequest.reset();
    }

    void assertDropTargetEquals(const sp<IBinder>& targetToken) {
    void assertDropTargetEquals(const InputDispatcherInterface& dispatcher,
                                const sp<IBinder>& targetToken) {
        dispatcher.waitForIdle();
        std::scoped_lock lock(mLock);
        ASSERT_TRUE(mNotifyDropWindowWasCalled);
        ASSERT_EQ(targetToken, mDropTargetWindowToken);
@@ -8450,7 +8452,7 @@ TEST_F(InputDispatcherDragTests, DragAndDrop) {
                             {150, 50}))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
    mFakePolicy->assertDropTargetEquals(mSecondWindow->getToken());
    mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
    mWindow->assertNoEvents();
    mSecondWindow->assertNoEvents();
}
@@ -8481,7 +8483,7 @@ TEST_F(InputDispatcherDragTests, StylusDragAndDrop) {
    mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT);
    mWindow->assertNoEvents();
    mSecondWindow->assertNoEvents();
    mFakePolicy->assertDropTargetEquals(mSecondWindow->getToken());
    mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());

    // nothing to the window.
    ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -8527,7 +8529,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropOnInvalidWindow) {
                             {150, 50}))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
    mFakePolicy->assertDropTargetEquals(nullptr);
    mFakePolicy->assertDropTargetEquals(*mDispatcher, nullptr);
    mWindow->assertNoEvents();
    mSecondWindow->assertNoEvents();
}
@@ -8610,7 +8612,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) {
              injectMotionEvent(mDispatcher, secondFingerUpEvent, INJECT_EVENT_TIMEOUT,
                                InputEventInjectionSync::WAIT_FOR_RESULT));
    mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
    mFakePolicy->assertDropTargetEquals(mWindow->getToken());
    mFakePolicy->assertDropTargetEquals(*mDispatcher, mWindow->getToken());
    mWindow->assertNoEvents();
    mSecondWindow->consumeMotionMove();
}
@@ -8660,7 +8662,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenMultiDisplays) {
                             {150, 50}))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
    mFakePolicy->assertDropTargetEquals(mSecondWindow->getToken());
    mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
    mWindow->assertNoEvents();
    mSecondWindow->assertNoEvents();
}
@@ -8709,7 +8711,7 @@ TEST_F(InputDispatcherDragTests, MouseDragAndDrop) {
                                        .build()))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
    mFakePolicy->assertDropTargetEquals(mSecondWindow->getToken());
    mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken());
    mWindow->assertNoEvents();
    mSecondWindow->assertNoEvents();
}