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

Commit 093318ee authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Add importantForAccessibility mode to block entire hierarchy" into klp-dev

parents 7192c6d7 23be1991
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28337,6 +28337,7 @@ package android.view {
    field public static final int HAPTIC_FEEDBACK_ENABLED = 268435456; // 0x10000000
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0; // 0x0
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 2; // 0x2
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 4; // 0x4
    field public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 1; // 0x1
    field public static final int INVISIBLE = 4; // 0x4
    field public static final int KEEP_SCREEN_ON = 67108864; // 0x4000000
+6 −5
Original line number Diff line number Diff line
@@ -178,12 +178,13 @@ public class AccessibilityServiceInfo implements Parcelable {
     * If this flag is set the system will regard views that are not important
     * for accessibility in addition to the ones that are important for accessibility.
     * That is, views that are marked as not important for accessibility via
     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} and views that are marked as
     * potentially important for accessibility via
     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO} or
     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS} and views that are
     * marked as potentially important for accessibility via
     * {@link View#IMPORTANT_FOR_ACCESSIBILITY_AUTO} for which the system has determined
     * that are not important for accessibility, are both reported while querying the
     * window content and also the accessibility service will receive accessibility events
     * from them.
     * that are not important for accessibility, are reported while querying the window
     * content and also the accessibility service will receive accessibility events from
     * them.
     * <p>
     * <strong>Note:</strong> For accessibility services targeting API version
     * {@link Build.VERSION_CODES#JELLY_BEAN} or higher this flag has to be explicitly
+30 −14
Original line number Diff line number Diff line
@@ -2120,6 +2120,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
    /**
     * The view is not important for accessibility, nor are any of its
     * descendant views.
     */
    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004;
    /**
     * The default whether the view is important for accessibility.
     */
@@ -2130,14 +2136,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * whether a view is important for accessibility.
     */
    static final int PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK = (IMPORTANT_FOR_ACCESSIBILITY_AUTO
        | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO)
        | IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO
        | IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)
        << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT;
    /**
     * Shift for the bits in {@link #mPrivateFlags2} related to the
     * "accessibilityLiveRegion" attribute.
     */
    static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 22;
    static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 23;
    /**
     * Live region mode specifying that accessibility services should not
@@ -6999,12 +7006,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *
     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
     */
    @ViewDebug.ExportedProperty(category = "accessibility", mapping = {
            @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_AUTO, to = "auto"),
            @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_YES, to = "yes"),
            @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no")
            @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no"),
            @ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS,
                    to = "noHideDescendants")
        })
    public int getImportantForAccessibility() {
        return (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK)
@@ -7074,6 +7084,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *
     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
     */
    public void setImportantForAccessibility(int mode) {
@@ -7101,19 +7112,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    public boolean isImportantForAccessibility() {
        final int mode = (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK)
                >> PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT;
        switch (mode) {
            case IMPORTANT_FOR_ACCESSIBILITY_YES:
                return true;
            case IMPORTANT_FOR_ACCESSIBILITY_NO:
        if (mode == IMPORTANT_FOR_ACCESSIBILITY_NO
                || mode == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
            return false;
            case IMPORTANT_FOR_ACCESSIBILITY_AUTO:
                return isActionableForAccessibility() || hasListenersForAccessibility()
                        || getAccessibilityNodeProvider() != null
                        || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE;
            default:
                throw new IllegalArgumentException("Unknow important for accessibility mode: "
                        + mode);
        }
        // Check parent mode to ensure we're not hidden.
        ViewParent parent = mParent;
        while (parent instanceof View) {
            if (((View) parent).getImportantForAccessibility()
                    == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
                return false;
            }
            parent = parent.getParent();
        }
        return mode == IMPORTANT_FOR_ACCESSIBILITY_YES || isActionableForAccessibility()
                || hasListenersForAccessibility() || getAccessibilityNodeProvider() != null
                || getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE;
    }
    /**
+3 −0
Original line number Diff line number Diff line
@@ -2182,6 +2182,9 @@
            <enum name="yes" value="1" />
            <!-- The view is not important for accessibility. -->
            <enum name="no" value="2" />
            <!-- The view is not important for accessibility, nor are any of its descendant
                 views. -->
            <enum name="noHideDescendants" value="4" />
        </attr>

        <!-- Indicates to accessibility services whether the user should be notified when