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

Commit 3b8faf91 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[BugFix] Reset key repeating in case a keyboard device was disabled or...

Merge "[BugFix] Reset key repeating in case a keyboard device was disabled or enabled." am: e040fd14

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1713796

Change-Id: I06e950ca9a3f31127dc897b6f2320b85a48bae73
parents 822199a8 e040fd14
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1098,6 +1098,11 @@ bool InputDispatcher::dispatchDeviceResetLocked(nsecs_t currentTime, DeviceReset
          entry->deviceId);
#endif

    // Reset key repeating in case a keyboard device was disabled or enabled.
    if (mKeyRepeatState.lastKeyEntry && mKeyRepeatState.lastKeyEntry->deviceId == entry->deviceId) {
        resetKeyRepeatLocked();
    }

    CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, "device was reset");
    options.deviceId = entry->deviceId;
    synthesizeCancelationEventsForAllConnectionsLocked(options);
+10 −0
Original line number Diff line number Diff line
@@ -1799,6 +1799,16 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterUp) {
    mWindow->assertNoEvents();
}

TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterDisableInputDevice) {
    sendAndConsumeKeyDown();
    expectKeyRepeatOnce(1 /*repeatCount*/);
    NotifyDeviceResetArgs args(10 /*id*/, 20 /*eventTime*/, DEVICE_ID);
    mDispatcher->notifyDeviceReset(&args);
    mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT,
                          AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_LONG_PRESS);
    mWindow->assertNoEvents();
}

TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_RepeatKeyEventsUseEventIdFromInputDispatcher) {
    sendAndConsumeKeyDown();
    for (int32_t repeatCount = 1; repeatCount <= 10; ++repeatCount) {