Have DisplayContent be the call point for assigning window layers

First step in trying to make the WindowList private to DisplayContent
Have the rest of the system call DisplayContent when they need to
assign layers to windows instead of calling WindowLayersController
directly. That way all the various call points don't need to get
the WindowList from DisplayContent to pass on to WindowLayersController.

Test: Existing tests pass.
Change-Id: If869abf7ba1c33b575908006ae5ad1557abc361c
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 3681123..7299bdf 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -44,6 +44,7 @@
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
+import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYERS;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
@@ -171,13 +172,20 @@
     // the display's direct children should be allowed.
     private boolean mRemovingDisplay = false;
 
+    private final WindowLayersController mLayersController;
+    int mInputMethodAnimLayerAdjustment;
+
     /**
      * @param display May not be null.
      * @param service You know.
+     * @param layersController window layer controller used to assign layer to the windows on this
+     *                         display.
      */
-    DisplayContent(Display display, WindowManagerService service) {
+    DisplayContent(Display display, WindowManagerService service,
+            WindowLayersController layersController) {
         mDisplay = display;
         mDisplayId = display.getDisplayId();
+        mLayersController = layersController;
         display.getDisplayInfo(mDisplayInfo);
         display.getMetrics(mDisplayMetrics);
         isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
@@ -691,6 +699,24 @@
         }
     }
 
+    void setInputMethodAnimLayerAdjustment(int adj) {
+        if (DEBUG_LAYERS) Slog.v(TAG_WM, "Setting im layer adj to " + adj);
+        mInputMethodAnimLayerAdjustment = adj;
+        final WindowState imw = mService.mInputMethodWindow;
+        if (imw != null) {
+            imw.adjustAnimLayer(adj);
+        }
+        for (int i = mService.mInputMethodDialogs.size() - 1; i >= 0; i--) {
+            final WindowState dialog = mService.mInputMethodDialogs.get(i);
+            // TODO: This and other places setting mAnimLayer can probably use WS.adjustAnimLayer,
+            // but need to make sure we are not setting things twice for child windows that are
+            // already in the list.
+            dialog.mWinAnimator.mAnimLayer = dialog.mLayer + adj;
+            if (DEBUG_LAYERS) Slog.v(TAG_WM, "IM win " + imw
+                    + " anim layer: " + dialog.mWinAnimator.mAnimLayer);
+        }
+    }
+
     void prepareFreezingTaskBounds() {
         for (int stackNdx = mTaskStackContainers.size() - 1; stackNdx >= 0; --stackNdx) {
             final TaskStack stack = mTaskStackContainers.get(stackNdx);
@@ -798,6 +824,11 @@
         mDimLayerController.dump(prefix + "  ", pw);
         pw.println();
         mDividerControllerLocked.dump(prefix + "  ", pw);
+
+        if (mInputMethodAnimLayerAdjustment != 0) {
+            pw.println(subPrefix
+                    + "mInputMethodAnimLayerAdjustment=" + mInputMethodAnimLayerAdjustment);
+        }
     }
 
     @Override
@@ -1113,6 +1144,14 @@
         }
     }
 
+    /** Updates the layer assignment of windows on this display. */
+    void assignWindowLayers(boolean setLayoutNeeded) {
+        mLayersController.assignWindowLayers(mWindows);
+        if (setLayoutNeeded) {
+            setLayoutNeeded();
+        }
+    }
+
     /**
      * Z-orders the display window list so that:
      * <ul>