Move stack to front in-sync with task reparenting

When reparenting a task to another stack have window manager move the
destination stack to the front at the same time it is reparenting the
task if REPARENT_MOVE_STACK_TO_FRONT is set to avoid jank.

Test: manual
Bug: 37299899
Change-Id: I45678e742188a4871f93a11178f7ab2b60c7bcc3
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index c7f20b9f..f8a4d4b 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -658,7 +658,8 @@
 
             // Must reparent first in window manager to avoid a situation where AM can delete the
             // we are coming from in WM before we reparent because it became empty.
-            mWindowContainerController.reparent(toStack.getWindowContainerController(), position);
+            mWindowContainerController.reparent(toStack.getWindowContainerController(), position,
+                    moveStackMode == REPARENT_MOVE_STACK_TO_FRONT);
 
             // Move the task
             sourceStack.removeTask(this, reason, REMOVE_TASK_MODE_MOVING);