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

Commit 2d80ae4f authored by Casey Burkhardt's avatar Casey Burkhardt
Browse files

Exposes accessibility importance on AccessibilityNodeInfo

This allows a service configured with FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
to discover which views in the hierarchy were evaluated as important.

Change-Id: Ife9411e41326b4872fc0682773722b9dae7ce994
parent 14a79bd1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -43669,6 +43669,7 @@ package android.view.accessibility {
    method public boolean isEnabled();
    method public boolean isFocusable();
    method public boolean isFocused();
    method public boolean isImportantForAccessibility();
    method public boolean isLongClickable();
    method public boolean isMultiLine();
    method public boolean isPassword();
@@ -43707,6 +43708,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
    method public void setLabelFor(android.view.View, int);
+2 −0
Original line number Diff line number Diff line
@@ -46089,6 +46089,7 @@ package android.view.accessibility {
    method public boolean isEnabled();
    method public boolean isFocusable();
    method public boolean isFocused();
    method public boolean isImportantForAccessibility();
    method public boolean isLongClickable();
    method public boolean isMultiLine();
    method public boolean isPassword();
@@ -46127,6 +46128,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
    method public void setLabelFor(android.view.View, int);
+2 −0
Original line number Diff line number Diff line
@@ -43686,6 +43686,7 @@ package android.view.accessibility {
    method public boolean isEnabled();
    method public boolean isFocusable();
    method public boolean isFocused();
    method public boolean isImportantForAccessibility();
    method public boolean isLongClickable();
    method public boolean isMultiLine();
    method public boolean isPassword();
@@ -43724,6 +43725,7 @@ package android.view.accessibility {
    method public void setError(java.lang.CharSequence);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method public void setImportantForAccessibility(boolean);
    method public void setInputType(int);
    method public void setLabelFor(android.view.View);
    method public void setLabelFor(android.view.View, int);
+7 −0
Original line number Diff line number Diff line
@@ -6770,6 +6770,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        info.setVisibleToUser(isVisibleToUser());
        if ((mAttachInfo != null) && ((mAttachInfo.mAccessibilityFetchFlags
                & AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0)) {
            info.setImportantForAccessibility(isImportantForAccessibility());
        } else {
            info.setImportantForAccessibility(true);
        }
        info.setPackageName(mContext.getPackageName());
        info.setClassName(getAccessibilityClassName());
        info.setContentDescription(getContentDescription());
+29 −0
Original line number Diff line number Diff line
@@ -568,6 +568,8 @@ public class AccessibilityNodeInfo implements Parcelable {

    private static final int BOOLEAN_PROPERTY_CONTEXT_CLICKABLE = 0x00020000;

    private static final int BOOLEAN_PROPERTY_IMPORTANCE = 0x0040000;

    /**
     * Bits that provide the id of a virtual descendant of a view.
     */
@@ -2155,6 +2157,33 @@ public class AccessibilityNodeInfo implements Parcelable {
        setBooleanProperty(BOOLEAN_PROPERTY_DISMISSABLE, dismissable);
    }

    /**
     * Returns whether the node originates from a view considered important for accessibility.
     *
     * @return {@code true} if the node originates from a view considered important for
     *         accessibility, {@code false} otherwise
     *
     * @see View#isImportantForAccessibility()
     */
    public boolean isImportantForAccessibility() {
        return getBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE);
    }

    /**
     * Sets whether the node is considered important for accessibility.
     * <p>
     *   <strong>Note:</strong> Cannot be called from an
     *   {@link android.accessibilityservice.AccessibilityService}.
     *   This class is made immutable before being delivered to an AccessibilityService.
     * </p>
     *
     * @param important {@code true} if the node is considered important for accessibility,
     *                  {@code false} otherwise
     */
    public void setImportantForAccessibility(boolean important) {
        setBooleanProperty(BOOLEAN_PROPERTY_IMPORTANCE, important);
    }

    /**
     * Gets the package this node comes from.
     *