Merge "Fix racing condition of mTouchExcludeRegion"

automerge: 6007d9a

* commit '6007d9aa5f53685bba47ee63d6b4702b9f802744':
  Fix racing condition of mTouchExcludeRegion
This commit is contained in:
Craig Mautner
2014-12-19 06:44:30 +00:00
committed by android-build-merger
2 changed files with 17 additions and 9 deletions

View File

@@ -241,6 +241,7 @@ class DisplayContent {
mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE);
} }
} }
mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
} }
void switchUserStacks(int newUserId) { void switchUserStacks(int newUserId) {

View File

@@ -31,7 +31,7 @@ public class StackTapPointerEventListener implements PointerEventListener {
private float mDownX; private float mDownX;
private float mDownY; private float mDownY;
private int mPointerId; private int mPointerId;
final private Region mTouchExcludeRegion; final private Region mTouchExcludeRegion = new Region();
private final WindowManagerService mService; private final WindowManagerService mService;
private final DisplayContent mDisplayContent; private final DisplayContent mDisplayContent;
@@ -39,7 +39,6 @@ public class StackTapPointerEventListener implements PointerEventListener {
DisplayContent displayContent) { DisplayContent displayContent) {
mService = service; mService = service;
mDisplayContent = displayContent; mDisplayContent = displayContent;
mTouchExcludeRegion = displayContent.mTouchExcludeRegion;
DisplayInfo info = displayContent.getDisplayInfo(); DisplayInfo info = displayContent.getDisplayInfo();
mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES); mMotionSlop = (int)(info.logicalDensityDpi * TAP_MOTION_SLOP_INCHES);
} }
@@ -72,13 +71,15 @@ public class StackTapPointerEventListener implements PointerEventListener {
if (mPointerId == motionEvent.getPointerId(index)) { if (mPointerId == motionEvent.getPointerId(index)) {
final int x = (int)motionEvent.getX(index); final int x = (int)motionEvent.getX(index);
final int y = (int)motionEvent.getY(index); final int y = (int)motionEvent.getY(index);
if ((motionEvent.getEventTime() - motionEvent.getDownTime()) synchronized(this) {
< TAP_TIMEOUT_MSEC if ((motionEvent.getEventTime() - motionEvent.getDownTime())
&& Math.abs(x - mDownX) < mMotionSlop < TAP_TIMEOUT_MSEC
&& Math.abs(y - mDownY) < mMotionSlop && Math.abs(x - mDownX) < mMotionSlop
&& !mTouchExcludeRegion.contains(x, y)) { && Math.abs(y - mDownY) < mMotionSlop
mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, && !mTouchExcludeRegion.contains(x, y)) {
mDisplayContent).sendToTarget(); mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y,
mDisplayContent).sendToTarget();
}
} }
mPointerId = -1; mPointerId = -1;
} }
@@ -86,4 +87,10 @@ public class StackTapPointerEventListener implements PointerEventListener {
} }
} }
} }
void setTouchExcludeRegion(Region newRegion) {
synchronized (this) {
mTouchExcludeRegion.set(newRegion);
}
}
} }