summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Chang <chengjeff@google.com> 2021-09-10 19:06:36 +0800
committer Jeff Chang <chengjeff@google.com> 2021-09-14 11:44:43 +0800
commitbd6bb3f50324c05a67b7ac184de52e44012ebd94 (patch)
tree7d53d732d344437961b5e47d274bc8c5d5761c5c
parent61246e7f0051758289a7423984a0b19a42f9c7c3 (diff)
Return the correct root task when start activity from recents
When starting activity from recents, the system will find the suitable task and move it to the front. With corresponding task display area, TDA#getOrCreateRootTask returns the candidate task directly instead of the existing launch root task. In RootWindowContainer#anyTaskForId, the candidate task is reparent to the root task(same as itself) which resolve from the TDA#getOrCreateRootTask and lead to the watchdog timeout. This CL updates the logic to return the correct root task. Bug: 197293995 Test: atest MultiWindowTests,WMShellUnitTests Change-Id: Ib0b24363dc35d624c358080998c25874d9e7094c
-rw-r--r--services/core/java/com/android/server/wm/TaskDisplayArea.java20
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java4
2 files changed, 13 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index c7ca180bfa14..4a1a922c8a02 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -1095,29 +1095,27 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
return rootTask;
}
} else if (candidateTask != null) {
- final Task rootTask = candidateTask;
final int position = onTop ? POSITION_TOP : POSITION_BOTTOM;
final Task launchRootTask = getLaunchRootTask(windowingMode, activityType, options,
sourceTask, launchFlags);
-
if (launchRootTask != null) {
- if (rootTask.getParent() == null) {
- launchRootTask.addChild(rootTask, position);
- } else if (rootTask.getParent() != launchRootTask) {
- rootTask.reparent(launchRootTask, position);
+ if (candidateTask.getParent() == null) {
+ launchRootTask.addChild(candidateTask, position);
+ } else if (candidateTask.getParent() != launchRootTask) {
+ candidateTask.reparent(launchRootTask, position);
}
- } else if (rootTask.getDisplayArea() != this || !rootTask.isRootTask()) {
- if (rootTask.getParent() == null) {
- addChild(rootTask, position);
+ } else if (candidateTask.getDisplayArea() != this || !candidateTask.isRootTask()) {
+ if (candidateTask.getParent() == null) {
+ addChild(candidateTask, position);
} else {
- rootTask.reparent(this, onTop);
+ candidateTask.reparent(this, onTop);
}
}
// Update windowing mode if necessary, e.g. moving a pinned task to fullscreen.
if (candidateTask.getWindowingMode() != windowingMode) {
candidateTask.setWindowingMode(windowingMode);
}
- return rootTask;
+ return candidateTask.getRootTask();
}
return new Task.Builder(mAtmService)
.setWindowingMode(windowingMode)
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 2882a2391066..cdfa5aa84a95 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -354,6 +354,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
throw new IllegalArgumentException("reparent: can't reparent to null " + this);
}
+ if (newParent == this) {
+ throw new IllegalArgumentException("Can not reparent to itself " + this);
+ }
+
final WindowContainer oldParent = mParent;
if (mParent == newParent) {
throw new IllegalArgumentException("WC=" + this + " already child of " + mParent);