diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 30589b1c27a01..c6c26663adcae 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -241,6 +241,7 @@ class DisplayContent { mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); } } + mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion); } void switchUserStacks(int newUserId) { diff --git a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java index 80eb453cdfeab..1a85993b69af6 100644 --- a/services/core/java/com/android/server/wm/StackTapPointerEventListener.java +++ b/services/core/java/com/android/server/wm/StackTapPointerEventListener.java @@ -31,7 +31,7 @@ public class StackTapPointerEventListener implements PointerEventListener { private float mDownX; private float mDownY; private int mPointerId; - final private Region mTouchExcludeRegion; + final private Region mTouchExcludeRegion = new Region(); private final WindowManagerService mService; private final DisplayContent mDisplayContent; @@ -39,7 +39,6 @@ public class StackTapPointerEventListener implements PointerEventListener { DisplayContent displayContent) { mService = service; mDisplayContent = displayContent; - mTouchExcludeRegion = displayContent.mTouchExcludeRegion; DisplayInfo info = displayContent.getDisplayInfo(); mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES); } @@ -72,13 +71,15 @@ public class StackTapPointerEventListener implements PointerEventListener { if (mPointerId == motionEvent.getPointerId(index)) { final int x = (int)motionEvent.getX(index); final int y = (int)motionEvent.getY(index); - if ((motionEvent.getEventTime() - motionEvent.getDownTime()) - < TAP_TIMEOUT_MSEC - && Math.abs(x - mDownX) < mMotionSlop - && Math.abs(y - mDownY) < mMotionSlop - && !mTouchExcludeRegion.contains(x, y)) { - mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, - mDisplayContent).sendToTarget(); + synchronized(this) { + if ((motionEvent.getEventTime() - motionEvent.getDownTime()) + < TAP_TIMEOUT_MSEC + && Math.abs(x - mDownX) < mMotionSlop + && Math.abs(y - mDownY) < mMotionSlop + && !mTouchExcludeRegion.contains(x, y)) { + mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, + mDisplayContent).sendToTarget(); + } } mPointerId = -1; } @@ -86,4 +87,10 @@ public class StackTapPointerEventListener implements PointerEventListener { } } } + + void setTouchExcludeRegion(Region newRegion) { + synchronized (this) { + mTouchExcludeRegion.set(newRegion); + } + } }