summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/Task.java15
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskTests.java43
2 files changed, 55 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index f9772f4c7c5c..ab1e96952c53 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -1132,6 +1132,9 @@ class Task extends TaskFragment {
final Task oldParentTask = oldParent.asTask();
if (oldParentTask != null) {
forAllActivities(oldParentTask::cleanUpActivityReferences);
+
+ // Update the task description of the previous parent as well
+ oldParentTask.updateTaskDescription();
}
if (newParent == null || !newParent.inPinnedWindowingMode()) {
@@ -1163,6 +1166,9 @@ class Task extends TaskFragment {
} catch (RemoteException e) {
}
}
+
+ // Update the ancestor tasks' task description after reparenting
+ updateTaskDescription();
}
// First time we are adding the task to the system.
@@ -3353,7 +3359,7 @@ class Task extends TaskFragment {
//TODO (AM refactor): Just use local once updateEffectiveIntent is run during all child
// order changes.
- final Task topTask = top != null ? top.getTask() : this;
+ final Task topTask = top != null && top.getTask() != null ? top.getTask() : this;
info.resizeMode = topTask.mResizeMode;
info.topActivityType = topTask.getActivityType();
info.displayCutoutInsets = topTask.getDisplayCutoutInsets();
@@ -6138,9 +6144,8 @@ class Task extends TaskFragment {
@Override
void onChildPositionChanged(WindowContainer child) {
- dispatchTaskInfoChangedIfNeeded(false /* force */);
-
if (!mChildren.contains(child)) {
+ dispatchTaskInfoChangedIfNeeded(false /* force */);
return;
}
if (child.asTask() != null) {
@@ -6152,6 +6157,10 @@ class Task extends TaskFragment {
// Send for TaskFragmentParentInfo#hasDirectActivity change.
sendTaskFragmentParentInfoChangedIfNeeded();
}
+
+ // Update the ancestor tasks' task description after any children have reparented
+ updateTaskDescription();
+ dispatchTaskInfoChangedIfNeeded(false /* force */);
}
void reparent(TaskDisplayArea newParent, boolean onTop) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index a1ac02a21e35..a232ff0dfcb6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -46,6 +46,7 @@ import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.Task.FLAG_FORCE_HIDDEN_FOR_TASK_ORG;
import static com.android.server.wm.TaskFragment.EMBEDDED_DIM_AREA_PARENT_TASK;
import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT;
+import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.google.common.truth.Truth.assertThat;
@@ -78,6 +79,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
+import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
@@ -2031,6 +2033,47 @@ public class TaskTests extends WindowTestsBase {
task.getTaskInfo().appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode);
}
+ @Test
+ public void testUpdateTaskDescriptionOnReparent() {
+ final Task rootTask1 = createTask(mDisplayContent);
+ final Task rootTask2 = createTask(mDisplayContent);
+ final Task childTask = createTaskInRootTask(rootTask1, 0 /* userId */);
+ final ActivityRecord activity = createActivityRecord(mDisplayContent, childTask);
+ final String testLabel = "test_task_description_label";
+ final ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(testLabel);
+ activity.setTaskDescription(td);
+
+ // Ensure the td is set for the original root task
+ assertEquals(testLabel, rootTask1.getTaskDescription().getLabel());
+ assertNull(rootTask2.getTaskDescription().getLabel());
+
+ childTask.reparent(rootTask2, POSITION_TOP, false /* moveParents */, "reparent");
+
+ // Ensure the td is set for the new root task
+ assertEquals(testLabel, rootTask2.getTaskDescription().getLabel());
+ }
+
+ @Test
+ public void testUpdateTaskDescriptionOnReorder() {
+ final Task task = createTask(mDisplayContent);
+ final ActivityRecord activity1 = createActivityRecord(mDisplayContent, task);
+ final ActivityRecord activity2 = createActivityRecord(mDisplayContent, task);
+ final ActivityManager.TaskDescription td1 = new ActivityManager.TaskDescription();
+ td1.setBackgroundColor(Color.RED);
+ activity1.setTaskDescription(td1);
+ final ActivityManager.TaskDescription td2 = new ActivityManager.TaskDescription();
+ td2.setBackgroundColor(Color.BLUE);
+ activity2.setTaskDescription(td2);
+
+ // Ensure the td is set for the original root task
+ assertEquals(Color.BLUE, task.getTaskDescription().getBackgroundColor());
+
+ task.positionChildAt(POSITION_TOP, activity1, false /* includeParents */);
+
+ // Ensure the td is set for the original root task
+ assertEquals(Color.RED, task.getTaskDescription().getBackgroundColor());
+ }
+
private Task getTestTask() {
return new TaskBuilder(mSupervisor).setCreateActivity(true).build();
}