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

Commit 5d043ce8 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Active window not updated window not updated properly.

1. Accessibility allows querying only of the active window.
   The active window is the one that has input focus or the
   one the user is touching. Hence, if the user is touching
   a window that does not have input focus this window is
   the active one and as soon as the user stops touching
   it the active window becomes the one that has input
   focus. Currently the active window is not updated properly
   when the user lifts his finger. This leads to a scenario
   of traversal actions sent to the wrong window and the user
   being stuck.

   The reason is that the last touch explored event that is
   used to determine where to click is cleared when accessibility
   focus moves but this event is also used to determine when to
   send the hover exit and touch exploration gesture end events.
   The problem is that the last hover event is cleared before
   it is used for sending the right exit events, thus the event
   stream is inconsistent and the accessibility manager service
   relies on this stream to update the active window. Now we
   are keeping separate copies of the last touch event - one
   for clicking and one for determining the which events to
   inject to ensure consistent stream.

bug:66660415

Change-Id: Ie9961e562a42ef8a9463afacfff2246adcb66303
parent 95068e5d
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -312,9 +312,9 @@ public class TouchExplorer {
        switch (eventType) {
            case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
            case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
                if (mInjectedPointerTracker.mLastInjectedHoverEvent != null) {
                    mInjectedPointerTracker.mLastInjectedHoverEvent.recycle();
                    mInjectedPointerTracker.mLastInjectedHoverEvent = null;
                if (mInjectedPointerTracker.mLastInjectedHoverEventForClick != null) {
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick.recycle();
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick = null;
                }
                mLastTouchedWindowId = -1;
            } break;
@@ -1077,7 +1077,8 @@ public class TouchExplorer {
            final int pointerId = secondTapUp.getPointerId(secondTapUp.getActionIndex());
            final int pointerIndex = secondTapUp.findPointerIndex(pointerId);

            MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
            MotionEvent lastExploreEvent =
                mInjectedPointerTracker.getLastInjectedHoverEventForClick();
            if (lastExploreEvent == null) {
                // No last touch explored event but there is accessibility focus in
                // the active window. We click in the middle of the focus bounds.
@@ -1328,7 +1329,8 @@ public class TouchExplorer {
            final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
            final int pointerIndex = mEvent.findPointerIndex(pointerId);

            MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
            MotionEvent lastExploreEvent =
                mInjectedPointerTracker.getLastInjectedHoverEventForClick();
            if (lastExploreEvent == null) {
                // No last touch explored event but there is accessibility focus in
                // the active window. We click in the middle of the focus bounds.
@@ -1482,6 +1484,9 @@ public class TouchExplorer {
        // The last injected hover event.
        private MotionEvent mLastInjectedHoverEvent;

        // The last injected hover event used for performing clicks.
        private MotionEvent mLastInjectedHoverEventForClick;

        /**
         * Processes an injected {@link MotionEvent} event.
         *
@@ -1513,6 +1518,10 @@ public class TouchExplorer {
                        mLastInjectedHoverEvent.recycle();
                    }
                    mLastInjectedHoverEvent = MotionEvent.obtain(event);
                    if (mLastInjectedHoverEventForClick != null) {
                        mLastInjectedHoverEventForClick.recycle();
                    }
                    mLastInjectedHoverEventForClick = MotionEvent.obtain(event);
                } break;
            }
            if (DEBUG) {
@@ -1566,6 +1575,13 @@ public class TouchExplorer {
            return mLastInjectedHoverEvent;
        }

        /**
         * @return The the last injected hover event.
         */
        public MotionEvent getLastInjectedHoverEventForClick() {
            return mLastInjectedHoverEventForClick;
        }

        @Override
        public String toString() {
            StringBuilder builder = new StringBuilder();