Misc fixes for window moving and resizing

- Do not skip resizeTask if we're starting or ending drag. We need
  the relayout because surface mode is changing.

- When we're changing the surface mode, need to wait for the first
  draw to finish before we can modify shown frame. Otherwise there
  could be 1 old frame displayed with new position, which makes the
  window position look a bit off.

- Clean up dragResizing/dragResizeChanged flags.

Change-Id: Ia396d6b88fd616ad57aa8cd24ca7e1161add7205
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index cc9efdb..58f0448 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -72,6 +72,12 @@
     // For handling display rotations.
     private Rect mTmpRect2 = new Rect();
 
+    // Whether the task is currently being drag-resized
+    private boolean mDragResizing;
+
+    // Whether the task is starting or ending to be drag-resized
+    private boolean mDragResizeChanging;
+
     // The particular window with FLAG_DIM_BEHIND set. If null, hide mDimLayer.
     WindowStateAnimator mDimWinAnimator;
     // Used to support {@link android.view.WindowManager.LayoutParams#FLAG_DIM_BEHIND}
@@ -227,10 +233,34 @@
         return boundsChange;
     }
 
+    boolean resizeLocked(Rect bounds, Configuration configuration) {
+        int boundsChanged = setBounds(bounds, configuration);
+        if (mDragResizeChanging) {
+            boundsChanged |= BOUNDS_CHANGE_SIZE;
+            mDragResizeChanging = false;
+        }
+        if (boundsChanged == BOUNDS_CHANGE_NONE) {
+            return false;
+        }
+        if ((boundsChanged & BOUNDS_CHANGE_SIZE) == BOUNDS_CHANGE_SIZE) {
+            resizeWindows();
+        }
+        return true;
+    }
+
     void getBounds(Rect out) {
         out.set(mBounds);
     }
 
+    void setDragResizing(boolean dragResizing) {
+        mDragResizeChanging = mDragResizing != dragResizing;
+        mDragResizing = dragResizing;
+    }
+
+    boolean isDragResizing() {
+        return mDragResizing;
+    }
+
     void updateDisplayInfo(final DisplayContent displayContent) {
         if (displayContent == null) {
             return;