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

Commit fb734548 authored by Svetoslav's avatar Svetoslav Committed by Android Git Automerger
Browse files

am 9900a843: am c6570bca: am a5fe65ad: am 86636aa3: am e87d1f7a: Merge...

am 9900a843: am c6570bca: am a5fe65ad: am 86636aa3: am e87d1f7a: Merge "TouchExploer computes incorectly the click location." into lmp-dev

* commit '9900a843a7b8ed589ee542825482c554c8283ad0':
  TouchExploer computes incorectly the click location.
parents 57b2d6b4 dbe48d33
Loading
Loading
Loading
Loading
+0 −30
Original line number Original line Diff line number Diff line
@@ -758,29 +758,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                .getAccessibilityFocusClickPointInScreenNotLocked(outPoint);
                .getAccessibilityFocusClickPointInScreenNotLocked(outPoint);
    }
    }


    /**
     * Gets the bounds of the active window.
     *
     * @param outBounds The output to which to write the bounds.
     */
    boolean getActiveWindowBounds(Rect outBounds) {
        // TODO: This should be refactored to work with accessibility
        // focus in multiple windows.
        IBinder token;
        synchronized (mLock) {
            final int windowId = mSecurityPolicy.mActiveWindowId;
            token = mGlobalWindowTokens.get(windowId);
            if (token == null) {
                token = getCurrentUserStateLocked().mWindowTokens.get(windowId);
            }
        }
        mWindowManagerService.getWindowFrame(token, outBounds);
        if (!outBounds.isEmpty()) {
            return true;
        }
        return false;
    }

    int getActiveWindowId() {
    int getActiveWindowId() {
        return mSecurityPolicy.mActiveWindowId;
        return mSecurityPolicy.mActiveWindowId;
    }
    }
@@ -3196,13 +3173,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
                    point.y = (int) (point.y * (1 / spec.scale));
                    point.y = (int) (point.y * (1 / spec.scale));
                }
                }


                // Make sure the point is within the window.
                Rect windowBounds = mTempRect;
                getActiveWindowBounds(windowBounds);
                if (!windowBounds.contains(point.x, point.y)) {
                    return false;
                }

                // Make sure the point is within the screen.
                // Make sure the point is within the screen.
                Point screenSize = mTempPoint;
                Point screenSize = mTempPoint;
                mDefaultDisplay.getRealSize(screenSize);
                mDefaultDisplay.getRealSize(screenSize);
+32 −78
Original line number Original line Diff line number Diff line
@@ -205,9 +205,6 @@ class TouchExplorer implements EventStreamTransformation {
    // The long pressing pointer Y if coordinate remapping is needed.
    // The long pressing pointer Y if coordinate remapping is needed.
    private int mLongPressingPointerDeltaY;
    private int mLongPressingPointerDeltaY;


    // The id of the last touch explored window.
    private int mLastTouchedWindowId;

    // Whether touch exploration is in progress.
    // Whether touch exploration is in progress.
    private boolean mTouchExplorationInProgress;
    private boolean mTouchExplorationInProgress;


@@ -368,11 +365,6 @@ class TouchExplorer implements EventStreamTransformation {
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick.recycle();
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick.recycle();
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick = null;
                    mInjectedPointerTracker.mLastInjectedHoverEventForClick = null;
                }
                }
                mLastTouchedWindowId = -1;
            } break;
            case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
            case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: {
                mLastTouchedWindowId = event.getWindowId();
            } break;
            } break;
        }
        }
        if (mNext != null) {
        if (mNext != null) {
@@ -1151,43 +1143,13 @@ class TouchExplorer implements EventStreamTransformation {
                mSendTouchInteractionEndDelayed.forceSendAndRemove();
                mSendTouchInteractionEndDelayed.forceSendAndRemove();
            }
            }


            int clickLocationX;
            int clickLocationY;

            final int pointerId = secondTapUp.getPointerId(secondTapUp.getActionIndex());
            final int pointerId = secondTapUp.getPointerId(secondTapUp.getActionIndex());
            final int pointerIndex = secondTapUp.findPointerIndex(pointerId);
            final int pointerIndex = secondTapUp.findPointerIndex(pointerId);


            MotionEvent lastExploreEvent =
            Point clickLocation = mTempPoint;
                mInjectedPointerTracker.getLastInjectedHoverEventForClick();
            if (!computeClickLocation(clickLocation)) {
            if (lastExploreEvent == null) {
                // No last touch explored event but there is accessibility focus in
                // the active window. We click in the focus bounds.
                Point point = mTempPoint;
                if (mAms.getAccessibilityFocusClickPointInScreen(point)) {
                    clickLocationX = point.x;
                    clickLocationY = point.y;
                } else {
                    // Out of luck - do nothing.
                return;
                return;
            }
            }
            } else {
                // If the click is within the active window but not within the
                // accessibility focus bounds we click in the focus bounds.
                final int lastExplorePointerIndex = lastExploreEvent.getActionIndex();
                clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
                clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
                Rect activeWindowBounds = mTempRect;
                if (mLastTouchedWindowId == mAms.getActiveWindowId()) {
                    mAms.getActiveWindowBounds(activeWindowBounds);
                    if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
                        Point point = mTempPoint;
                        if (mAms.getAccessibilityFocusClickPointInScreen(point)) {
                            clickLocationX = point.x;
                            clickLocationY = point.y;
                        }
                    }
                }
            }


            // Do the click.
            // Do the click.
            PointerProperties[] properties = new PointerProperties[1];
            PointerProperties[] properties = new PointerProperties[1];
@@ -1195,8 +1157,8 @@ class TouchExplorer implements EventStreamTransformation {
            secondTapUp.getPointerProperties(pointerIndex, properties[0]);
            secondTapUp.getPointerProperties(pointerIndex, properties[0]);
            PointerCoords[] coords = new PointerCoords[1];
            PointerCoords[] coords = new PointerCoords[1];
            coords[0] = new PointerCoords();
            coords[0] = new PointerCoords();
            coords[0].x = clickLocationX;
            coords[0].x = clickLocation.x;
            coords[0].y = clickLocationY;
            coords[0].y = clickLocation.y;
            MotionEvent event = MotionEvent.obtain(secondTapUp.getDownTime(),
            MotionEvent event = MotionEvent.obtain(secondTapUp.getDownTime(),
                    secondTapUp.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties,
                    secondTapUp.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties,
                    coords, 0, 0, 1.0f, 1.0f, secondTapUp.getDeviceId(), 0,
                    coords, 0, 0, 1.0f, 1.0f, secondTapUp.getDeviceId(), 0,
@@ -1322,47 +1284,18 @@ class TouchExplorer implements EventStreamTransformation {
                return;
                return;
            }
            }


            int clickLocationX;
            int clickLocationY;

            final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
            final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
            final int pointerIndex = mEvent.findPointerIndex(pointerId);
            final int pointerIndex = mEvent.findPointerIndex(pointerId);


            MotionEvent lastExploreEvent =

                mInjectedPointerTracker.getLastInjectedHoverEventForClick();
            Point clickLocation = mTempPoint;
            if (lastExploreEvent == null) {
            if (!computeClickLocation(clickLocation)) {
                // No last touch explored event but there is accessibility focus in
                // the active window. We click in the focus bounds.
                Point point = mTempPoint;
                if (mAms.getAccessibilityFocusClickPointInScreen(point)) {
                    clickLocationX = point.x;
                    clickLocationY = point.y;
                } else {
                    // Out of luck - do nothing.
                return;
                return;
            }
            }
            } else {
                // If the click is within the active window but not within the
                // accessibility focus bounds we click in the focus bounds.
                final int lastExplorePointerIndex = lastExploreEvent.getActionIndex();
                clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
                clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
                Rect activeWindowBounds = mTempRect;
                if (mLastTouchedWindowId == mAms.getActiveWindowId()) {
                    mAms.getActiveWindowBounds(activeWindowBounds);
                    if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
                        Point point = mTempPoint;
                        if (mAms.getAccessibilityFocusClickPointInScreen(point)) {
                            clickLocationX = point.x;
                            clickLocationY = point.y;
                        }
                    }
                }
            }


            mLongPressingPointerId = pointerId;
            mLongPressingPointerId = pointerId;
            mLongPressingPointerDeltaX = (int) mEvent.getX(pointerIndex) - clickLocationX;
            mLongPressingPointerDeltaX = (int) mEvent.getX(pointerIndex) - clickLocation.x;
            mLongPressingPointerDeltaY = (int) mEvent.getY(pointerIndex) - clickLocationY;
            mLongPressingPointerDeltaY = (int) mEvent.getY(pointerIndex) - clickLocation.y;


            sendHoverExitAndTouchExplorationGestureEndIfNeeded(mPolicyFlags);
            sendHoverExitAndTouchExplorationGestureEndIfNeeded(mPolicyFlags);


@@ -1378,6 +1311,27 @@ class TouchExplorer implements EventStreamTransformation {
        }
        }
    }
    }


    private boolean computeClickLocation(Point outPoint) {
        // Try to click on the accessiblity focused view and if that
        // fails try the last touch explored location, if such.
        Point point = mTempPoint;
        if (mAms.getAccessibilityFocusClickPointInScreen(point)) {
            outPoint.x = point.x;
            outPoint.y = point.y;
            return true;
        } else {
            MotionEvent lastExploreEvent =
                    mInjectedPointerTracker.getLastInjectedHoverEventForClick();
            if (lastExploreEvent != null) {
                final int lastExplorePointerIndex = lastExploreEvent.getActionIndex();
                outPoint.x = (int) lastExploreEvent.getX(lastExplorePointerIndex);
                outPoint.y = (int) lastExploreEvent.getY(lastExplorePointerIndex);
                return true;
            }
        }
        return false;
    }

    /**
    /**
     * Class for delayed sending of hover enter and move events.
     * Class for delayed sending of hover enter and move events.
     */
     */