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.
This commit is contained in:
Mike Playle
2010-11-29 16:01:03 +00:00
parent e1de3f390e
commit c6ded10dd1

View File

@ -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();