diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index a7129561c7548..3a3eea966a866 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -48,6 +48,7 @@ import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.KeyEvent; +import android.view.SurfaceView; import android.view.WindowManager; import android.view.WindowManagerImpl; import android.view.accessibility.AccessibilityEvent; @@ -1832,6 +1833,14 @@ public abstract class AccessibilityService extends Service { * setting the {@link AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS} * flag. Otherwise, the search will be performed only in the active window. *

+ *

+ * Note: If the view with {@link AccessibilityNodeInfo#FOCUS_INPUT} + * is on an embedded view hierarchy which is embedded in a {@link SurfaceView} via + * {@link SurfaceView#setChildSurfacePackage}, there is a limitation that this API + * won't be able to find the node for the view. It's because views don't know about + * the embedded hierarchies. Instead, you could traverse all the nodes to find the + * focus. + *

* * @param focus The focus to find. One of {@link AccessibilityNodeInfo#FOCUS_INPUT} or * {@link AccessibilityNodeInfo#FOCUS_ACCESSIBILITY}. diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 454953cce33c8..f2cbf895dfb66 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -52,6 +52,7 @@ import android.util.LongArray; import android.util.Pools.SynchronizedPool; import android.util.Size; import android.util.TypedValue; +import android.view.SurfaceView; import android.view.TouchDelegate; import android.view.View; import android.view.ViewGroup; @@ -916,6 +917,15 @@ public class AccessibilityNodeInfo implements Parcelable { * Find the view that has the specified focus type. The search starts from * the view represented by this node info. * + *

+ * Note: If this view hierarchy has a {@link SurfaceView} embedding another + * view hierarchy via {@link SurfaceView#setChildSurfacePackage}, there is a limitation that + * this API won't be able to find the node for the view on the embedded view hierarchy. It's + * because views don't know about the embedded hierarchies. Instead, you could traverse all + * the children to find the node. Or, use {@link AccessibilityService#findFocus(int)} for + * {@link #FOCUS_ACCESSIBILITY} only since it has no such limitation. + *

+ * * @param focus The focus to find. One of {@link #FOCUS_INPUT} or * {@link #FOCUS_ACCESSIBILITY}. * @return The node info of the focused view or null. @@ -937,6 +947,14 @@ public class AccessibilityNodeInfo implements Parcelable { * Searches for the nearest view in the specified direction that can take * the input focus. * + *

+ * Note: If this view hierarchy has a {@link SurfaceView} embedding another + * view hierarchy via {@link SurfaceView#setChildSurfacePackage}, there is a limitation that + * this API won't be able to find the node for the view in the specified direction on the + * embedded view hierarchy. It's because views don't know about the embedded hierarchies. + * Instead, you could traverse all the children to find the node. + *

+ * * @param direction The direction. Can be one of: * {@link View#FOCUS_DOWN}, * {@link View#FOCUS_UP}, @@ -1723,6 +1741,13 @@ public class AccessibilityNodeInfo implements Parcelable { * received info by calling {@link AccessibilityNodeInfo#recycle()} * to avoid creating of multiple instances. *

+ *

+ * Note: If this view hierarchy has a {@link SurfaceView} embedding another + * view hierarchy via {@link SurfaceView#setChildSurfacePackage}, there is a limitation that + * this API won't be able to find the node for the view on the embedded view hierarchy. It's + * because views don't know about the embedded hierarchies. Instead, you could traverse all + * the children to find the node. + *

* * @param text The searched text. * @return A list of node info. @@ -1754,6 +1779,13 @@ public class AccessibilityNodeInfo implements Parcelable { * the client has to set the {@link AccessibilityServiceInfo#FLAG_REPORT_VIEW_IDS} * flag when configuring his {@link android.accessibilityservice.AccessibilityService}. *

+ *

+ * Note: If this view hierarchy has a {@link SurfaceView} embedding another + * view hierarchy via {@link SurfaceView#setChildSurfacePackage}, there is a limitation that + * this API won't be able to find the node for the view on the embedded view hierarchy. It's + * because views don't know about the embedded hierarchies. Instead, you could traverse all + * the children to find the node. + *

* * @param viewId The fully qualified resource name of the view id to find. * @return A list of node info.