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

Commit 3a86cd89 authored by Daniel Norman's avatar Daniel Norman Committed by Android (Google) Code Review
Browse files

Merge "Dispatch A11yEvents regardless of the AccessibilityDataPrivate property."

parents 7041049b 3567b980
Loading
Loading
Loading
Loading
+45 −18
Original line number Diff line number Diff line
@@ -14119,7 +14119,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        // working solution.
        View source = this;
        while (true) {
            if (source.includeForAccessibility()) {
            if (source.includeForAccessibility(false)) {
                source.sendAccessibilityEvent(eventType);
                return;
            }
@@ -14473,11 +14473,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // importance, since we'll need to check it later to make sure.
            final boolean maySkipNotify = oldMode == IMPORTANT_FOR_ACCESSIBILITY_AUTO
                    || mode == IMPORTANT_FOR_ACCESSIBILITY_AUTO;
            final boolean oldIncludeForAccessibility = maySkipNotify && includeForAccessibility();
            final boolean oldIncludeForAccessibility =
                    maySkipNotify && includeForAccessibility(false);
            mPrivateFlags2 &= ~PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK;
            mPrivateFlags2 |= (mode << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT)
                    & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK;
            if (!maySkipNotify || oldIncludeForAccessibility != includeForAccessibility()) {
            if (!maySkipNotify || oldIncludeForAccessibility != includeForAccessibility(false)) {
                notifySubtreeAccessibilityStateChangedIfNeeded();
            } else {
                notifyViewAccessibilityStateChangedIfNeeded(
@@ -14609,29 +14610,54 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * Whether to regard this view for accessibility. A view is regarded for
     * accessibility if it is important for accessibility or the querying
     * accessibility service has explicitly requested that view not
     * important for accessibility are regarded.
     *
     * @return Whether to regard the view for accessibility.
     *
     * @see #includeForAccessibility(boolean)
     * @hide
     */
    @UnsupportedAppUsage
    public boolean includeForAccessibility() {
        if (mAttachInfo != null) {
        return includeForAccessibility(true);
    }
    /**
     * Whether to regard this view for accessibility.
     *
     * <p>
     * If this decision is used for generating the accessibility node tree then this returns false
     * for {@link #isAccessibilityDataPrivate()} views queried by non-accessibility tools.
     * </p>
     * <p>
     * Otherwise, a view is regarded for accessibility if:
     * <li>the view returns true for {@link #isImportantForAccessibility()}, or</li>
     * <li>the querying accessibility service has explicitly requested that views not important for
     * accessibility are regarded by setting
     * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS}</li>
     * </p>
     *
     * @param forNodeTree True if the result of this function will be used for generating a node
     *                    tree, otherwise false (like when sending {@link AccessibilityEvent}s).
     * @return Whether to regard the view for accessibility.
     * @hide
     */
    public boolean includeForAccessibility(boolean forNodeTree) {
        if (mAttachInfo == null) {
            return false;
        }
        if (forNodeTree) {
            // The AccessibilityDataPrivate property should not effect whether this View is
            // included for consideration when sending AccessibilityEvents. Events copy their
            // source View's AccessibilityDataPrivate value, and then filtering is done when
            // AccessibilityManagerService propagates events to each recipient AccessibilityService.
            if (!AccessibilityManager.getInstance(mContext).isRequestFromAccessibilityTool()
                    && isAccessibilityDataPrivate()) {
                return false;
            }
        }
        return (mAttachInfo.mAccessibilityFetchFlags
                & AccessibilityNodeInfo.FLAG_SERVICE_REQUESTS_INCLUDE_NOT_IMPORTANT_VIEWS) != 0
                || isImportantForAccessibility();
    }
        return false;
    }
    /**
     * Whether this view should restrict accessibility service access only to services that have the
@@ -17178,7 +17204,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    void setFlags(int flags, int mask) {
        final boolean accessibilityEnabled =
                AccessibilityManager.getInstance(mContext).isEnabled();
        final boolean oldIncludeForAccessibility = accessibilityEnabled && includeForAccessibility();
        final boolean oldIncludeForAccessibility =
                accessibilityEnabled && includeForAccessibility(false);
        int old = mViewFlags;
        mViewFlags = (mViewFlags & ~mask) | (flags & mask);
@@ -17404,7 +17431,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if ((changed & FOCUSABLE) != 0 || (changed & VISIBILITY_MASK) != 0
                    || (changed & CLICKABLE) != 0 || (changed & LONG_CLICKABLE) != 0
                    || (changed & CONTEXT_CLICKABLE) != 0) {
                if (oldIncludeForAccessibility != includeForAccessibility()) {
                if (oldIncludeForAccessibility != includeForAccessibility(false)) {
                    notifySubtreeAccessibilityStateChangedIfNeeded();
                } else {
                    notifyViewAccessibilityStateChangedIfNeeded(
+1 −1
Original line number Diff line number Diff line
@@ -3532,7 +3532,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
    @Override
    public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) {
        boolean handled = false;
        if (includeForAccessibility()) {
        if (includeForAccessibility(false)) {
            handled = super.dispatchPopulateAccessibilityEventInternal(event);
            if (handled) {
                return handled;