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

Commit fa2a049c authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Disable key repeat for PendingKey_IsDroppedWhileMotionIsProcessedAndNewTouchComesIn test

This test occasionally fails because the dispatcher generates a key
repeat. This key repeat races with the other timeouts that are used in
this test, so it is only occasionally generated.

Since this test isn't related to key repeats, attempt to deflake it by
disabling key repeats.

Bug: 294547658
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="*PendingKey_IsDroppedWhileMotionIsProcessedAndNewTouchComesIn"
Test: m checkinput
Change-Id: I75cae28b07011ddaeb9165494e27fc17a2ef36f5
parent aefa5f37
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -243,6 +243,9 @@ phony {
        "Bug-115739809",
        "StructLayout_test",

        // jni
        "libservices.core",

        // rust targets
        "libinput_rust_test",

+4 −3
Original line number Diff line number Diff line
@@ -6927,11 +6927,12 @@ sp<WindowInfoHandle> InputDispatcher::findWallpaperWindowBelow(
    return nullptr;
}

void InputDispatcher::setKeyRepeatConfiguration(nsecs_t timeout, nsecs_t delay) {
void InputDispatcher::setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
                                                std::chrono::nanoseconds delay) {
    std::scoped_lock _l(mLock);

    mConfig.keyRepeatTimeout = timeout;
    mConfig.keyRepeatDelay = delay;
    mConfig.keyRepeatTimeout = timeout.count();
    mConfig.keyRepeatDelay = delay.count();
}

} // namespace android::inputdispatcher
+2 −1
Original line number Diff line number Diff line
@@ -145,7 +145,8 @@ public:
    // Public to allow tests to verify that a Monitor can get ANR.
    void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout);

    void setKeyRepeatConfiguration(nsecs_t timeout, nsecs_t delay) override;
    void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
                                   std::chrono::nanoseconds delay) override;

private:
    enum class DropReason {
+2 −1
Original line number Diff line number Diff line
@@ -221,7 +221,8 @@ public:
    /*
     * Updates key repeat configuration timeout and delay.
     */
    virtual void setKeyRepeatConfiguration(nsecs_t timeout, nsecs_t delay) = 0;
    virtual void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
                                           std::chrono::nanoseconds delay) = 0;
};

} // namespace android
+4 −3
Original line number Diff line number Diff line
@@ -6748,8 +6748,8 @@ TEST_F(InputDispatcherFallbackKeyTest, CanceledKeyCancelsFallback) {
class InputDispatcherKeyRepeatTest : public InputDispatcherTest {
protected:
    static constexpr nsecs_t KEY_REPEAT_TIMEOUT = 40 * 1000000; // 40 ms
    static constexpr nsecs_t KEY_REPEAT_DELAY = 40 * 1000000;   // 40 ms
    static constexpr std::chrono::nanoseconds KEY_REPEAT_TIMEOUT = 40ms;
    static constexpr std::chrono::nanoseconds KEY_REPEAT_DELAY = 40ms;
    std::shared_ptr<FakeApplicationHandle> mApp;
    sp<FakeWindowHandle> mWindow;
@@ -8131,7 +8131,8 @@ TEST_F(InputDispatcherSingleWindowAnr,
    // Injection is async, so it will succeed
    ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
              injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0,
                        ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE));
                        ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE, INJECT_EVENT_TIMEOUT,
                        /*allowKeyRepeat=*/false));
    // At this point, key is still pending, and should not be sent to the application yet.
    // Make sure the `assertNoEvents` check doesn't take too long. It uses
    // CONSUME_TIMEOUT_NO_EVENT_EXPECTED under the hood.