Resize all changed windows and fix moveTaskToStack

- Add all changing windows to mResizingWindows when an ActivityStack
is resized.

- Stop calling TaskStack.setBounds if the bounds haven't changed.

- Make moving a task from one stack to another work properly.

- Eliminate unused methods and redundant variables in WindowState and
WindowStateAnimator.

Change-Id: I3a950c777bcc50cdeced150d44423d4d0b38af4a
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 136353b..8a7a2fa 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -314,7 +314,12 @@
     }
 
     void removeTask(TaskRecord task) {
+        mWindowManager.removeTask(task.taskId);
         final ActivityStack stack = task.stack;
+        final ActivityRecord r = stack.mResumedActivity;
+        if (r != null && r.task == task) {
+            stack.mResumedActivity = null;
+        }
         if (stack.removeTask(task) && !stack.isHomeStack()) {
             if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing stack " + stack);
             mStacks.remove(stack);
@@ -1893,12 +1898,22 @@
     }
 
     void moveTaskToStack(int taskId, int stackId, boolean toTop) {
+        final TaskRecord task = anyTaskForIdLocked(taskId);
+        if (task == null) {
+            return;
+        }
         final ActivityStack stack = getStack(stackId);
         if (stack == null) {
             Slog.w(TAG, "moveTaskToStack: no stack for id=" + stackId);
             return;
         }
-        stack.moveTask(taskId, toTop);
+        removeTask(task);
+        stack.addTask(task, toTop);
+        if (toTop) {
+            moveHomeStack(stack.isHomeStack());
+            setFocusedStack(task.getTopActivity());
+        }
+        mWindowManager.addTask(taskId, stackId, toTop);
         resumeTopActivitiesLocked();
     }