/* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.accessibilityservice; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_DOUBLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_DOUBLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_SINGLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_SWIPE_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_SWIPE_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_SWIPE_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_SWIPE_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_TRIPLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_2_FINGER_TRIPLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_DOUBLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_DOUBLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SINGLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SINGLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SWIPE_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SWIPE_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SWIPE_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_SWIPE_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_TRIPLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_3_FINGER_TRIPLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_DOUBLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_DOUBLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_SINGLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_SWIPE_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_SWIPE_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_SWIPE_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_SWIPE_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_4_FINGER_TRIPLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP; import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP_AND_HOLD; import static android.accessibilityservice.AccessibilityService.GESTURE_PASSTHROUGH; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT; import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT; import static android.accessibilityservice.AccessibilityService.GESTURE_TOUCH_EXPLORATION; import static android.accessibilityservice.AccessibilityService.GESTURE_UNKNOWN; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.TestApi; import android.content.pm.ParceledListSlice; import android.os.Parcel; import android.os.Parcelable; import android.view.MotionEvent; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; /** * This class describes the gesture event including gesture id and which display it happens * on. *
* Note: Accessibility services setting the
* {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REQUEST_TOUCH_EXPLORATION_MODE}
* flag can receive gestures.
*
* @see AccessibilityService#onGesture(AccessibilityGestureEvent)
*/
public final class AccessibilityGestureEvent implements Parcelable {
/** @hide */
@IntDef(prefix = { "GESTURE_" }, value = {
GESTURE_UNKNOWN,
GESTURE_TOUCH_EXPLORATION,
GESTURE_2_FINGER_SINGLE_TAP,
GESTURE_2_FINGER_DOUBLE_TAP,
GESTURE_2_FINGER_DOUBLE_TAP_AND_HOLD,
GESTURE_2_FINGER_TRIPLE_TAP,
GESTURE_2_FINGER_TRIPLE_TAP_AND_HOLD,
GESTURE_3_FINGER_SINGLE_TAP,
GESTURE_3_FINGER_SINGLE_TAP_AND_HOLD,
GESTURE_3_FINGER_DOUBLE_TAP,
GESTURE_3_FINGER_DOUBLE_TAP_AND_HOLD,
GESTURE_3_FINGER_TRIPLE_TAP,
GESTURE_3_FINGER_TRIPLE_TAP_AND_HOLD,
GESTURE_DOUBLE_TAP,
GESTURE_DOUBLE_TAP_AND_HOLD,
GESTURE_SWIPE_UP,
GESTURE_SWIPE_UP_AND_LEFT,
GESTURE_SWIPE_UP_AND_DOWN,
GESTURE_SWIPE_UP_AND_RIGHT,
GESTURE_SWIPE_DOWN,
GESTURE_SWIPE_DOWN_AND_LEFT,
GESTURE_SWIPE_DOWN_AND_UP,
GESTURE_SWIPE_DOWN_AND_RIGHT,
GESTURE_SWIPE_LEFT,
GESTURE_SWIPE_LEFT_AND_UP,
GESTURE_SWIPE_LEFT_AND_RIGHT,
GESTURE_SWIPE_LEFT_AND_DOWN,
GESTURE_SWIPE_RIGHT,
GESTURE_SWIPE_RIGHT_AND_UP,
GESTURE_SWIPE_RIGHT_AND_LEFT,
GESTURE_SWIPE_RIGHT_AND_DOWN,
GESTURE_2_FINGER_SWIPE_DOWN,
GESTURE_2_FINGER_SWIPE_LEFT,
GESTURE_2_FINGER_SWIPE_RIGHT,
GESTURE_2_FINGER_SWIPE_UP,
GESTURE_3_FINGER_SWIPE_DOWN,
GESTURE_3_FINGER_SWIPE_LEFT,
GESTURE_3_FINGER_SWIPE_RIGHT,
GESTURE_3_FINGER_SWIPE_UP,
GESTURE_4_FINGER_DOUBLE_TAP,
GESTURE_4_FINGER_DOUBLE_TAP_AND_HOLD,
GESTURE_4_FINGER_SINGLE_TAP,
GESTURE_4_FINGER_SWIPE_DOWN,
GESTURE_4_FINGER_SWIPE_LEFT,
GESTURE_4_FINGER_SWIPE_RIGHT,
GESTURE_4_FINGER_SWIPE_UP,
GESTURE_4_FINGER_TRIPLE_TAP
})
@Retention(RetentionPolicy.SOURCE)
public @interface GestureId {}
@GestureId
private final int mGestureId;
private final int mDisplayId;
private List