Fix unminimizing dock stack for AppTask.moveToFront

Some apps call AppTask.moveToFront instead of startActivity from
their trampoline activity. We need to handle this case also and
need to do all the post processing after starting an activity
so the docked stack gets unminimized.

Change-Id: I8400995bf1d1a4a4467d01fd55fca7e5800b4645
Fixes: 28722017
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 637061d09..0e4c9a4 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -4404,6 +4404,12 @@
                     "startActivityFromRecentsInner: Task " + taskId + " not found.");
         }
 
+        // Since we don't have an actual source record here, we assume that the currently focused
+        // activity was the source.
+        final ActivityStack focusedStack = getFocusedStack();
+        final ActivityRecord sourceRecord =
+                focusedStack != null ? focusedStack.topActivity() : null;
+
         if (launchStackId != INVALID_STACK_ID) {
             if (task.stack.mStackId != launchStackId) {
                 moveTaskToStackLocked(
@@ -4427,6 +4433,11 @@
             if (launchStackId == DOCKED_STACK_ID) {
                 setResizingDuringAnimation(taskId);
             }
+
+            mService.mActivityStarter.postStartActivityUncheckedProcessing(task.getTopActivity(),
+                    ActivityManager.START_TASK_TO_FRONT,
+                    sourceRecord != null ? sourceRecord.task.stack.mStackId : INVALID_STACK_ID,
+                    sourceRecord, task.stack);
             return ActivityManager.START_TASK_TO_FRONT;
         }
         callingUid = task.mCallingUid;