Use fullscreen sized buffer for drag resizing

- When drag resizing starts, set the surface size to fullscreen
  (plus any surface insets requested by win attrs), so that we don't
  reallocate buffers and the buffers don't get rejected by surfaceflinger
  due to size-mismatch.

- When drag resizing ends, restore the surface size to the original.

- Update shown frame before setSurfaceBoundariesLocked(), as the top-left
  of the window could change, we need to update the surface position. This
  fixes incorrect window positing during resizing by corners on top/left.

- When doing tap-detection, skip non-freeformed tasks. This fixes the
  bug where clicking near border of a window could dismiss it.

Change-Id: I5dc9fc34ff05685320b8fe5d491b9c066c6726e8
diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java
index 17936a6..9e29925 100644
--- a/services/core/java/com/android/server/wm/TaskPositioner.java
+++ b/services/core/java/com/android/server/wm/TaskPositioner.java
@@ -85,6 +85,7 @@
 
     private int mTaskId;
     private TaskStack mStack;
+    private boolean mResizing;
     private final Rect mWindowOriginalBounds = new Rect();
     private final Rect mWindowDragBounds = new Rect();
     private float mStartDragX;
@@ -131,8 +132,8 @@
                             notifyMoveLocked(newX, newY);
                         }
                         try {
-                            mService.mActivityManager.resizeTask(mTaskId, mWindowDragBounds,
-                                    true /* resizedByUser */);
+                            mService.mActivityManager.resizeTask(
+                                    mTaskId, mWindowDragBounds, true /* resizedByUser */);
                         } catch(RemoteException e) {}
                     } break;
 
@@ -152,6 +153,11 @@
                 }
 
                 if (endDrag) {
+                    mResizing = false;
+                    try {
+                        mService.mActivityManager.resizeTask(
+                                mTaskId, mWindowDragBounds, true /* resizedByUser */);
+                    } catch(RemoteException e) {}
                     // Post back to WM to handle clean-ups. We still need the input
                     // event handler for the last finishInputEvent()!
                     mService.mH.sendEmptyMessage(H.FINISH_TASK_POSITIONING);
@@ -280,6 +286,10 @@
         mService.resumeRotationLocked();
     }
 
+    boolean isTaskResizing(final Task task) {
+        return mResizing && task != null && mTaskId == task.mTaskId;
+    }
+
     void startDragLocked(WindowState win, boolean resize, float startX, float startY) {
         if (DEBUG_TASK_POSITIONING) {
             Slog.d(TAG, "startDragLocked: win=" + win + ", resize=" + resize
@@ -300,6 +310,7 @@
             if (startY > visibleFrame.bottom) {
                 mCtrlType |= CTRL_BOTTOM;
             }
+            mResizing = true;
         }
 
         final Task task = win.getTask();