From 004e857ce5cb60b3bfab8756bdf5df1779f11924 Mon Sep 17 00:00:00 2001 From: Yao Qijing Date: Wed, 5 Apr 2023 08:19:27 +0000 Subject: [PATCH] Make sure topActivity always retrieves focus when move task to back In a freeform environment, multiple windows can be visible and therefore RESUMED at the same time. It means that when moving a task to back, the topActivity that is going to be focused may be RESUMED. However, there's a check in `moveTaskToBackInner()` to only trigger `resumeFocusedTasksTopActivities()` when topActivity is not RESUMED, which results in DisplayContent#mFocusedApp not getting updated correctly. This CL fixes the bug by triggering DisplayContent#setFocusedApp() even topActivity is RESUMED. Bug: 276136272 Test: Manual testing to make sure the top activity can get focused Change-Id: I51371394830277777ff7983fd1d1c14d63fa505a --- services/core/java/com/android/server/wm/Task.java | 1 + 1 file changed, 1 insertion(+) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 3680e6dff9fef..6cf0e527b4e7a 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5655,6 +5655,7 @@ class Task extends TaskFragment { // Usually resuming a top activity triggers the next app transition, but nothing's got // resumed in this case, so we need to execute it explicitly. mDisplayContent.executeAppTransition(); + mDisplayContent.setFocusedApp(topActivity); } else { mRootWindowContainer.resumeFocusedTasksTopActivities(); }