From 0756665a903cf3da32bc1c149bbbd3462448403f Mon Sep 17 00:00:00 2001 From: Winson Chung <winsonc@google.com> Date: Tue, 28 May 2024 23:22:17 +0000 Subject: [PATCH] Only reset the frozen recents list if touching outside of the mandatory system gesture region - Currently, any touch after a quickswitch within an app window will be construed as a reset of the frozen task list, however we allow users to quickswitch multiple times whenever touching within the mandatory system gesture region, so we should also ensure that touches within that region are also ignored. - Also add protologs for when we set/reset the frozen list Bug: 320408763 Test: Quickswitch, but touch above the nav handle and within the system gesture region, verify this does not trigger resetting Change-Id: Ie8dd880eb2b45812d5b72ec1ae1c23e28ba02250 Merged-In: Ie8dd880eb2b45812d5b72ec1ae1c23e28ba02250 Signed-off-by: Winson Chung <winsonc@google.com> --- data/etc/core.protolog.pb | Bin 54073 -> 54185 bytes data/etc/services.core.protolog.json | 18 +++++++++++++ .../com/android/server/wm/RecentTasks.java | 24 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/data/etc/core.protolog.pb b/data/etc/core.protolog.pb index 0415e44af72a6e2197c9f6fd54cabd6392d795df..02c8099f04705f7484dfff5628737cb5c92b82c0 100644 GIT binary patch delta 234 zcmdnFjCtj9<_*1x^@*HZcFp0N<ZWIG1qG!Rr<Rmt=A|p773Ei@<|!1VCa30=6f2Y@ z7H2EuWEPhIMG}ki^K26f3KUB6OOrDc$}{t9Rf`oWY*kYfDnUeM9?%fCqQu-(ptuCH z0za2NXS~hsZ)#I6wF)T&qgfD!ZUb0{1LuB|uRMv9g)M{(iFZ^<W^QVJX$i=L%{_@6 LQJa75wigEg{c==H delta 121 zcmZ3voO$Om<_*1xo0F5+qf%2iGYn38yIpeU5eh9SO3W)xODzh?FHO#HPc1GfElO2L zOU%qkO;JcnO-?K=PE|-ON-tJ`DRe8!&kf1XPR&!uFM<n(<U@oqixu)pb8;kD734Q( I?r{(Y06xnt)Bpeg diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 0231d3abd19e..a5bc2ea4b493 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -2065,6 +2065,24 @@ "group": "WM_DEBUG_WINDOW_TRANSITIONS", "at": "com\/android\/server\/wm\/PhysicalDisplaySwitchTransitionLauncher.java" }, + "-1640401313436844534": { + "message": "Resetting frozen recents task list reason=app touch win=%s x=%d y=%d insetFrame=%s", + "level": "INFO", + "group": "WM_DEBUG_TASKS", + "at": "com\/android\/server\/wm\/RecentTasks.java" + }, + "-8803811426486764449": { + "message": "Setting frozen recents task list", + "level": "INFO", + "group": "WM_DEBUG_TASKS", + "at": "com\/android\/server\/wm\/RecentTasks.java" + }, + "4040735335719974079": { + "message": "Resetting frozen recents task list reason=timeout", + "level": "INFO", + "group": "WM_DEBUG_TASKS", + "at": "com\/android\/server\/wm\/RecentTasks.java" + }, "3308140128142966415": { "message": "remove RecentTask %s when finishing user %d", "level": "INFO", diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java index f3f4def924b5..5218c772be60 100644 --- a/services/core/java/com/android/server/wm/RecentTasks.java +++ b/services/core/java/com/android/server/wm/RecentTasks.java @@ -33,6 +33,7 @@ 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.MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE; +import static android.view.WindowInsets.Type.mandatorySystemGestures; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; @@ -60,6 +61,8 @@ import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.res.Resources; import android.graphics.Bitmap; +import android.graphics.Insets; +import android.graphics.Rect; import android.os.Environment; import android.os.IBinder; import android.os.RemoteException; @@ -72,7 +75,9 @@ import android.util.IntArray; import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; +import android.view.InsetsState; import android.view.MotionEvent; +import android.view.WindowInsets; import android.view.WindowManagerPolicyConstants.PointerEventListener; import com.android.internal.annotations.VisibleForTesting; @@ -209,6 +214,7 @@ class RecentTasks { private final HashMap<ComponentName, ActivityInfo> mTmpAvailActCache = new HashMap<>(); private final HashMap<String, ApplicationInfo> mTmpAvailAppCache = new HashMap<>(); private final SparseBooleanArray mTmpQuietProfileUserIds = new SparseBooleanArray(); + private final Rect mTmpRect = new Rect(); // TODO(b/127498985): This is currently a rough heuristic for interaction inside an app private final PointerEventListener mListener = new PointerEventListener() { @@ -230,12 +236,27 @@ class RecentTasks { if (win == null) { return; } + + // Verify the touch is within the mandatory system gesture inset bounds of the + // window, use the raw insets state to ignore window z-order + final InsetsState insetsState = dc.getInsetsStateController() + .getRawInsetsState(); + mTmpRect.set(win.getFrame()); + mTmpRect.inset(insetsState.calculateInsets(win.getFrame(), + mandatorySystemGestures(), false /* ignoreVisibility */)); + if (!mTmpRect.contains(x, y)) { + 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; + ProtoLog.i(WM_DEBUG_TASKS, "Resetting frozen recents task list" + + " reason=app touch win=%s x=%d y=%d insetFrame=%s", win, x, y, + mTmpRect); resetFreezeTaskListReordering(topTask); } } @@ -302,6 +323,8 @@ class RecentTasks { mFreezeTaskListReordering = true; } + ProtoLog.i(WM_DEBUG_TASKS, "Setting frozen recents task list"); + // Always update the reordering time when this is called to ensure that the timeout // is reset mService.mH.removeCallbacks(mResetFreezeTaskListOnTimeoutRunnable); @@ -345,6 +368,7 @@ class RecentTasks { final Task focusedStack = mService.getTopDisplayFocusedRootTask(); final Task topTask = focusedStack != null ? focusedStack.getTopMostTask() : null; final Task reorderToEndTask = topTask != null && topTask.hasChild() ? topTask : null; + ProtoLog.i(WM_DEBUG_TASKS, "Resetting frozen recents task list reason=timeout"); resetFreezeTaskListReordering(reorderToEndTask); } } -- GitLab