Introduce multiple displays with DisplayContent.

Fix a couple of bugs that turned up.
Remove touch/focus from display. Add iterators for access.
Respond to comments. Remove TODOs, and some deviceId parameters.

Change-Id: Idcdb4f1979aa7b14634d450fd0333d6eff26994d
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index b0c858c..0dbe692 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -39,7 +39,7 @@
     final Context mContext;
     final WindowManagerPolicy mPolicy;
 
-    ArrayList<WindowStateAnimator> mWinAnimators = new ArrayList<WindowStateAnimator>();
+    ArrayList<WinAnimatorList> mWinAnimatorLists = new ArrayList<WinAnimatorList>();
 
     boolean mAnimating;
 
@@ -158,7 +158,8 @@
                 mWallpaperTokens = new ArrayList<WindowToken>(layoutToAnim.mWallpaperTokens);
             }
 
-            mWinAnimators = new ArrayList<WindowStateAnimator>(layoutToAnim.mWinAnimators);
+            mWinAnimatorLists =
+                    new ArrayList<WinAnimatorList>(layoutToAnim.mWinAnimatorLists);
             mWallpaperTarget = layoutToAnim.mWallpaperTarget;
             mWpAppAnimator = mWallpaperTarget == null
                     ? null : mWallpaperTarget.mAppToken == null
@@ -267,7 +268,7 @@
         }
     }
 
-    private void updateWindowsLocked() {
+    private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
         ++mAnimTransactionSequence;
 
         ArrayList<WindowStateAnimator> unForceHiding = null;
@@ -280,8 +281,8 @@
         final int KEYGUARD_ANIMATING_OUT = 3;
         int forceHiding = KEYGUARD_NOT_SHOWN;
 
-        for (int i = mWinAnimators.size() - 1; i >= 0; i--) {
-            WindowStateAnimator winAnimator = mWinAnimators.get(i);
+        for (int i = winAnimatorList.size() - 1; i >= 0; i--) {
+            WindowStateAnimator winAnimator = winAnimatorList.get(i);
             WindowState win = winAnimator.mWin;
             final int flags = winAnimator.mAttrFlags;
 
@@ -418,13 +419,13 @@
         }
     }
 
-    private void updateWallpaperLocked() {
+    private void updateWallpaperLocked(final WinAnimatorList winAnimatorList) {
         WindowStateAnimator windowAnimationBackground = null;
         int windowAnimationBackgroundColor = 0;
         WindowState detachedWallpaper = null;
 
-        for (int i = mWinAnimators.size() - 1; i >= 0; i--) {
-            WindowStateAnimator winAnimator = mWinAnimators.get(i);
+        for (int i = winAnimatorList.size() - 1; i >= 0; i--) {
+            WindowStateAnimator winAnimator = winAnimatorList.get(i);
             if (winAnimator.mSurface == null) {
                 continue;
             }
@@ -489,11 +490,11 @@
             // don't cause the wallpaper to suddenly disappear.
             int animLayer = windowAnimationBackground.mAnimLayer;
             WindowState win = windowAnimationBackground.mWin;
-            if (windowAnimationBackground != null && mWallpaperTarget == win
+            if (mWallpaperTarget == win
                     || mLowerWallpaperTarget == win || mUpperWallpaperTarget == win) {
-                final int N = mWinAnimators.size();
+                final int N = winAnimatorList.size();
                 for (int i = 0; i < N; i++) {
-                    WindowStateAnimator winAnimator = mWinAnimators.get(i);
+                    WindowStateAnimator winAnimator = winAnimatorList.get(i);
                     if (winAnimator.mIsWallpaper) {
                         animLayer = winAnimator.mAnimLayer;
                         break;
@@ -548,9 +549,9 @@
         }
     }
 
-    private void performAnimationsLocked() {
-        updateWindowsLocked();
-        updateWallpaperLocked();
+    private void performAnimationsLocked(final WinAnimatorList winAnimatorList) {
+        updateWindowsLocked(winAnimatorList);
+        updateWallpaperLocked(winAnimatorList);
 
         if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
             mPendingActions |= WALLPAPER_ACTION_PENDING;
@@ -562,6 +563,12 @@
     // TODO(cmautner): Change the following comment when no longer locked on mWindowMap */
     /** Locked on mService.mWindowMap and this. */
     private void animateLocked() {
+        for (int i = mWinAnimatorLists.size() - 1; i >= 0; i--) {
+            animateLocked(mWinAnimatorLists.get(i));
+        }
+    }
+
+    private void animateLocked(final WinAnimatorList winAnimatorList) {
         mPendingLayoutChanges = 0;
         mCurrentTime = SystemClock.uptimeMillis();
         mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
@@ -577,7 +584,7 @@
 
         try {
             updateWindowsAppsAndRotationAnimationsLocked();
-            performAnimationsLocked();
+            performAnimationsLocked(winAnimatorList);
 
             // THIRD LOOP: Update the surfaces of all windows.
 
@@ -585,9 +592,9 @@
                 mScreenRotationAnimation.updateSurfaces();
             }
 
-            final int N = mWinAnimators.size();
+            final int N = winAnimatorList.size();
             for (int i = 0; i < N; i++) {
-                mWinAnimators.get(i).prepareSurfaceLocked(true);
+                winAnimatorList.get(i).prepareSurfaceLocked(true);
             }
 
             if (mDimParams != null) {