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

MonkeyMotionEvent

public class MonkeyMotionEvent extends MonkeyEvent
monkey motion event

Fields Summary
private long
mDownTime
private long
mEventTime
private int
mAction
private float
mX
private float
mY
private float
mPressure
private float
mSize
private int
mMetaState
private float
mXPrecision
private float
mYPrecision
private int
mDeviceId
private int
mEdgeFlags
private boolean
mIntermediateNote
Constructors Summary
public MonkeyMotionEvent(int type, long downAt, int action, float x, float y, int metaState)

  
        
           
                  
        super(type);
        mDownTime = downAt;
        mAction = action;
        mX = x;
        mY = y;
        mMetaState = metaState;
    
public MonkeyMotionEvent(int type, long downTime, long eventTime, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags)

        super(type);
        mDownTime = downTime;
        mEventTime = eventTime;
        mAction = action;
        mX = x;
        mY = y;
        mPressure = pressure;
        mSize = size;
        mMetaState = metaState;
        mXPrecision = xPrecision;
        mYPrecision = yPrecision;
        mDeviceId = deviceId;
        mEdgeFlags = edgeFlags;
    
Methods Summary
public intgetAction()

        return mAction;
    
public longgetDownTime()

        return mDownTime;
    
private android.view.MotionEventgetEvent()

return
instance of a motion event

        if (mDeviceId < 0) {
            return MotionEvent.obtain(mDownTime, SystemClock.uptimeMillis(), 
                mAction, mX, mY, mMetaState);
        }
        
        // for scripts
        return MotionEvent.obtain(mDownTime, mEventTime, 
                mAction, mX, mY, mPressure, mSize, mMetaState,
                mXPrecision, mYPrecision, mDeviceId, mEdgeFlags);
    
public longgetEventTime()

        return mEventTime;
    
public booleangetIntermediateNote()

        return mIntermediateNote;
    
public floatgetX()

        return mX;
    
public floatgetY()

        return mY;
    
public intinjectEvent(android.view.IWindowManager iwm, android.app.IActivityManager iam, int verbose)

        
        String note;
        if ((verbose > 0 && !mIntermediateNote) || verbose > 1) {
            if (mAction == MotionEvent.ACTION_DOWN) {
                note = "DOWN";
            } else if (mAction == MotionEvent.ACTION_UP) {
                note = "UP";
            } else {
                note = "MOVE";
            }
            System.out.println(":Sending Pointer ACTION_" + note + 
                    " x=" + mX + " y=" + mY);
        }
        try {
            int type = this.getEventType();
            MotionEvent me = getEvent();
            
            if ((type == MonkeyEvent.EVENT_TYPE_POINTER && 
                    !iwm.injectPointerEvent(me, false))
                    || (type == MonkeyEvent.EVENT_TYPE_TRACKBALL && 
                            !iwm.injectTrackballEvent(me, 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;
    
public voidsetIntermediateNote(boolean b)

        mIntermediateNote = b;