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

Commit a0c19056 authored by Casey Burkhardt's avatar Casey Burkhardt Committed by Android (Google) Code Review
Browse files

Merge "[Accessibility API] Add implementation for isRequired API" into main

parents d9179546 a6de34eb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55421,6 +55421,7 @@ package android.view.accessibility {
    method public boolean isDismissable();
    method public boolean isEditable();
    method public boolean isEnabled();
    method @FlaggedApi("android.view.accessibility.a11y_is_required_api") public boolean isFieldRequired();
    method public boolean isFocusable();
    method public boolean isFocused();
    method @FlaggedApi("android.view.accessibility.granular_scrolling") public boolean isGranularScrollingSupported();
@@ -55475,6 +55476,7 @@ package android.view.accessibility {
    method public void setEnabled(boolean);
    method public void setError(CharSequence);
    method @FlaggedApi("android.view.accessibility.a11y_expansion_state_api") public void setExpandedState(int);
    method @FlaggedApi("android.view.accessibility.a11y_is_required_api") public void setFieldRequired(boolean);
    method public void setFocusable(boolean);
    method public void setFocused(boolean);
    method @FlaggedApi("android.view.accessibility.granular_scrolling") public void setGranularScrollingSupported(boolean);
+31 −0
Original line number Diff line number Diff line
@@ -997,6 +997,8 @@ public class AccessibilityNodeInfo implements Parcelable {

    private static final int BOOLEAN_PROPERTY_SUPPORTS_GRANULAR_SCROLLING = 1 << 26;

    private static final int BOOLEAN_PROPERTY_FIELD_REQUIRED = 1 << 27;

    /**
     * Bits that provide the id of a virtual descendant of a view.
     */
@@ -2543,6 +2545,32 @@ public class AccessibilityNodeInfo implements Parcelable {
        setBooleanProperty(BOOLEAN_PROPERTY_CHECKED, checked == CHECKED_STATE_TRUE);
    }

    /**
     * Gets whether a node representing a form field requires input or selection.
     *
     * @return {@code true} if {@code this} node represents a form field that requires input or
     *     selection, {@code false} otherwise.
     */
    @FlaggedApi(Flags.FLAG_A11Y_IS_REQUIRED_API)
    public boolean isFieldRequired() {
        return getBooleanProperty(BOOLEAN_PROPERTY_FIELD_REQUIRED);
    }

    /**
     * Sets whether {@code this} node represents a form field that requires input or selection.
     *
     * <p><strong>Note:</strong> Cannot be called from an AccessibilityService. This class is made
     * immutable before being delivered to an AccessibilityService.
     *
     * @param required {@code true} if input or selection of this node should be required, {@code
     *     false} otherwise.
     * @throws IllegalStateException If called from an AccessibilityService
     */
    @FlaggedApi(Flags.FLAG_A11Y_IS_REQUIRED_API)
    public void setFieldRequired(boolean required) {
        setBooleanProperty(BOOLEAN_PROPERTY_FIELD_REQUIRED, required);
    }

    /**
     * Gets whether this node is focusable.
     *
@@ -5556,6 +5584,9 @@ public class AccessibilityNodeInfo implements Parcelable {

        builder.append("; checkable: ").append(isCheckable());
        builder.append("; checked: ").append(isChecked());
        if (Flags.a11yIsRequiredApi()) {
            builder.append("; required: ").append(isFieldRequired());
        }
        builder.append("; focusable: ").append(isFocusable());
        builder.append("; focused: ").append(isFocused());
        builder.append("; selected: ").append(isSelected());
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public class AccessibilityNodeInfoTest {

    // The number of flags held in boolean properties. Their values should also be double-checked
    // in the methods above.
    private static final int NUM_BOOLEAN_PROPERTIES = 27;
    private static final int NUM_BOOLEAN_PROPERTIES = 28;

    @Test
    public void testStandardActions_serializationFlagIsValid() {