Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ec2e1b9 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Remove activation gestures form reported and add a touch explore requesting flag.

1. Delegating activation gestures has several issues that we should
   decide how to handle if possible before allowing an accessibility
   service to take over them:

   A) It is needed that every view than can be clicked or long pressed on
      reacts to such as a response to calling performClick and performLongPress
      which is not necessary true since the view may watch the touch
      events and do its own click long click detection. As a result it may
      be possible that there are view a user cannot interact with in
      touch exploration mode but can if not in that mode.

   B) Clicking or long pressing on a different location in a view may yield
      different results, for example NumberPicker. Ideally such views have
      to implement AccessibilityNodeProvide which provider handles correctly
      the request for click long press on virtual nodes. Some apps however
      just fire different hover accessibility events when the user is over
      a specific semantic portion of the view but do not provide virtual
      nodes. Hence, a user will not be able to interact with such semantic
      regions but the system can achieve that by sending the click/long click
      at the precise location in the view that was last touch explored.

2. Adding a flag on accessibility service info to request explore by touch
   mode. There is no need to put the device in this mode if node of the currently
   enabled accessibility services supports it. Now the problem is inverted and
   the service has to explicitly state its capability.

3. Fixing a bug where includeImportantViews was ignored for automation
   services.

Change-Id: I3b29a19f24ab5e26ee29f974bbac2197614c9e2a

Conflicts:

	api/current.txt
parent bb0018d0
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -315,7 +315,6 @@ package android {
    field public static final int cacheColorHint = 16843009; // 0x1010101
    field public static final int calendarViewShown = 16843596; // 0x101034c
    field public static final int calendarViewStyle = 16843613; // 0x101035d
    field public static final int canHandleGestures = 16843699; // 0x10103b3
    field public static final int canRetrieveWindowContent = 16843653; // 0x1010385
    field public static final int candidatesTextStyleSpans = 16843312; // 0x1010230
    field public static final deprecated int capitalize = 16843113; // 0x1010169
@@ -759,7 +758,7 @@ package android {
    field public static final int pathPrefix = 16842795; // 0x101002b
    field public static final int permission = 16842758; // 0x1010006
    field public static final int permissionGroup = 16842762; // 0x101000a
    field public static final int permissionGroupFlags = 16843700; // 0x10103b4
    field public static final int permissionGroupFlags = 16843691; // 0x10103ab
    field public static final int persistent = 16842765; // 0x101000d
    field public static final int persistentDrawingCache = 16842990; // 0x10100ee
    field public static final deprecated int phoneNumber = 16843111; // 0x1010167
@@ -2025,7 +2024,6 @@ package android.accessibilityservice {
    method protected void onServiceConnected();
    method public final boolean performGlobalAction(int);
    method public final void setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo);
    field public static final int GESTURE_DOUBLE_TAP = 17; // 0x11
    field public static final int GESTURE_SWIPE_DOWN = 2; // 0x2
    field public static final int GESTURE_SWIPE_DOWN_AND_LEFT = 15; // 0xf
    field public static final int GESTURE_SWIPE_DOWN_AND_RIGHT = 16; // 0x10
@@ -2042,7 +2040,6 @@ package android.accessibilityservice {
    field public static final int GESTURE_SWIPE_UP_AND_DOWN = 7; // 0x7
    field public static final int GESTURE_SWIPE_UP_AND_LEFT = 13; // 0xd
    field public static final int GESTURE_SWIPE_UP_AND_RIGHT = 14; // 0xe
    field public static final int GESTURE_TAP_AND_HOLD = 18; // 0x12
    field public static final int GLOBAL_ACTION_BACK = 1; // 0x1
    field public static final int GLOBAL_ACTION_HOME = 2; // 0x2
    field public static final int GLOBAL_ACTION_NOTIFICATIONS = 4; // 0x4
@@ -2056,7 +2053,6 @@ package android.accessibilityservice {
    method public int describeContents();
    method public static java.lang.String feedbackTypeToString(int);
    method public static java.lang.String flagToString(int);
    method public boolean getCanHandleGestures();
    method public boolean getCanRetrieveWindowContent();
    method public deprecated java.lang.String getDescription();
    method public java.lang.String getId();
@@ -2072,7 +2068,8 @@ package android.accessibilityservice {
    field public static final int FEEDBACK_HAPTIC = 2; // 0x2
    field public static final int FEEDBACK_SPOKEN = 1; // 0x1
    field public static final int FEEDBACK_VISUAL = 8; // 0x8
    field public static final int INCLUDE_NOT_IMPORTANT_VIEWS = 2; // 0x2
    field public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 2; // 0x2
    field public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE = 4; // 0x4
    field public int eventTypes;
    field public int feedbackType;
    field public int flags;
+5 −22
Original line number Diff line number Diff line
@@ -283,16 +283,6 @@ public abstract class AccessibilityService extends Service {
     */
    public static final int GESTURE_SWIPE_DOWN_AND_RIGHT = 16;

    /**
     * The user has performed a double tap gesture on the touch screen.
     */
    public static final int GESTURE_DOUBLE_TAP = 17;

    /**
     * The user has performed a tap and hold gesture on the touch screen.
     */
    public static final int GESTURE_TAP_AND_HOLD = 18;

    /**
     * The {@link Intent} that must be declared as handled by the service.
     */
@@ -377,14 +367,12 @@ public abstract class AccessibilityService extends Service {

    /**
     * Called by the system when the user performs a specific gesture on the
     * touch screen. If the gesture is not handled in this callback the system
     * may provide default handing. Therefore, one should return true from this
     * function if overriding of default behavior is desired.
     * touch screen.
     *
     * <strong>Note:</strong> To receive gestures an accessibility service
     *         must declare that it can handle such by specifying the
     *         <code>&lt;{@link android.R.styleable#AccessibilityService_canHandleGestures
     *         canHandleGestures}&gt;</code> attribute.
     * <strong>Note:</strong> To receive gestures an accessibility service must
     * request that the device is in touch exploration mode by setting the
     * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS}
     * flag.
     *
     * @param gestureId The unique id of the performed gesture.
     *
@@ -406,13 +394,8 @@ public abstract class AccessibilityService extends Service {
     * @see #GESTURE_SWIPE_RIGHT_AND_UP
     * @see #GESTURE_SWIPE_RIGHT_AND_LEFT
     * @see #GESTURE_SWIPE_RIGHT_AND_DOWN
     * @see #GESTURE_CLOCKWISE_CIRCLE
     * @see #GESTURE_COUNTER_CLOCKWISE_CIRCLE
     * @see #GESTURE_DOUBLE_TAP
     * @see #GESTURE_TAP_AND_HOLD
     */
    protected boolean onGesture(int gestureId) {
        // TODO: Describe the default gesture processing in the javaDoc once it is finalized.
        return false;
    }

+19 −23
Original line number Diff line number Diff line
@@ -131,7 +131,19 @@ public class AccessibilityServiceInfo implements Parcelable {
     * elements.
     * </p>
     */
    public static final int INCLUDE_NOT_IMPORTANT_VIEWS = 0x0000002;
    public static final int FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x0000002;

    /**
     * This flag requests that the system gets into touch exploration mode.
     * In this mode a single finger moving on the screen behaves as a mouse
     * pointer hovering over the user interface. The system will also detect
     * certain gestures performed on the touch screen and notify this service.
     * The system will enable touch exploration mode if there is at least one
     * accessibility service that has this flag set. Hence, clearing this
     * flag does not guarantee that the device will not be in touch exploration
     * mode since there may be another enabled service that requested it.
     */
    public static final int FLAG_REQUEST_TOUCH_EXPLORATION_MODE= 0x0000004;

    /**
     * The event types an {@link AccessibilityService} is interested in.
@@ -198,7 +210,8 @@ public class AccessibilityServiceInfo implements Parcelable {
     *   <strong>Can be dynamically set at runtime.</strong>
     * </p>
     * @see #DEFAULT
     * @see #INCLUDE_NOT_IMPORTANT_VIEWS
     * @see #FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
     * @see #FLAG_REQUEST_TOUCH_EXPLORATION_MODE
     */
    public int flags;

@@ -223,11 +236,6 @@ public class AccessibilityServiceInfo implements Parcelable {
     */
    private boolean mCanRetrieveWindowContent;

    /**
     * Flag whether this accessibility service can handle gestures.
     */
    private boolean mCanHandleGestures;

    /**
     * Resource id of the description of the accessibility service.
     */
@@ -308,8 +316,6 @@ public class AccessibilityServiceInfo implements Parcelable {
            mCanRetrieveWindowContent = asAttributes.getBoolean(
                    com.android.internal.R.styleable.AccessibilityService_canRetrieveWindowContent,
                    false);
            mCanHandleGestures = asAttributes.getBoolean(
                    com.android.internal.R.styleable.AccessibilityService_canHandleGestures, false);
            TypedValue peekedValue = asAttributes.peekValue(
                    com.android.internal.R.styleable.AccessibilityService_description);
            if (peekedValue != null) {
@@ -391,18 +397,6 @@ public class AccessibilityServiceInfo implements Parcelable {
        return mCanRetrieveWindowContent;
    }

    /**
     * Whether this service can handle gestures.
     * <p>
     *    <strong>Statically set from
     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
     * </p>
     * @return True if the service can handle gestures.
     */
    public boolean getCanHandleGestures() {
        return mCanHandleGestures;
    }

    /**
     * Gets the non-localized description of the accessibility service.
     * <p>
@@ -614,8 +608,10 @@ public class AccessibilityServiceInfo implements Parcelable {
        switch (flag) {
            case DEFAULT:
                return "DEFAULT";
            case INCLUDE_NOT_IMPORTANT_VIEWS:
                return "REGARD_VIEWS_NOT_IMPORTANT_FOR_ACCESSIBILITY";
            case FLAG_INCLUDE_NOT_IMPORTANT_VIEWS:
                return "FLAG_INCLUDE_NOT_IMPORTANT_VIEWS";
            case FLAG_REQUEST_TOUCH_EXPLORATION_MODE:
                return "FLAG_REQUEST_TOUCH_EXPLORATION_MODE";
            default:
                return null;
        }
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public class UiTestAutomationBridge {
        final AccessibilityServiceInfo info = new AccessibilityServiceInfo();
        info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
        info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
        info.flags |= AccessibilityServiceInfo.INCLUDE_NOT_IMPORTANT_VIEWS;
        info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;

        try {
            manager.registerUiTestAutomationService(mListener, info);
+3 −3
Original line number Diff line number Diff line
@@ -2461,8 +2461,10 @@
        <attr name="accessibilityFlags">
            <!-- Has flag {@link android.accessibilityservice.AccessibilityServiceInfo#DEFAULT} -->
            <flag name="flagDefault" value="0x00000001" />
            <!-- Has flag {@link android.accessibilityservice.AccessibilityServiceInfo#INCLUDE_NOT_IMPORTANT_VIEWS} -->
            <!-- Has flag {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} -->
            <flag name="flagIncludeNotImportantViews" value="0x00000002" />
            <!-- Has flag {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REQUEST_TOUCH_EXPLORATION_MODE} -->
            <flag name="flagRequestTouchExplorationMode" value="0x00000004" />
        </attr>
        <!-- Component name of an activity that allows the user to modify
             the settings for this service. This setting cannot be changed at runtime. -->
@@ -2470,8 +2472,6 @@
        <!-- Flag whether the accessibility service wants to be able to retrieve the
             active window content. This setting cannot be changed at runtime. -->
        <attr name="canRetrieveWindowContent" format="boolean" />
        <!-- Flag whether the accessibility service can handle gesrures and wants such. -->
        <attr name="canHandleGestures" format="boolean" />
        <!-- Short description of the accessibility serivce purpose or behavior.-->
        <attr name="description" />
    </declare-styleable>
Loading