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

Commit 1c3d855f authored by Arpit Singh's avatar Arpit Singh
Browse files

Wait till next SYN_REPORT to repopulate device state after SYN_DROPPED

Currently, we repopulate device state immediately upon receiving a SYN_DROPPED
event. We should wait till the next SYN_REPORT event to query the device
state as it signals evdev client's event queue has now recovered from the
buffer overrun.

Test: atest inputflinger_tests
Bug: b/291626046
Change-Id: Ie02dbcb3d3fdc94deee67f1bc06e670c8cd9cd83
parent 4b4a457f
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -810,14 +810,20 @@ void EventHub::Device::trackInputEvent(const struct input_event& event) {
        case EV_SYN: {
            switch (event.code) {
                case SYN_REPORT:
                    if (currentFrameDropped) {
                        // To recover after a SYN_DROPPED, we need to query the state of the device
                        // to synchronize our device state with the kernel's to account for the
                        // dropped events on receiving the next SYN_REPORT.
                        // Note we don't drop the SYN_REPORT at this point but it is used by the
                        // InputDevice to reset and repopulate mapper state
                        readDeviceState();
                        currentFrameDropped = false;
                    }
                    break;
                case SYN_DROPPED:
                    // When we receive SYN_DROPPED, all events in the current frame should be
                    // dropped. We query the state of the device to synchronize our device state
                    // with the kernel's to account for the dropped events.
                    // dropped up to and including next SYN_REPORT
                    currentFrameDropped = true;
                    readDeviceState();
                    break;
                default:
                    break;