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

Commit 3a689185 authored by tingna_sung's avatar tingna_sung Committed by Steve Kondik
Browse files

Fix racing condition of mTouchExcludeRegion



Copy region from DisplayContent.mTouchExcludeRegion instead of
directly refer to the same object of DisplayContent, and able to
protect it by lock of self class, don't have to lock out mWindowMap
on every tap.

This fix is to avoid racing condition of mTouchExcludeRegion.

Change-Id: I7401968167c2e539b4da2afe71e3020038fbfcbf
Signed-off-by: default avatartingna_sung <tingna_sung@htc.com>
parent 28546577
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ class DisplayContent {
                mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE);
            }
        }
        mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
    }

    void switchUserStacks(int newUserId) {
+16 −9
Original line number Diff line number Diff line
@@ -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);
    }
@@ -77,6 +76,7 @@ public class StackTapPointerEventListener implements PointerEventListener {
                if (mPointerId == motionEvent.getPointerId(index)) {
                    final int x = (int)motionEvent.getX(index);
                    final int y = (int)motionEvent.getY(index);
                    synchronized(this) {
                        if ((motionEvent.getEventTime() - motionEvent.getDownTime())
                                < TAP_TIMEOUT_MSEC
                                && Math.abs(x - mDownX) < mMotionSlop
@@ -85,10 +85,17 @@ public class StackTapPointerEventListener implements PointerEventListener {
                            mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y,
                                    mDisplayContent).sendToTarget();
                        }
                    }
                    mPointerId = -1;
                }
                break;
            }
        }
    }

    void setTouchExcludeRegion(Region newRegion) {
        synchronized (this) {
           mTouchExcludeRegion.set(newRegion);
        }
    }
}