Put ResovlerActivity and noDisplay activities in the source task

Launch the ResolverActivity in the source task, so that the chooser
stays in the bounds of the task, instead of always at the bottom of
the screen.

Also put the nodisplay activities in the source task, it could launch
other activities (eg. ResolverActivity), we need the original task.

Bug: 24136124
Change-Id: I8b22d7f6cba4dc9e57cb19d357091013a74826bb
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 6b5f205..dc97954 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1262,7 +1262,7 @@
                         r.userId, System.identityHashCode(r),
                         task.taskId, r.shortComponentName);
             }
-            if (r.isHomeActivity() && r.isNotResolverActivity()) {
+            if (r.isHomeActivity()) {
                 // Home process is the root process of the task.
                 mService.mHomeProcess = task.mActivities.get(0).app;
             }
@@ -2024,6 +2024,14 @@
             reuseTask = inTask;
         } else {
             inTask = null;
+            // Launch ResolverActivity in the source task, so that it stays in the task
+            // bounds when in freeform workspace.
+            // Also put noDisplay activities in the source task. These by itself can
+            // be placed in any task/stack, however it could launch other activities
+            // like ResolverActivity, and we want those to stay in the original task.
+            if (r.isResolverActivity() || r.noDisplay) {
+                addingToTask = true;
+            }
         }
 
         if (inTask == null) {