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

Commit d3c93387 authored by Craig Mautner's avatar Craig Mautner
Browse files

Fix deadlock.

Grabbing StackTapDetector before grabbing mWindowMap doesn't play well
with grabbing mWindowMap and then StackTapDetector.

Change-Id: I40daa4c940930b1ebbb587edc1958e84321d6d7f
parent 9e0c5455
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.MotionEvent;

import com.android.server.wm.WindowManagerService.H;

public class StackTapDetector extends InputEventReceiver {
    private static final int TAP_TIMEOUT_MSEC = 300;
    private static final float TAP_MOTION_SLOP_INCHES = 0.125f;
@@ -83,7 +85,8 @@ public class StackTapDetector extends InputEventReceiver {
                                < TAP_TIMEOUT_MSEC
                                && (x - mDownX) < mMotionSlop && (y - mDownY) < mMotionSlop
                                && !mStackBounds.contains(x, y)) {
                            mService.tapOutsideStackBounds(mDisplayContent, x, y);
                            mService.mH.obtainMessage(H.TAP_OUTSIDE_STACK, x, y, mDisplayContent)
                                    .sendToTarget();
                        }
                    }
                    mPointerId = -1;
+13 −12
Original line number Diff line number Diff line
@@ -3705,18 +3705,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void tapOutsideStackBounds(DisplayContent displayContent, int x, int y) {
        synchronized (mWindowMap) {
            int stackId = displayContent.stackIdFromPoint(x, y);
            if (stackId >= 0) {
                try {
                    mActivityManager.setFocusedStack(stackId);
                } catch (RemoteException e) {
                }
            }
        }
    }

    @Override
    public void setFocusedApp(IBinder token, boolean moveFocusNow) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
@@ -6932,6 +6920,7 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int DO_DISPLAY_CHANGED = 29;

        public static final int CLIENT_FREEZE_TIMEOUT = 30;
        public static final int TAP_OUTSIDE_STACK = 31;

        @Override
        public void handleMessage(Message msg) {
@@ -7351,6 +7340,18 @@ public class WindowManagerService extends IWindowManager.Stub
                        handleDisplayChangedLocked(msg.arg1);
                    }
                    break;

                case TAP_OUTSIDE_STACK:
                    synchronized (mWindowMap) {
                        int stackId =
                                ((DisplayContent)msg.obj).stackIdFromPoint(msg.arg1, msg.arg2);
                        if (stackId >= 0) {
                            try {
                                mActivityManager.setFocusedStack(stackId);
                            } catch (RemoteException e) {
                            }
                        }
                    }
            }
            if (DEBUG_WINDOW_TRACE) {
                Slog.v(TAG, "handleMessage: exit");