From 6a009c6c1bcd4820d7dda09d026bee77a333a37b Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 21 Sep 2022 23:01:09 +0800 Subject: [PATCH] Allow to send user leave hint for task switch by touch A corner case if the window on a launching activity is not shown in-time, a touch event may send to the current top window which belongs to previous app. That causes task reorder and pauses the launching activity. Just to fit the description in document "activity is about to go into the background as the result of user choice". Bug: 245423495 Test: Launch a dialog style activity from launcher with sleeping(500) in onCreate. And keep clicking launcher at the same time. The activity should receive onUserLeaveHint. Change-Id: Ia7257fe2383bf2a1f55c26170ca047a4604ebd60 --- .../core/java/com/android/server/wm/WindowManagerService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 66c962d855b7e..391698ebd425f 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -8499,7 +8499,10 @@ public class WindowManagerService extends IWindowManager.Stub if (mFocusedInputTarget != t && mFocusedInputTarget != null) { mFocusedInputTarget.handleTapOutsideFocusOutsideSelf(); } + // Trigger Activity#onUserLeaveHint() if the order change of task pauses any activities. + mAtmService.mTaskSupervisor.mUserLeaving = true; t.handleTapOutsideFocusInsideSelf(); + mAtmService.mTaskSupervisor.mUserLeaving = false; } @VisibleForTesting