コード例 #1
0
  /** step 3 */
  private boolean performMultiPointerUp() {
    if (mTouches == null) {
      return false;
    }

    boolean ret = true;
    MotionEvent event;

    // For each pointer get the last coordinates
    for (int x = 0; x < mTouches.length; x++)
      mPointerCoords[x] = mTouches[x][mTouches[x].length - 1];

    // touch up
    for (int x = 1; x < mTouches.length; x++) {
      event =
          MotionEvent.obtain(
              mDownTime,
              SystemClock.uptimeMillis(),
              getPointerAction(MotionEvent.ACTION_POINTER_UP, x),
              x + 1,
              mProperties,
              mPointerCoords,
              0,
              0,
              1,
              1,
              0,
              0,
              InputDevice.SOURCE_TOUCHSCREEN,
              0);
      ret &= mUiAutomation.injectInputEvent(event, true);
    }

    // first to touch down is last up
    event =
        MotionEvent.obtain(
            mDownTime,
            SystemClock.uptimeMillis(),
            MotionEvent.ACTION_UP,
            1,
            mProperties,
            mPointerCoords,
            0,
            0,
            1,
            1,
            0,
            0,
            InputDevice.SOURCE_TOUCHSCREEN,
            0);
    ret &= mUiAutomation.injectInputEvent(event, true);

    return ret;
  }
コード例 #2
0
 /** 按下 */
 public void touchDown(int x, int y, int duration) {
   mTouchDownTime = SystemClock.uptimeMillis();
   MotionEvent event =
       MotionEvent.obtain(
           mTouchDownTime, mTouchDownTime + duration, MotionEvent.ACTION_DOWN, x, y, 0);
   event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
   mUiAutomation.injectInputEvent(event, true);
 }
コード例 #3
0
 /** 抬起 */
 public void touchUp(int x, int y) {
   MotionEvent event =
       MotionEvent.obtain(mTouchDownTime, mTouchDownTime, MotionEvent.ACTION_UP, x, y, 0);
   event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
   mUiAutomation.injectInputEvent(event, true);
 }
コード例 #4
0
  /** step 2 */
  private boolean performMultiPointerDown() {
    if (mTouches == null) {
      return false;
    }

    boolean ret = true;
    MotionEvent event;

    // Touch down all pointers
    mDownTime = SystemClock.uptimeMillis();
    event =
        MotionEvent.obtain(
            mDownTime,
            SystemClock.uptimeMillis(),
            MotionEvent.ACTION_DOWN,
            1,
            mProperties,
            mPointerCoords,
            0,
            0,
            1,
            1,
            0,
            0,
            InputDevice.SOURCE_TOUCHSCREEN,
            0);
    ret &= mUiAutomation.injectInputEvent(event, true);

    for (int x = 1; x < mTouches.length; x++) {
      event =
          MotionEvent.obtain(
              mDownTime,
              SystemClock.uptimeMillis(),
              getPointerAction(MotionEvent.ACTION_POINTER_DOWN, x),
              x + 1,
              mProperties,
              mPointerCoords,
              0,
              0,
              1,
              1,
              0,
              0,
              InputDevice.SOURCE_TOUCHSCREEN,
              0);
      ret &= mUiAutomation.injectInputEvent(event, true);
    }

    //        // Move all pointers
    //        for (int i = 1; i < mMaxSteps - 1; i++) {
    //            // for each pointer
    //            for (int x = 0; x < mTouches.length; x++) {
    //                // check if it has coordinates to move
    //                if (mTouches[x].length > i)
    //                    mPointerCoords[x] = mTouches[x][i];
    //                else
    //                    mPointerCoords[x] = mTouches[x][mTouches[x].length - 1];
    //            }
    //
    //            event = MotionEvent.obtain(mDownTime, SystemClock.uptimeMillis(),
    //                    MotionEvent.ACTION_MOVE, mTouches.length, mProperties, mPointerCoords, 0,
    // 0, 1, 1,
    //                    0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
    //
    //            ret &= mUiAutomation.injectInputEvent(event, true);
    //            SystemClock.sleep(5);
    //        }

    return ret;
  }