From 61076ae02c016d215e0f18a9462916964458be16 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Wed, 14 Jul 2021 15:05:55 +0800 Subject: [PATCH] Prevent having empty task added back into TDA Main stage will reparent specfic window mode and activity type tasks under default task display area as its children. When user enter some apps then press back to exit, tasks should become out screen surface, but tasks with no activity reocrd child will pop out again as children of default task display area while user enter recent overview screen. If user active stage split in such status, those tasks except the side stage target will be reparent to main stage. After split active, if user press back to exit app, the target task will bring to back but other children tasks have no activity to show so home screen will display. However, split screen cannot exit because main stage children count still larger than 0 and both stage still visible. For fix such issue, we should prevent empty tasks created and added back into TDA. Fix: 193112081 Test: Follow repro step on b/193112081 and check result Test: atest WmTests Change-Id: I66fcac68f6231a41b7b142307db2e7d89566cad6 --- .../java/com/android/server/wm/ActivityTaskManagerService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 04c01736431da..f3ba56a03aef9 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -5604,7 +5604,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public ActivityTokens getTopActivityForTask(int taskId) { synchronized (mGlobalLock) { - final Task task = mRootWindowContainer.anyTaskForId(taskId); + final Task task = mRootWindowContainer.anyTaskForId(taskId, + MATCH_ATTACHED_TASK_ONLY); if (task == null) { Slog.w(TAG, "getApplicationThreadForTopActivity failed:" + " Requested task not found");