FileDocCategorySizeDatePackage
MonkeyKeyEvent.javaAPI DocAndroid 1.5 API3589Wed May 06 22:41:08 BST 2009com.android.commands.monkey

MonkeyKeyEvent

public class MonkeyKeyEvent extends MonkeyEvent
monkey key event

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 intgetAction()

        return mAction;
    
public longgetDownTime()

        return mDownTime;
    
private android.view.KeyEventgetEvent()

return
the key event

        if (mDeviceId < 0) {
            return new KeyEvent(mAction, mKeyCode);
        }       
        
        // for scripts
        return new KeyEvent(mDownTime, mEventTime, mAction, 
                mKeyCode, mRepeatCount, mMetaState, mDeviceId, mScancode);
    
public longgetEventTime()

        return mEventTime;
    
public intgetKeyCode()

        return mKeyCode;
    
public intinjectEvent(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 voidsetDownTime(long downTime)

        mDownTime = downTime;
    
public voidsetEventTime(long eventTime)

        mEventTime = eventTime;