Make WindowState mUnderStatusBar reflect position.

The mUnderStatusBar variable was always true but now it changes
when the StackBox is no longer directly under the Status Bar.

Change-Id: I0c9db5790bfa9b0e4bb35e389d539fd941d56730
diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java
index 0647296..4a3699c 100644
--- a/services/java/com/android/server/wm/DisplayContent.java
+++ b/services/java/com/android/server/wm/DisplayContent.java
@@ -340,7 +340,7 @@
     boolean setStackBoxSize(Rect contentRect) {
         boolean change = false;
         for (int stackBoxNdx = mStackBoxes.size() - 1; stackBoxNdx >= 0; --stackBoxNdx) {
-            change |= mStackBoxes.get(stackBoxNdx).setStackBoxSizes(contentRect);
+            change |= mStackBoxes.get(stackBoxNdx).setStackBoxSizes(contentRect, true);
         }
         return change;
     }
diff --git a/services/java/com/android/server/wm/StackBox.java b/services/java/com/android/server/wm/StackBox.java
index 15f5dff..d352464 100644
--- a/services/java/com/android/server/wm/StackBox.java
+++ b/services/java/com/android/server/wm/StackBox.java
@@ -79,6 +79,9 @@
     /** Dirty flag. Something inside this or some descendant of this has changed. */
     boolean layoutNeeded;
 
+    /** True if this StackBox sits below the Status Bar. */
+    boolean mUnderStatusBar;
+
     /** Used to keep from reallocating a temporary Rect for propagating bounds to child boxes */
     Rect mTmpRect = new Rect();
 
@@ -286,14 +289,19 @@
 
     /** If this is a terminal StackBox (contains a TaskStack) set the bounds.
      * @param bounds The rectangle to set the bounds to.
+     * @param underStatusBar True if the StackBox is directly below the Status Bar.
      * @return True if the bounds changed, false otherwise. */
-    boolean setStackBoxSizes(Rect bounds) {
-        boolean change;
+    boolean setStackBoxSizes(Rect bounds, boolean underStatusBar) {
+        boolean change = false;
+        if (mUnderStatusBar != underStatusBar) {
+            change = true;
+            mUnderStatusBar = underStatusBar;
+        }
         if (mStack != null) {
-            change = !mBounds.equals(bounds);
+            change |= !mBounds.equals(bounds);
             if (change) {
                 mBounds.set(bounds);
-                mStack.setBounds(bounds);
+                mStack.setBounds(bounds, underStatusBar);
             }
         } else {
             mTmpRect.set(bounds);
@@ -301,18 +309,18 @@
                 final int height = bounds.height();
                 int firstHeight = (int)(height * mWeight);
                 mTmpRect.bottom = bounds.top + firstHeight;
-                change = mFirst.setStackBoxSizes(mTmpRect);
+                change |= mFirst.setStackBoxSizes(mTmpRect, underStatusBar);
                 mTmpRect.top = mTmpRect.bottom;
                 mTmpRect.bottom = bounds.top + height;
-                change |= mSecond.setStackBoxSizes(mTmpRect);
+                change |= mSecond.setStackBoxSizes(mTmpRect, false);
             } else {
                 final int width = bounds.width();
                 int firstWidth = (int)(width * mWeight);
                 mTmpRect.right = bounds.left + firstWidth;
-                change = mFirst.setStackBoxSizes(mTmpRect);
+                change |= mFirst.setStackBoxSizes(mTmpRect, underStatusBar);
                 mTmpRect.left = mTmpRect.right;
                 mTmpRect.right = bounds.left + width;
-                change |= mSecond.setStackBoxSizes(mTmpRect);
+                change |= mSecond.setStackBoxSizes(mTmpRect, underStatusBar);
             }
         }
         return change;
diff --git a/services/java/com/android/server/wm/TaskStack.java b/services/java/com/android/server/wm/TaskStack.java
index 6fd8745..827958d 100644
--- a/services/java/com/android/server/wm/TaskStack.java
+++ b/services/java/com/android/server/wm/TaskStack.java
@@ -222,7 +222,7 @@
         }
     }
 
-    void setBounds(Rect bounds) {
+    void setBounds(Rect bounds, boolean underStatusBar) {
         mDimLayer.setBounds(bounds);
         mAnimationBackgroundSurface.setBounds(bounds);
 
@@ -236,6 +236,7 @@
                     if (!resizingWindows.contains(win)) {
                         resizingWindows.add(win);
                     }
+                    win.mUnderStatusBar = underStatusBar;
                 }
             }
         }