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

Commit 6485b545 authored by sahok's avatar sahok Committed by Saho Kobayashi
Browse files

Correctly handle TargetAccessibilityFocus flag

In current implementation of GroupView, TargetAccessibilityFocus flag is
not reflected while searching the node to dispatch the touch event.

History:
The logic to search the accessibility focused node was removed in CL [1].
CL [1] was reverted in [2], but the logic is not correctly restored.

[1] I84bba65ac16e27e9c564b23a0c27d48245eef447
[2] I427b98c71ce8a2ac5b9285b2f34c1864f48c4a32

Bug: 159168795, 182434603
Test: atest TouchExplorerTest
Change-Id: I911547dd506511dd830c8b051af3264523b75df2
parent 6d65ee19
Loading
Loading
Loading
Loading
+14 −17
Original line number Diff line number Diff line
@@ -2049,26 +2049,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            for (int i = childrenCount - 1; i >= 0; i--) {
                final int childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);
                final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);
                View childWithAccessibilityFocus =
                        event.isTargetAccessibilityFocus()
                                ? findChildWithAccessibilityFocus()
                                : null;

                if (!child.canReceivePointerEvents()
                        || !isTransformedTouchPointInView(x, y, child, null)) {

                    // If there is a view that has accessibility focus we want it
                    // to get the event first and if not handled we will perform a
                    // normal dispatch. We may do a double iteration but this is
                    // safer given the timeframe.
                    if (childWithAccessibilityFocus != null) {
                        if (childWithAccessibilityFocus != child) {
                            continue;
                        }
                        childWithAccessibilityFocus = null;
                        i = childrenCount - 1;
                    }
                    event.setTargetAccessibilityFocus(false);
                    continue;
                }
                final PointerIcon pointerIcon =
@@ -2726,8 +2709,22 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                                    childrenCount, i, customOrder);
                            final View child = getAndVerifyPreorderedView(
                                    preorderedList, children, childIndex);

                            // If there is a view that has accessibility focus we want it
                            // to get the event first and if not handled we will perform a
                            // normal dispatch. We may do a double iteration but this is
                            // safer given the timeframe.
                            if (childWithAccessibilityFocus != null) {
                                if (childWithAccessibilityFocus != child) {
                                    continue;
                                }
                                childWithAccessibilityFocus = null;
                                i = childrenCount - 1;
                            }

                            if (!child.canReceivePointerEvents()
                                    || !isTransformedTouchPointInView(x, y, child, null)) {
                                ev.setTargetAccessibilityFocus(false);
                                continue;
                            }