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

Commit 002d7bab authored by Vaibhav Devmurari's avatar Vaibhav Devmurari Committed by Android (Google) Code Review
Browse files

Merge "Fix: Mouse keys interceptor uses stale KeyEvent" into main

parents 7d29380a 9390376b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -528,8 +528,10 @@ public class MouseKeysInterceptor extends BaseEventStreamTransformation
                    FLAGS_INPUT_FILTER, "event=" + event + ";policyFlags=" + policyFlags);
        }

        final KeyEvent keyEvent = event.copy();
        mHandler.post(() -> {
            onKeyEventInternal(event, policyFlags);
            onKeyEventInternal(keyEvent, policyFlags);
            keyEvent.recycle();
        });
    }

+8 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ class MouseKeysInterceptorTest {
        testLooper.dispatchAll()

        assertThat(nextInterceptor.events).hasSize(1)
        assertThat(nextInterceptor.events.poll()).isEqualTo(downEvent)
        verifyKeyEventsEqual(downEvent, nextInterceptor.events.poll())
    }

    @Test
@@ -529,6 +529,13 @@ class MouseKeysInterceptorTest {
        assertThat(actualYAxis).containsExactlyElementsIn(yAxisMovements.toList()).inOrder()
    }

    private fun verifyKeyEventsEqual(expected: KeyEvent, received: KeyEvent) {
        assertThat(received.keyCode).isEqualTo(expected.keyCode)
        assertThat(received.action).isEqualTo(expected.action)
        assertThat(received.downTime).isEqualTo(expected.downTime)
        assertThat(received.eventTime).isEqualTo(expected.eventTime)
    }

    private fun createInputDevice(
            deviceId: Int,
            generation: Int = -1