Add source activity to values passed to LaunchingBoundsPositioner.

Bug: 64144308
Test: bit FrameworksServicesTests:com.android.server.am.LaunchingBoundsControllerTests
Test: bit FrameworksServicesTests:com.android.server.am.LaunchingTaskPositionerTests
Test: bit FrameworksServicesTests:com.android.server.am.LaunchingActivityPositionerTests
Change-Id: I8a9d2a41e923e972c11db0b79854ff4a6a742d1c
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index f6905c5..1c80282 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -26,9 +26,6 @@
 import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
 import static android.app.ActivityManager.START_SUCCESS;
 import static android.app.ActivityManager.START_TASK_TO_FRONT;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
 import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
 import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
@@ -1249,7 +1246,7 @@
         mLaunchBounds.setEmpty();
 
         mSupervisor.getLaunchingBoundsController().calculateBounds(inTask, null /*layout*/, r,
-                options, mLaunchBounds);
+                sourceRecord, options, mLaunchBounds);
 
         mLaunchMode = r.launchMode;
 
@@ -2170,15 +2167,6 @@
         }
     }
 
-    private Rect getOverrideBounds(ActivityRecord r, ActivityOptions options, TaskRecord inTask) {
-        Rect newBounds = null;
-        if (mSupervisor.canUseActivityOptionsLaunchBounds(options)
-                && (r.isResizeable() || (inTask != null && inTask.isResizeable()))) {
-            newBounds = TaskRecord.validateBounds(options.getLaunchBounds());
-        }
-        return newBounds;
-    }
-
     private boolean isLaunchModeOneOf(int mode1, int mode2) {
         return mode1 == mLaunchMode || mode2 == mLaunchMode;
     }
diff --git a/services/core/java/com/android/server/am/LaunchingActivityPositioner.java b/services/core/java/com/android/server/am/LaunchingActivityPositioner.java
index 5815e98..d5f9cf3 100644
--- a/services/core/java/com/android/server/am/LaunchingActivityPositioner.java
+++ b/services/core/java/com/android/server/am/LaunchingActivityPositioner.java
@@ -34,7 +34,8 @@
 
     @Override
     public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout,
-            ActivityRecord activity, ActivityOptions options,  Rect current, Rect result) {
+            ActivityRecord activity, ActivityRecord source,
+            ActivityOptions options, Rect current, Rect result) {
         // We only care about figuring out bounds for activities.
         if (activity == null) {
             return RESULT_SKIP;
diff --git a/services/core/java/com/android/server/am/LaunchingBoundsController.java b/services/core/java/com/android/server/am/LaunchingBoundsController.java
index 8345ba6..c762f7f 100644
--- a/services/core/java/com/android/server/am/LaunchingBoundsController.java
+++ b/services/core/java/com/android/server/am/LaunchingBoundsController.java
@@ -62,12 +62,13 @@
      * @param task      The {@link TaskRecord} currently being positioned.
      * @param layout    The specified {@link WindowLayout}.
      * @param activity  The {@link ActivityRecord} currently being positioned.
+     * @param source    The {@link ActivityRecord} from which activity was started from.
      * @param options   The {@link ActivityOptions} specified for the activity.
      * @param result    The resulting bounds. If no bounds are set, {@link Rect#isEmpty()} will be
-     *                  true.
+     *                  {@code true}.
      */
     void calculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity,
-            ActivityOptions options, Rect result) {
+            ActivityRecord source, ActivityOptions options, Rect result) {
         result.setEmpty();
 
         // We start at the last registered {@link LaunchingBoundsPositioner} as this represents
@@ -78,8 +79,8 @@
             mTmpCurrent.set(result);
             final LaunchingBoundsPositioner positioner = mPositioners.get(i);
 
-            switch(positioner.onCalculateBounds(task, layout, activity, options, mTmpCurrent,
-                    mTmpResult)) {
+            switch(positioner.onCalculateBounds(task, layout, activity, source, options,
+                    mTmpCurrent, mTmpResult)) {
                 case RESULT_SKIP:
                     // Do not apply any results when we are told to skip
                     continue;
@@ -100,7 +101,8 @@
      * @return {@code true} if bounds were set on the task. {@code false} otherwise.
      */
     boolean layoutTask(TaskRecord task, WindowLayout layout) {
-        calculateBounds(task, layout, null /*activity*/, null /*options*/, mTmpRect);
+        calculateBounds(task, layout, null /*activity*/, null /*source*/, null /*options*/,
+                mTmpRect);
 
         if (mTmpRect.isEmpty()) {
             return false;
@@ -145,16 +147,17 @@
          * @param task      The {@link TaskRecord} currently being positioned.
          * @param layout    The specified {@link WindowLayout}.
          * @param activity  The {@link ActivityRecord} currently being positioned.
+         * @param source    The {@link ActivityRecord} activity was started from.
          * @param options   The {@link ActivityOptions} specified for the activity.
          * @param current   The current bounds. This can differ from the initial bounds as it
          *                  represents the modified bounds up to this point.
          * @param result    The {@link Rect} which the positioner should return its modified bounds.
          *                  Any merging of the current bounds should be already applied to this
          *                  value as well before returning.
-         * @return A {@link Result} representing the result of the bounds calculation.
+         * @return          A {@link Result} representing the result of the bounds calculation.
          */
         @Result
         int onCalculateBounds(TaskRecord task, WindowLayout layout, ActivityRecord activity,
-                ActivityOptions options, Rect current, Rect result);
+                ActivityRecord source, ActivityOptions options, Rect current, Rect result);
     }
 }
diff --git a/services/core/java/com/android/server/am/LaunchingTaskPositioner.java b/services/core/java/com/android/server/am/LaunchingTaskPositioner.java
index 6389075..c958fca 100644
--- a/services/core/java/com/android/server/am/LaunchingTaskPositioner.java
+++ b/services/core/java/com/android/server/am/LaunchingTaskPositioner.java
@@ -79,7 +79,8 @@
      */
     @Override
     public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout,
-            ActivityRecord activity, ActivityOptions options, Rect current, Rect result) {
+            ActivityRecord activity, ActivityRecord source,
+            ActivityOptions options, Rect current, Rect result) {
         // We can only apply positioning if we're in a freeform stack.
         if (task == null || task.getStack() == null || !task.inFreeformWindowingMode()) {
             return RESULT_SKIP;