From 0d925fbbcd64d690388f7b39c632cdb67fe2c11e Mon Sep 17 00:00:00 2001 From: Saho Kobayashi Date: Sun, 4 Apr 2021 13:45:18 +0900 Subject: [PATCH] Fix index corner bug to search the target node In dispatchTouchEvent(), the target node is searched by the for loop. When the TargetAccessibilityFocus flag is set, dispatchTouchEvent prioritizes finding the accessibility focused node first. When the accessibility focused node doesn't handle the event, the second search is done without the TargetAccessibilityFocus flag. To prepare for the second search, the index is reset when the accessibility focused node is found. Currently the index is reset to childrenCount - 1, which is the same as the initial index of the for loop, but to search the same range as the first search, we need to reset it to childrenCount, because the actual second search starts from the next loop. Bug: 182434603 Test: atest TouchExplorerTest Change-Id: Ifc88f7df43bd26e978b24a0d94cfb1ce60c6cb3b --- core/java/android/view/ViewGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 5b695f4c425a1..6db5eae86be9d 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2723,7 +2723,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager continue; } childWithAccessibilityFocus = null; - i = childrenCount - 1; + i = childrenCount; } if (!child.canReceivePointerEvents()