Entry animation for docking windows.

We achieve the animation in the same way we would do that for maximizing
windows. We preserve the exiting window of relaunched activity until the
activity adds a new one. Then we animation the new window from the
bounds of the old window to the dock bounds.

This mostly reuses existing infrastructure for maximize animations, but
unfortunately needs scaling. The before window might be have one
dimension larger than after window and using cropping is not sufficient.

Change-Id: I9538ba983a0af1e64ea48aad6836173d6fd25f3b
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 17a4472..0e0ebf8 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1348,8 +1348,7 @@
 
         r.launchFailed = false;
         if (stack.updateLRUListLocked(r)) {
-            Slog.w(TAG, "Activity " + r
-                  + " being launched, but already in LRU list");
+            Slog.w(TAG, "Activity " + r + " being launched, but already in LRU list");
         }
 
         if (andResume) {
@@ -3110,16 +3109,6 @@
                 ensureActivitiesVisibleLocked(r, 0, !PRESERVE_WINDOWS);
                 if (!kept) {
                     resumeTopActivitiesLocked(stack, null, null);
-                    if (changedStacks && stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
-                        // We are about to relaunch the activity because its configuration changed
-                        // due to being maximized, i.e. size change. The activity will first
-                        // remove the old window and then add a new one. This call will tell window
-                        // manager about this, so it can preserve the old window until the new
-                        // one is drawn. This prevents having a gap between the removal and
-                        // addition, in which no window is visible. We also want the entrace of the
-                        // new window to be properly animated.
-                        mWindowManager.setReplacingWindow(r.appToken, true /* animate */);
-                    }
                 }
             }
         }
@@ -3246,6 +3235,16 @@
             return;
         }
         final String reason = "moveTaskToStack";
+        if (stackId == DOCKED_STACK_ID || stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
+            // We are about to relaunch the activity because its configuration changed due to
+            // being maximized, i.e. size change. The activity will first remove the old window
+            // and then add a new one. This call will tell window manager about this, so it can
+            // preserve the old window until the new one is drawn. This prevents having a gap
+            // between the removal and addition, in which no window is visible. We also want the
+            // entrace of the new window to be properly animated.
+            ActivityRecord r = task.getTopActivity();
+            mWindowManager.setReplacingWindow(r.appToken, true /* animate */);
+        }
         final ActivityStack stack =
                 moveTaskToStackUncheckedLocked(task, stackId, toTop, forceFocus, reason);