summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Orhan Uysal <uysalorhan@google.com> 2025-01-29 15:30:14 +0000
committer Orhan Uysal <uysalorhan@google.com> 2025-01-30 14:07:29 +0000
commit747ece1e1aecec72689b8eb4dcf9a855fbabf17d (patch)
tree9e1d07b39bc4b3a620138901d3316e3e0a4341ec
parentea66f9f4dc78acc373e31627819de496ed1b36df (diff)
If the rootTaskIdsToRestore is empty...
on user switch, restore the home task to the top for the user. This happens when the home task belongs to the system user and is visible to a secondary user. Test: atest RootWindowContainerTest & manual Bug: 391501236 Flag: com.android.window.flags.enable_top_visible_root_task_per_user_tracking Change-Id: I345dc1b965cc21e5cbb12a6ee4dade79927eb696
-rw-r--r--services/core/java/com/android/server/wm/RootWindowContainer.java9
1 files changed, 3 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index cf464c707ff4..1fe6ad68a313 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -1948,7 +1948,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
final IntArray rootTaskIdsToRestore = mUserVisibleRootTasks.get(userId);
boolean homeInFront = false;
if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
- if (rootTaskIdsToRestore == null) {
+ if (rootTaskIdsToRestore == null || rootTaskIdsToRestore.size() == 0) {
// If there are no root tasks saved, try restore id 0 which should create and launch
// the home task.
handleRootTaskLaunchOnUserSwitch(/* restoreRootTaskId */INVALID_TASK_ID);
@@ -1958,11 +1958,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
handleRootTaskLaunchOnUserSwitch(rootTaskIdsToRestore.get(i));
}
// Check if the top task is type home
- if (rootTaskIdsToRestore.size() > 0) {
- final int topRootTaskId = rootTaskIdsToRestore.get(
- rootTaskIdsToRestore.size() - 1);
- homeInFront = isHomeTask(topRootTaskId);
- }
+ final int topRootTaskId = rootTaskIdsToRestore.get(rootTaskIdsToRestore.size() - 1);
+ homeInFront = isHomeTask(topRootTaskId);
}
} else {
handleRootTaskLaunchOnUserSwitch(restoreRootTaskId);