Correctly resize dialogs when measured in WRAP_CONTENT
Bug #2549649

If the window had a different size than its content but the content had already
been measured with the appropriate size, the window would not be resized. This
happens in wrap_content windows (dialogs.) This change simply adds a new codition
to window resizing: if the window is wrap_content, not as big as it can be and
not as big as its content, it gets resized.

Change-Id: I1d82d03af5a15c9ad8dffa0511d5f6d522578285
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index ed83bca..bf94707 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -852,7 +852,11 @@
         }
 
         boolean windowShouldResize = mLayoutRequested && windowResizesToFitContent
-            && (mWidth != host.mMeasuredWidth || mHeight != host.mMeasuredHeight);
+            && ((mWidth != host.mMeasuredWidth || mHeight != host.mMeasuredHeight)
+                || (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT &&
+                        frame.width() < desiredWindowWidth && frame.width() != mWidth)
+                || (lp.height == ViewGroup.LayoutParams.WRAP_CONTENT &&
+                        frame.height() < desiredWindowHeight && frame.height() != mHeight));
 
         final boolean computesInternalInsets =
                 attachInfo.mTreeObserver.hasComputeInternalInsetsListeners();