MonkeyKeyEventpublic class MonkeyKeyEvent extends MonkeyEvent
Fields Summary |
---|
private long | mDownTime | private int | mMetaState | private int | mAction | private int | mKeyCode | private int | mScancode | private int | mRepeatCount | private int | mDeviceId | private long | mEventTime |
Constructors Summary |
---|
public MonkeyKeyEvent(int action, int keycode)
super(EVENT_TYPE_KEY);
mAction = action;
mKeyCode = keycode;
| public MonkeyKeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scancode)
super(EVENT_TYPE_KEY);
mAction = action;
mKeyCode = code;
mMetaState = metaState;
mScancode = scancode;
mRepeatCount = repeat;
mDeviceId = device;
mDownTime = downTime;
mEventTime = eventTime;
|
Methods Summary |
---|
public int | getAction()
return mAction;
| public long | getDownTime()
return mDownTime;
| private android.view.KeyEvent | getEvent()
if (mDeviceId < 0) {
return new KeyEvent(mAction, mKeyCode);
}
// for scripts
return new KeyEvent(mDownTime, mEventTime, mAction,
mKeyCode, mRepeatCount, mMetaState, mDeviceId, mScancode);
| public long | getEventTime()
return mEventTime;
| public int | getKeyCode()
return mKeyCode;
| public int | injectEvent(android.view.IWindowManager iwm, android.app.IActivityManager iam, int verbose)
if (verbose > 1) {
String note;
if (mAction == KeyEvent.ACTION_UP) {
note = "ACTION_UP";
} else {
note = "ACTION_DOWN";
}
try {
System.out.println(":SendKey (" + note + "): "
+ mKeyCode + " // "
+ MonkeySourceRandom.getKeyName(mKeyCode));
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(":SendKey (ACTION_UP): "
+ mKeyCode + " // Unknown key event");
}
}
// inject key event
try {
if (!iwm.injectKeyEvent(getEvent(), false)) {
return MonkeyEvent.INJECT_FAIL;
}
} catch (RemoteException ex) {
return MonkeyEvent.INJECT_ERROR_REMOTE_EXCEPTION;
}
return MonkeyEvent.INJECT_SUCCESS;
| public void | setDownTime(long downTime)
mDownTime = downTime;
| public void | setEventTime(long eventTime)
mEventTime = eventTime;
|
|