From c33a13a3c53ab5e243b6d4078da4304bb30e2b67 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 8 Feb 2023 21:40:04 +0000 Subject: [PATCH] Fix regression in unfreezing the recent task list - On certain devices, the HWC ScreenDecorOverlay is full size (not just the corners), and the previous logic to determine if a touch is in an app inadvertently finds this window (it's above everything else) and as a result incorrectly assumes that the touch is not going to an app window. Instead, use the alternate existing method for finding the app window under a point which takes into account the touchable region of the window. Bug: 268285353 Test: Quickswitch to previous app, tap on the app and ensure task list is unfrozen (you can't quickswitch back to previous app) Change-Id: I2580dc8e8ed463c6d994f44382138ce2ba5bf890 --- .../com/android/server/wm/DisplayContent.java | 16 ---------------- .../java/com/android/server/wm/RecentTasks.java | 12 ++++++++++-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ca3cfafc4a553..719edee55bce6 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3139,22 +3139,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp }); } - /** - * Returns true if the input point is within an app window. - */ - boolean pointWithinAppWindow(int x, int y) { - final int[] targetWindowType = {-1}; - forAllWindows(w -> { - if (w.isOnScreen() && w.isVisible() && w.getFrame().contains(x, y)) { - targetWindowType[0] = w.mAttrs.type; - return true; - } - return false; - }, true /* traverseTopToBottom */); - return FIRST_APPLICATION_WINDOW <= targetWindowType[0] - && targetWindowType[0] <= LAST_APPLICATION_WINDOW; - } - /** * Find the task whose outside touch area (for resizing) (x, y) falls within. * Returns null if the touch doesn't fall into a resizing area. diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java index 4be1c830f3310..14b845c6f6435 100644 --- a/services/core/java/com/android/server/wm/RecentTasks.java +++ b/services/core/java/com/android/server/wm/RecentTasks.java @@ -33,6 +33,8 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.os.Process.SYSTEM_UID; +import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; +import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_TASKS; import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RECENTS; @@ -215,10 +217,16 @@ class RecentTasks { int y = (int) ev.getY(); mService.mH.post(PooledLambda.obtainRunnable((nonArg) -> { synchronized (mService.mGlobalLock) { - // Unfreeze the task list once we touch down in a task final RootWindowContainer rac = mService.mRootWindowContainer; final DisplayContent dc = rac.getDisplayContent(displayId).mDisplayContent; - if (dc.pointWithinAppWindow(x, y)) { + final WindowState win = dc.getTouchableWinAtPointLocked((float) x, (float) y); + if (win == null) { + return; + } + // Unfreeze the task list once we touch down in a task + final boolean isAppWindowTouch = FIRST_APPLICATION_WINDOW <= win.mAttrs.type + && win.mAttrs.type <= LAST_APPLICATION_WINDOW; + if (isAppWindowTouch) { final Task stack = mService.getTopDisplayFocusedRootTask(); final Task topTask = stack != null ? stack.getTopMostTask() : null; resetFreezeTaskListReordering(topTask);