From 85f30de218f1e28c3812bd14244dbbf603fa1692 Mon Sep 17 00:00:00 2001 From: yingleiw Date: Tue, 10 Aug 2021 11:57:59 -0700 Subject: [PATCH] Update view#sendAccessibilityEvent(int eventType) doc Update view#sendAccessibilityEvent(int eventType) doc to add the throttling and note that it should not be used for virtual children. Fix: b/196070848 Test: not needed for doc change only. Change-Id: Ie85bca3ad330ab946ff990bae598bbeae4c93da3 --- core/java/android/view/View.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 1793eaf2ec57a..505f88ae4698b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8204,7 +8204,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * to populate information about the event source (this View), then calls * {@link #dispatchPopulateAccessibilityEvent(AccessibilityEvent)} to * populate the text content of the event source including its descendants, - * and last calls + * then for events type {@link AccessibilityEvent#TYPE_VIEW_SCROLLED} + * and {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED} with + * subtype {@link AccessibilityEvent#CONTENT_CHANGE_TYPE_STATE_DESCRIPTION}, + * throttle the events, and last calls * {@link ViewParent#requestSendAccessibilityEvent(View, AccessibilityEvent)} * on its parent to request sending of the event to interested parties. *

@@ -8213,11 +8216,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@link AccessibilityDelegate#sendAccessibilityEvent(View, int)} is * responsible for handling this call. *

+ *

+ * If this view uses {@link AccessibilityNodeProvider} to provide virtual view hierarchy rooted + * at this view, this method should not be called to send events from virtual children because + * it will populate the events with wrong information and the events should be throttled per + * child instead at the virtual root level. To send events from virtual children, call + * {@link ViewParent#requestSendAccessibilityEvent(View, AccessibilityEvent)} on the view's + * parent to request sending of the event to interested parties. + *

* * @param eventType The type of the event to send, as defined by several types from - * {@link android.view.accessibility.AccessibilityEvent}, such as - * {@link android.view.accessibility.AccessibilityEvent#TYPE_VIEW_CLICKED} or - * {@link android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER}. + * {@link AccessibilityEvent}, such as + * {@link AccessibilityEvent#TYPE_VIEW_CLICKED} or + * {@link AccessibilityEvent#TYPE_VIEW_HOVER_ENTER}. * * @see #onInitializeAccessibilityEvent(AccessibilityEvent) * @see #dispatchPopulateAccessibilityEvent(AccessibilityEvent)