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

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

Merge "Deprecate View#announceForAccessibility and AccessibilityEvent.TYPE_ANNOUNCEMENT" into main

parents 892faa99 6f6a513b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52997,7 +52997,7 @@ package android.view {
    method public void addOnUnhandledKeyEventListener(android.view.View.OnUnhandledKeyEventListener);
    method public void addTouchables(java.util.ArrayList<android.view.View>);
    method public android.view.ViewPropertyAnimator animate();
    method public void announceForAccessibility(CharSequence);
    method @Deprecated @FlaggedApi("android.view.accessibility.deprecate_accessibility_announcement_apis") public void announceForAccessibility(CharSequence);
    method public void autofill(android.view.autofill.AutofillValue);
    method public void autofill(@NonNull android.util.SparseArray<android.view.autofill.AutofillValue>);
    method protected boolean awakenScrollBars();
@@ -55247,7 +55247,7 @@ package android.view.accessibility {
    field public static final int SPEECH_STATE_SPEAKING_END = 2; // 0x2
    field public static final int SPEECH_STATE_SPEAKING_START = 1; // 0x1
    field public static final int TYPES_ALL_MASK = -1; // 0xffffffff
    field public static final int TYPE_ANNOUNCEMENT = 16384; // 0x4000
    field @Deprecated @FlaggedApi("android.view.accessibility.deprecate_accessibility_announcement_apis") public static final int TYPE_ANNOUNCEMENT = 16384; // 0x4000
    field public static final int TYPE_ASSIST_READING_CONTEXT = 16777216; // 0x1000000
    field public static final int TYPE_GESTURE_DETECTION_END = 524288; // 0x80000
    field public static final int TYPE_GESTURE_DETECTION_START = 262144; // 0x40000
+29 −27
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.view.Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_GTE;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED;
import static android.view.accessibility.Flags.FLAG_DEPRECATE_ACCESSIBILITY_ANNOUNCEMENT_APIS;
import static android.view.accessibility.Flags.FLAG_SUPPLEMENTAL_DESCRIPTION;
import static android.view.accessibility.Flags.removeChildHoverCheckForTouchExploration;
import static android.view.accessibility.Flags.supplementalDescription;
@@ -8941,44 +8942,45 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    }
    /**
     * Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT}
     * {@link AccessibilityEvent} to suggest that an accessibility service announce the
     * specified text to its users.
     * <p>
     * Note: The event generated with this API carries no semantic meaning, and is appropriate only
     * in exceptional situations. Apps can generally achieve correct behavior for accessibility by
     * accurately supplying the semantics of their UI.
     * They should not need to specify what exactly is announced to users.
     * Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT} {@link
     * AccessibilityEvent} to suggest that an accessibility service announce the specified text to
     * its users.
     *
     * <p>
     * In general, only announce transitions and don't generate a confirmation message for simple
     * actions like a button press. Label your controls concisely and precisely instead, and for
     * significant UI changes like window changes, use
     * {@link android.app.Activity#setTitle(CharSequence)} and
     * {@link #setAccessibilityPaneTitle(CharSequence)}.
     * <p>Note: The event generated with this API carries no semantic meaning, and accessibility
     * services may choose to ignore it. Apps that accurately supply accessibility with the
     * semantics of their UI should not need to specify what exactly is announced.
     *
     * <p>
     * Use {@link #setAccessibilityLiveRegion(int)} to inform the user of changes to critical
     * <p>In general, do not attempt to generate announcements as confirmation message for simple
     * actions like a button press. Label your controls concisely and precisely instead.
     *
     * <p>To convey significant UI changes like window changes, use {@link
     * android.app.Activity#setTitle(CharSequence)} and {@link
     * #setAccessibilityPaneTitle(CharSequence)}.
     *
     * <p>Use {@link #setAccessibilityLiveRegion(int)} to inform the user of changes to critical
     * views within the user interface. These should still be used sparingly as they may generate
     * announcements every time a View is updated.
     *
     * <p>
     * For notifying users about errors, such as in a login screen with text that displays an
     * "incorrect password" notification, that view should send an AccessibilityEvent of type
     * {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR} and set
     * {@link AccessibilityNodeInfo#setError(CharSequence)} instead. Custom widgets should expose
     * error-setting methods that support accessibility automatically. For example, instead of
     * explicitly sending this event when using a TextView, use
     * {@link android.widget.TextView#setError(CharSequence)}.
     *
     * <p>
     * Use {@link #setStateDescription(CharSequence)} to convey state changes to views within the
     * <p>Use {@link #setStateDescription(CharSequence)} to convey state changes to views within the
     * user interface. While a live region may send different types of events generated by the view,
     * state description will send {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED} events of
     * type {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION}.
     *
     * <p>For notifying users about errors, such as in a login screen with text that displays an
     * "incorrect password" notification, set {@link AccessibilityNodeInfo#setError(CharSequence)}
     * and dispatch an {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED} event with a change
     * type of {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR}, instead. Some widgets may
     * expose methods that convey error states to accessibility automatically, such as {@link
     * android.widget.TextView#setError(CharSequence)}, which manages these accessibility semantics
     * and event dispatch for callers.
     *
     * @deprecated Use one of the methods described in the documentation above to semantically
     *     describe UI instead of using an announcement, as accessibility services may choose to
     *     ignore events dispatched with this method.
     * @param text The announcement text.
     */
    @FlaggedApi(FLAG_DEPRECATE_ACCESSIBILITY_ANNOUNCEMENT_APIS)
    @Deprecated
    public void announceForAccessibility(CharSequence text) {
        if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
            AccessibilityEvent event = AccessibilityEvent.obtain(
+6 −3
Original line number Diff line number Diff line
@@ -563,10 +563,13 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par

    /**
     * Represents the event of an application making an announcement.
     * <p>
     * In general, follow the practices described in
     * {@link View#announceForAccessibility(CharSequence)}.
     *
     * @deprecated Use one of the semantic alternative methods described in the documentation of
     *     {@link View#announceForAccessibility(CharSequence)} instead of using this event, as
     *     accessibility services may choose to ignore dispatch of this event type.
     */
    @FlaggedApi(Flags.FLAG_DEPRECATE_ACCESSIBILITY_ANNOUNCEMENT_APIS)
    @Deprecated
    public static final int TYPE_ANNOUNCEMENT = 1 << 14;

    /**
+7 −0
Original line number Diff line number Diff line
@@ -83,6 +83,13 @@ flag {
    bug: "280130713"
}

flag {
    namespace: "accessibility"
    name: "deprecate_accessibility_announcement_apis"
    description: "Controls the deprecation of platform APIs related to disruptive accessibility announcements"
    bug: "376727542"
}

flag {
    namespace: "accessibility"
    name: "fix_merged_content_change_event_v2"