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

Commit c6ded10d authored by Mike Playle's avatar Mike Playle
Browse files

Preserve flags field of event passed to injectKeyEvent()

This patch allows users of WindowManagerService.injectKeyEvent() to
set flags on the key event being injected.

In particular this allows long presses (FLAG_LONG_PRESS) to be
injected into the window manager.
parent e1de3f39
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5488,12 +5488,13 @@ public class WindowManagerService extends IWindowManager.Stub
        int metaState = ev.getMetaState();
        int deviceId = ev.getDeviceId();
        int scancode = ev.getScanCode();
        int flags = ev.getFlags();

        if (eventTime == 0) eventTime = SystemClock.uptimeMillis();
        if (downTime == 0) downTime = eventTime;

        KeyEvent newEvent = new KeyEvent(downTime, eventTime, action, code, repeatCount, metaState,
                deviceId, scancode, KeyEvent.FLAG_FROM_SYSTEM);
                deviceId, scancode, flags | KeyEvent.FLAG_FROM_SYSTEM);

        final int pid = Binder.getCallingPid();
        final int uid = Binder.getCallingUid();