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

Commit b8b49559 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Touch exploration feature, event bubling, refactor"

parents 461d8cd2 736c2756
Loading
Loading
Loading
Loading
+50 −30
Original line number Diff line number Diff line
@@ -21945,49 +21945,24 @@ package android.view {
package android.view.accessibility {
  public final class AccessibilityEvent implements android.os.Parcelable {
  public final class AccessibilityEvent extends android.view.accessibility.AccessibilityRecord implements android.os.Parcelable {
    method public void appendRecord(android.view.accessibility.AccessibilityRecord);
    method public int describeContents();
    method public int getAddedCount();
    method public java.lang.CharSequence getBeforeText();
    method public java.lang.CharSequence getClassName();
    method public java.lang.CharSequence getContentDescription();
    method public int getCurrentItemIndex();
    method public long getEventTime();
    method public int getEventType();
    method public int getFromIndex();
    method public int getItemCount();
    method public java.lang.CharSequence getPackageName();
    method public android.os.Parcelable getParcelableData();
    method public int getRemovedCount();
    method public java.util.List<java.lang.CharSequence> getText();
    method public android.view.accessibility.AccessibilityRecord getRecord(int);
    method public int getRecordCount();
    method public void initFromParcel(android.os.Parcel);
    method public boolean isChecked();
    method public boolean isEnabled();
    method public boolean isFullScreen();
    method public boolean isPassword();
    method public static android.view.accessibility.AccessibilityEvent obtain(int);
    method public static android.view.accessibility.AccessibilityEvent obtain();
    method public void recycle();
    method public void setAddedCount(int);
    method public void setBeforeText(java.lang.CharSequence);
    method public void setChecked(boolean);
    method public void setClassName(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setCurrentItemIndex(int);
    method public void setEnabled(boolean);
    method public void setEventTime(long);
    method public void setEventType(int);
    method public void setFromIndex(int);
    method public void setFullScreen(boolean);
    method public void setItemCount(int);
    method public void setPackageName(java.lang.CharSequence);
    method public void setParcelableData(android.os.Parcelable);
    method public void setPassword(boolean);
    method public void setRemovedCount(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int INVALID_POSITION = -1; // 0xffffffff
    field public static final int MAX_TEXT_LENGTH = 500; // 0x1f4
    field public static final deprecated int MAX_TEXT_LENGTH = 500; // 0x1f4
    field public static final int TYPES_ALL_MASK = -1; // 0xffffffff
    field public static final int TYPE_NOTIFICATION_STATE_CHANGED = 64; // 0x40
    field public static final int TYPE_VIEW_CLICKED = 1; // 0x1
@@ -22010,6 +21985,51 @@ package android.view.accessibility {
    method public void sendAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
  }
  public class AccessibilityRecord {
    ctor protected AccessibilityRecord();
    method protected void clear();
    method public int getAddedCount();
    method public java.lang.CharSequence getBeforeText();
    method public boolean getBooleanProperty(int);
    method public java.lang.CharSequence getClassName();
    method public java.lang.CharSequence getContentDescription();
    method public int getCurrentItemIndex();
    method public int getFromIndex();
    method public int getItemCount();
    method public android.os.Parcelable getParcelableData();
    method public int getRemovedCount();
    method public java.util.List<java.lang.CharSequence> getText();
    method public boolean isChecked();
    method public boolean isEnabled();
    method public boolean isFullScreen();
    method public boolean isPassword();
    method protected static android.view.accessibility.AccessibilityRecord obtain();
    method public void recycle();
    method public void setAddedCount(int);
    method public void setBeforeText(java.lang.CharSequence);
    method public void setChecked(boolean);
    method public void setClassName(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setCurrentItemIndex(int);
    method public void setEnabled(boolean);
    method public void setFromIndex(int);
    method public void setFullScreen(boolean);
    method public void setItemCount(int);
    method public void setParcelableData(android.os.Parcelable);
    method public void setPassword(boolean);
    method public void setRemovedCount(int);
    field protected int mAddedCount;
    field protected java.lang.CharSequence mBeforeText;
    field protected int mBooleanProperties;
    field protected java.lang.CharSequence mClassName;
    field protected java.lang.CharSequence mContentDescription;
    field protected int mCurrentItemIndex;
    field protected int mFromIndex;
    field protected int mItemCount;
    field protected android.os.Parcelable mParcelableData;
    field protected int mRemovedCount;
    field protected final java.util.List mText;
  }
}
package android.view.animation {
+59 −29
Original line number Diff line number Diff line
@@ -21174,6 +21174,7 @@ package android.view {
    method protected void onLayout(boolean, int, int, int, int);
    method protected void onMeasure(int, int);
    method protected void onOverScrolled(int, int, boolean, boolean);
    method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
    method protected void onRestoreInstanceState(android.os.Parcelable);
    method protected android.os.Parcelable onSaveInstanceState();
    method protected void onScrollChanged(int, int, int, int);
@@ -21585,6 +21586,7 @@ package android.view {
    method public boolean onInterceptTouchEvent(android.view.MotionEvent);
    method protected abstract void onLayout(boolean, int, int, int, int);
    method protected boolean onRequestFocusInDescendants(int, android.graphics.Rect);
    method public boolean onRequestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public void recomputeViewAttributes(android.view.View);
    method public void removeAllViews();
    method public void removeAllViewsInLayout();
@@ -21597,6 +21599,7 @@ package android.view {
    method public void requestChildFocus(android.view.View, android.view.View);
    method public boolean requestChildRectangleOnScreen(android.view.View, android.graphics.Rect, boolean);
    method public void requestDisallowInterceptTouchEvent(boolean);
    method public boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public void requestTransparentRegion(android.view.View);
    method public void scheduleLayoutAnimation();
    method public void setAddStatesFromChildren(boolean);
@@ -21683,6 +21686,7 @@ package android.view {
    method public abstract boolean requestChildRectangleOnScreen(android.view.View, android.graphics.Rect, boolean);
    method public abstract void requestDisallowInterceptTouchEvent(boolean);
    method public abstract void requestLayout();
    method public abstract boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public abstract void requestTransparentRegion(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
@@ -22028,53 +22032,32 @@ package android.view {
package android.view.accessibility {
  public final class AccessibilityEvent implements android.os.Parcelable {
  public final class AccessibilityEvent extends android.view.accessibility.AccessibilityRecord implements android.os.Parcelable {
    method public void appendRecord(android.view.accessibility.AccessibilityRecord);
    method public int describeContents();
    method public int getAddedCount();
    method public java.lang.CharSequence getBeforeText();
    method public java.lang.CharSequence getClassName();
    method public java.lang.CharSequence getContentDescription();
    method public int getCurrentItemIndex();
    method public long getEventTime();
    method public int getEventType();
    method public int getFromIndex();
    method public int getItemCount();
    method public java.lang.CharSequence getPackageName();
    method public android.os.Parcelable getParcelableData();
    method public int getRemovedCount();
    method public java.util.List<java.lang.CharSequence> getText();
    method public android.view.accessibility.AccessibilityRecord getRecord(int);
    method public int getRecordCount();
    method public void initFromParcel(android.os.Parcel);
    method public boolean isChecked();
    method public boolean isEnabled();
    method public boolean isFullScreen();
    method public boolean isPassword();
    method public static android.view.accessibility.AccessibilityEvent obtain(int);
    method public static android.view.accessibility.AccessibilityEvent obtain();
    method public void recycle();
    method public void setAddedCount(int);
    method public void setBeforeText(java.lang.CharSequence);
    method public void setChecked(boolean);
    method public void setClassName(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setCurrentItemIndex(int);
    method public void setEnabled(boolean);
    method public void setEventTime(long);
    method public void setEventType(int);
    method public void setFromIndex(int);
    method public void setFullScreen(boolean);
    method public void setItemCount(int);
    method public void setPackageName(java.lang.CharSequence);
    method public void setParcelableData(android.os.Parcelable);
    method public void setPassword(boolean);
    method public void setRemovedCount(int);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int INVALID_POSITION = -1; // 0xffffffff
    field public static final deprecated int MAX_TEXT_LENGTH = 500; // 0x1f4
    field public static final int TYPES_ALL_MASK = -1; // 0xffffffff
    field public static final int TYPE_NOTIFICATION_STATE_CHANGED = 64; // 0x40
    field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_END = 1024; // 0x400
    field public static final int TYPE_TOUCH_EXPLORATION_GESTURE_START = 512; // 0x200
    field public static final int TYPE_VIEW_CLICKED = 1; // 0x1
    field public static final int TYPE_VIEW_FOCUSED = 8; // 0x8
    field public static final int TYPE_VIEW_HOVER_ENTER = 128; // 0x80
    field public static final int TYPE_VIEW_HOVER_EXIT = 256; // 0x100
    field public static final int TYPE_VIEW_LONG_CLICKED = 2; // 0x2
    field public static final int TYPE_VIEW_SELECTED = 4; // 0x4
    field public static final int TYPE_VIEW_TEXT_CHANGED = 16; // 0x10
@@ -22088,11 +22071,58 @@ package android.view.accessibility {
  public final class AccessibilityManager {
    method public java.util.List<android.content.pm.ServiceInfo> getAccessibilityServiceList();
    method public java.util.List<android.content.pm.ServiceInfo> getEnabledAccessibilityServiceList(int);
    method public void interrupt();
    method public boolean isEnabled();
    method public void sendAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
  }
  public class AccessibilityRecord {
    ctor protected AccessibilityRecord();
    method protected void clear();
    method public int getAddedCount();
    method public java.lang.CharSequence getBeforeText();
    method public boolean getBooleanProperty(int);
    method public java.lang.CharSequence getClassName();
    method public java.lang.CharSequence getContentDescription();
    method public int getCurrentItemIndex();
    method public int getFromIndex();
    method public int getItemCount();
    method public android.os.Parcelable getParcelableData();
    method public int getRemovedCount();
    method public java.util.List<java.lang.CharSequence> getText();
    method public boolean isChecked();
    method public boolean isEnabled();
    method public boolean isFullScreen();
    method public boolean isPassword();
    method protected static android.view.accessibility.AccessibilityRecord obtain();
    method public void recycle();
    method public void setAddedCount(int);
    method public void setBeforeText(java.lang.CharSequence);
    method public void setChecked(boolean);
    method public void setClassName(java.lang.CharSequence);
    method public void setContentDescription(java.lang.CharSequence);
    method public void setCurrentItemIndex(int);
    method public void setEnabled(boolean);
    method public void setFromIndex(int);
    method public void setFullScreen(boolean);
    method public void setItemCount(int);
    method public void setParcelableData(android.os.Parcelable);
    method public void setPassword(boolean);
    method public void setRemovedCount(int);
    field protected int mAddedCount;
    field protected java.lang.CharSequence mBeforeText;
    field protected int mBooleanProperties;
    field protected java.lang.CharSequence mClassName;
    field protected java.lang.CharSequence mContentDescription;
    field protected int mCurrentItemIndex;
    field protected int mFromIndex;
    field protected int mItemCount;
    field protected android.os.Parcelable mParcelableData;
    field protected int mRemovedCount;
    field protected final java.util.List mText;
  }
}
package android.view.animation {
+17 −2
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.util.Log;
 * @hide
 */
public final class InputEventConsistencyVerifier {
    private static final String TAG = "InputEventConsistencyVerifier";
    private static final boolean IS_ENG_BUILD = "eng".equals(Build.TYPE);

    // The number of recent events to log when a problem is detected.
@@ -44,6 +43,11 @@ public final class InputEventConsistencyVerifier {
    // Consistency verifier flags.
    private final int mFlags;

    // Tag for logging which a client can set to help distinguish the output
    // from different verifiers since several can be active at the same time.
    // If not provided defaults to the simple class name.
    private final String mLogTag;

    // The most recently checked event and the nesting level at which it was checked.
    // This is only set when the verifier is called from a nesting level greater than 0
    // so that the verifier can detect when it has been asked to verify the same event twice.
@@ -103,8 +107,19 @@ public final class InputEventConsistencyVerifier {
     * @param flags Flags to the verifier, or 0 if none.
     */
    public InputEventConsistencyVerifier(Object caller, int flags) {
        this(caller, flags, InputEventConsistencyVerifier.class.getSimpleName());
    }

    /**
     * Creates an input consistency verifier.
     * @param caller The object to which the verifier is attached.
     * @param flags Flags to the verifier, or 0 if none.
     * @param logTag Tag for logging. If null defaults to the short class name.
     */
    public InputEventConsistencyVerifier(Object caller, int flags, String logTag) {
        this.mCaller = caller;
        this.mFlags = flags;
        this.mLogTag = (logTag != null) ? logTag : "InputEventConsistencyVerifier";
    }

    /**
@@ -596,7 +611,7 @@ public final class InputEventConsistencyVerifier {
                }
            }

            Log.d(TAG, mViolationMessage.toString());
            Log.d(mLogTag, mViolationMessage.toString());
            mViolationMessage.setLength(0);
            tainted = true;
        }
+26 −18
Original line number Diff line number Diff line
@@ -3455,6 +3455,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        if (!isShown()) {
            return;
        }

        // Populate these here since they are related to the View that
        // sends the event and should not be modified while dispatching
        // to descendants.
        event.setClassName(getClass().getName());
        event.setPackageName(getContext().getPackageName());
        event.setEnabled(isEnabled());
@@ -3470,21 +3474,37 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility

        dispatchPopulateAccessibilityEvent(event);

        AccessibilityManager.getInstance(mContext).sendAccessibilityEvent(event);
        // In the beginning we called #isShown(), so we know that getParent() is not null.
        getParent().requestSendAccessibilityEvent(this, event);
    }

    /**
     * Dispatches an {@link AccessibilityEvent} to the {@link View} children
     * to be populated.
     * Dispatches an {@link AccessibilityEvent} to the {@link View} children to be populated.
     * This method first calls {@link #onPopulateAccessibilityEvent(AccessibilityEvent)}
     * on this view allowing it to populate information about itself and also decide
     * whether to intercept the population i.e. to prevent its children from populating
     * the event.
     *
     * @param event The event.
     *
     * @return True if the event population was completed.
     */
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
        onPopulateAccessibilityEvent(event);
        return false;
    }

    /**
     * Called from {@link #dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
     * giving a chance to this View to populate the accessibility evnet with
     * information about itself.
     *
     * @param event The accessibility event which to populate.
     */
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {

    }

    /**
     * Gets the {@link View} description. It briefly describes the view and is
     * primarily used for accessibility support. Set this property to enable
@@ -5390,20 +5410,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * to receive the hover event.
     */
    public boolean onHoverEvent(MotionEvent event) {
        final int viewFlags = mViewFlags;

        if (((viewFlags & CLICKABLE) != CLICKABLE &&
                (viewFlags & LONG_CLICKABLE) != LONG_CLICKABLE)) {
            // Nothing to do if the view is not clickable.
            return false;
        }

        if ((viewFlags & ENABLED_MASK) == DISABLED) {
            // A disabled view that is clickable still consumes the hover events, it just doesn't
            // respond to them.
            return true;
        }

        switch (event.getAction()) {
            case MotionEvent.ACTION_HOVER_ENTER:
                setHovered(true);
@@ -5414,7 +5420,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                break;
        }

        return true;
        return false;
    }

    /**
@@ -5436,11 +5442,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            if ((mPrivateFlags & HOVERED) == 0) {
                mPrivateFlags |= HOVERED;
                refreshDrawableState();
                sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
            }
        } else {
            if ((mPrivateFlags & HOVERED) != 0) {
                mPrivateFlags &= ~HOVERED;
                refreshDrawableState();
                sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
            }
        }
    }
+21 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.view;
import android.app.AppGlobals;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.SparseArray;
@@ -155,6 +154,13 @@ public class ViewConfiguration {
     */
    private static final int MAXIMUM_FLING_VELOCITY = 8000;

    /**
     * Distance between a touch up event denoting the end of a touch exploration
     * gesture and the touch up event of a subsequent tap for the latter tap to be
     * considered as a tap i.e. to perform a click.
     */
    private static final int TOUCH_EXPLORATION_TAP_SLOP = 80;

    /**
     * The maximum size of View's drawing cache, expressed in bytes. This size
     * should be at least equal to the size of the screen in ARGB888 format.
@@ -185,6 +191,7 @@ public class ViewConfiguration {
    private final int mTouchSlop;
    private final int mPagingTouchSlop;
    private final int mDoubleTapSlop;
    private final int mScaledTouchExplorationTapSlop;
    private final int mWindowTouchSlop;
    private final int mMaximumDrawingCacheSize;
    private final int mOverscrollDistance;
@@ -206,6 +213,7 @@ public class ViewConfiguration {
        mTouchSlop = TOUCH_SLOP;
        mPagingTouchSlop = PAGING_TOUCH_SLOP;
        mDoubleTapSlop = DOUBLE_TAP_SLOP;
        mScaledTouchExplorationTapSlop = TOUCH_EXPLORATION_TAP_SLOP;
        mWindowTouchSlop = WINDOW_TOUCH_SLOP;
        //noinspection deprecation
        mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
@@ -242,6 +250,7 @@ public class ViewConfiguration {
        mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f);
        mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f);
        mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
        mScaledTouchExplorationTapSlop = (int) (density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f);
        mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);

        // Size of the screen in bytes, in ARGB_8888 format
@@ -443,6 +452,17 @@ public class ViewConfiguration {
        return mDoubleTapSlop;
    }

    /**
     * @return Distance between a touch up event denoting the end of a touch exploration
     * gesture and the touch up event of a subsequent tap for the latter tap to be
     * considered as a tap i.e. to perform a click.
     *
     * @hide
     */
    public int getScaledTouchExplorationTapSlop() {
        return mScaledTouchExplorationTapSlop;
    }

    /**
     * @return Distance a touch must be outside the bounds of a window for it
     * to be counted as outside the window for purposes of dismissing that
Loading