Report bounds instead of size in WindowMetrics

Use case: Jetpack WM will use them to get the location of windows on
screen and compute the display feature positions in window coordinate
space.

Bug: 150908045
Test: atest FrameworksCoreTests:WindowMetricsTest
Test: atest CtsWindowManagerDeviceTestCases:WindowMetricsTests
Change-Id: Ia08950cd5df35971408e8b17bb27d97d29d0ab9b
Exempt-From-Owner-Approval: API change
diff --git a/api/current.txt b/api/current.txt
index eb8ee3c..d1bf4ea 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -55752,8 +55752,8 @@
   }
 
   public final class WindowMetrics {
-    ctor public WindowMetrics(@NonNull android.util.Size, @NonNull android.view.WindowInsets);
-    method @NonNull public android.util.Size getSize();
+    ctor public WindowMetrics(@NonNull android.graphics.Rect, @NonNull android.view.WindowInsets);
+    method @NonNull public android.graphics.Rect getBounds();
     method @NonNull public android.view.WindowInsets getWindowInsets();
   }
 
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index c2ee21d..a6d2fa8 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -60,7 +60,6 @@
 import android.util.Log;
 import android.util.PrintWriterPrinter;
 import android.util.Printer;
-import android.util.Size;
 import android.view.Gravity;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
@@ -1479,8 +1478,8 @@
      */
     public int getMaxWidth() {
         final WindowManager windowManager = getSystemService(WindowManager.class);
-        final Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
-        return windowSize.getWidth();
+        final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
+        return windowBounds.width();
     }
     
     /**
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index dffcafe..0ccb1e0 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -57,8 +57,8 @@
  * <li>The application display area specifies the part of the display that may contain
  * an application window, excluding the system decorations.  The application display area may
  * be smaller than the real display area because the system subtracts the space needed
- * for decor elements such as the status bar.  Use {@link WindowMetrics#getSize()} to query the
- * application window size.</li>
+ * for decor elements such as the status bar.  Use {@link WindowMetrics#getBounds()} to query the
+ * application window bounds.</li>
  * <li>The real display area specifies the part of the display that contains content
  * including the system decorations.  Even so, the real display area may be smaller than the
  * physical size of the display if the window manager is emulating a smaller display
@@ -673,7 +673,7 @@
      *
      * @param outSize A {@link Point} object to receive the size information.
      * @deprecated Use {@link WindowManager#getCurrentWindowMetrics()} to obtain an instance of
-     * {@link WindowMetrics} and use {@link WindowMetrics#getSize()} instead.
+     * {@link WindowMetrics} and use {@link WindowMetrics#getBounds()} instead.
      */
     @Deprecated
     public void getSize(Point outSize) {
@@ -689,7 +689,7 @@
      * Gets the size of the display as a rectangle, in pixels.
      *
      * @param outSize A {@link Rect} object to receive the size information.
-     * @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
+     * @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
      * window area.
      */
     @Deprecated
@@ -755,7 +755,7 @@
     }
 
     /**
-     * @deprecated Use {@link WindowMetrics#getSize()} instead.
+     * @deprecated Use {@link WindowMetrics#getBounds#width()} instead.
      */
     @Deprecated
     public int getWidth() {
@@ -766,7 +766,7 @@
     }
 
     /**
-     * @deprecated Use {@link WindowMetrics#getSize()} instead.
+     * @deprecated Use {@link WindowMetrics#getBounds()#height()} instead.
      */
     @Deprecated
     public int getHeight() {
@@ -1105,7 +1105,7 @@
      * </p>
      *
      * @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
-     * @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
+     * @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
      * window area, and {@link Configuration#densityDpi} to get the current density.
      */
     @Deprecated
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index 04260c4..4bea623 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -23,11 +23,11 @@
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.Resources;
+import android.graphics.Rect;
 import android.os.Build;
 import android.os.RemoteException;
 import android.provider.Settings;
 import android.util.DisplayMetrics;
-import android.util.Size;
 import android.util.SparseArray;
 import android.util.TypedValue;
 
@@ -410,8 +410,8 @@
 
         // Size of the screen in bytes, in ARGB_8888 format
         final WindowManager windowManager = context.getSystemService(WindowManager.class);
-        final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
-        mMaximumDrawingCacheSize = 4 * maxWindowSize.getWidth() * maxWindowSize.getHeight();
+        final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
+        mMaximumDrawingCacheSize = 4 * maxWindowBounds.width() * maxWindowBounds.height();
 
         mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
         mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index 4050da1..0942bca 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -35,7 +35,6 @@
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
-import android.util.Size;
 
 import com.android.internal.os.IResultReceiver;
 
@@ -220,7 +219,7 @@
         final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;
         final Rect bounds = getCurrentBounds(context);
 
-        return new WindowMetrics(toSize(bounds), computeWindowInsets(bounds));
+        return new WindowMetrics(bounds, computeWindowInsets(bounds));
     }
 
     private static Rect getCurrentBounds(Context context) {
@@ -232,11 +231,7 @@
     @Override
     public WindowMetrics getMaximumWindowMetrics() {
         final Rect maxBounds = getMaximumBounds();
-        return new WindowMetrics(toSize(maxBounds), computeWindowInsets(maxBounds));
-    }
-
-    private Size toSize(Rect frame) {
-        return new Size(frame.width(), frame.height());
+        return new WindowMetrics(maxBounds, computeWindowInsets(maxBounds));
     }
 
     private Rect getMaximumBounds() {
diff --git a/core/java/android/view/WindowMetrics.java b/core/java/android/view/WindowMetrics.java
index ab5a06e..86ef879 100644
--- a/core/java/android/view/WindowMetrics.java
+++ b/core/java/android/view/WindowMetrics.java
@@ -18,10 +18,10 @@
 
 import android.annotation.NonNull;
 import android.graphics.Point;
-import android.util.Size;
+import android.graphics.Rect;
 
 /**
- * Metrics about a Window, consisting of the size and {@link WindowInsets}.
+ * Metrics about a Window, consisting of the bounds and {@link WindowInsets}.
  * <p>
  * This is usually obtained from {@link WindowManager#getCurrentWindowMetrics()} and
  * {@link WindowManager#getMaximumWindowMetrics()}.
@@ -31,21 +31,22 @@
  * @see WindowManager#getMaximumWindowMetrics()
  */
 public final class WindowMetrics {
-    private final @NonNull Size mSize;
+    private final @NonNull Rect mBounds;
     private final @NonNull WindowInsets mWindowInsets;
 
-    public WindowMetrics(@NonNull Size size, @NonNull WindowInsets windowInsets) {
-        mSize = size;
+    public WindowMetrics(@NonNull Rect bounds, @NonNull WindowInsets windowInsets) {
+        mBounds = bounds;
         mWindowInsets = windowInsets;
     }
 
     /**
-     * Returns the size of the window.
+     * Returns the bounds of the area associated with this window or visual context.
      * <p>
-     * <b>Note that this reports a different size than {@link Display#getSize(Point)}.</b>
-     * This method reports the window size including all system bars area, while
-     * {@link Display#getSize(Point)} reports the area excluding navigation bars and display cutout
-     * areas. The value reported by {@link Display#getSize(Point)} can be obtained by using:
+     * <b>Note that the size of the reported bounds can have different size than
+     * {@link Display#getSize(Point)}.</b> This method reports the window size including all system
+     * bar areas, while {@link Display#getSize(Point)} reports the area excluding navigation bars
+     * and display cutout areas. The value reported by {@link Display#getSize(Point)} can be
+     * obtained by using:
      * <pre class="prettyprint">
      * final WindowMetrics metrics = windowManager.getCurrentMetrics();
      * // Gets all excluding insets
@@ -66,16 +67,16 @@
      * </pre>
      * </p>
      *
-     * @return window size in pixel.
+     * @return window bounds in pixels.
      */
-    public @NonNull Size getSize() {
-        return mSize;
+    public @NonNull Rect getBounds() {
+        return mBounds;
     }
 
     /**
-     * Returns the {@link WindowInsets} of the window.
+     * Returns the {@link WindowInsets} of the area associated with this window or visual context.
      *
-     * @return the {@link WindowInsets} of the window.
+     * @return the {@link WindowInsets} of the visual area.
      */
     public @NonNull WindowInsets getWindowInsets() {
         return mWindowInsets;
diff --git a/core/java/android/view/autofill/AutofillPopupWindow.java b/core/java/android/view/autofill/AutofillPopupWindow.java
index 8d3dc83..2ead352 100644
--- a/core/java/android/view/autofill/AutofillPopupWindow.java
+++ b/core/java/android/view/autofill/AutofillPopupWindow.java
@@ -25,7 +25,6 @@
 import android.os.RemoteException;
 import android.transition.Transition;
 import android.util.Log;
-import android.util.Size;
 import android.view.View;
 import android.view.View.OnTouchListener;
 import android.view.ViewTreeObserver;
@@ -129,10 +128,10 @@
             // Gravity.BOTTOM because PopupWindow base class does not expose computeGravity().
             final WindowManager windowManager = anchor.getContext()
                     .getSystemService(WindowManager.class);
-            final Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
-            width = windowSize.getWidth();
+            final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
+            width = windowBounds.width();
             if (height != LayoutParams.MATCH_PARENT) {
-                offsetY = windowSize.getHeight() - height;
+                offsetY = windowBounds.height() - height;
             }
             actualAnchor = anchor;
         } else if (virtualBounds != null) {
diff --git a/core/java/com/android/internal/view/menu/MenuPopupHelper.java b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
index 0aeaa47..980943e 100644
--- a/core/java/com/android/internal/view/menu/MenuPopupHelper.java
+++ b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
@@ -22,14 +22,10 @@
 import android.annotation.StyleRes;
 import android.compat.annotation.UnsupportedAppUsage;
 import android.content.Context;
-import android.graphics.Point;
 import android.graphics.Rect;
-import android.util.Size;
-import android.view.Display;
 import android.view.Gravity;
 import android.view.View;
 import android.view.WindowManager;
-import android.view.WindowMetrics;
 import android.widget.PopupWindow.OnDismissListener;
 
 import com.android.internal.view.menu.MenuPresenter.Callback;
@@ -227,9 +223,9 @@
     @NonNull
     private MenuPopup createPopup() {
         final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
-        final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
+        final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
 
-        final int smallestWidth = Math.min(maxWindowSize.getWidth(), maxWindowSize.getHeight());
+        final int smallestWidth = Math.min(maxWindowBounds.width(), maxWindowBounds.height());
         final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(
             com.android.internal.R.dimen.cascading_menus_min_smallest_width);
         final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading;
diff --git a/core/tests/coretests/BstatsTestApp/src/com/android/coretests/apps/bstatstestapp/TestService.java b/core/tests/coretests/BstatsTestApp/src/com/android/coretests/apps/bstatstestapp/TestService.java
index 79b803a..0cd0643e 100644
--- a/core/tests/coretests/BstatsTestApp/src/com/android/coretests/apps/bstatstestapp/TestService.java
+++ b/core/tests/coretests/BstatsTestApp/src/com/android/coretests/apps/bstatstestapp/TestService.java
@@ -25,13 +25,13 @@
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Color;
+import android.graphics.Rect;
 import android.hardware.display.DisplayManager;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Process;
 import android.os.RemoteException;
 import android.util.Log;
-import android.util.Size;
 import android.view.Display;
 import android.view.Gravity;
 import android.view.View;
@@ -119,15 +119,15 @@
         @Override
         public void showApplicationOverlay() throws RemoteException {
             final WindowManager wm = mOverlayContext.getSystemService(WindowManager.class);
-            final Size size = wm.getCurrentWindowMetrics().getSize();
+            final Rect bounds = wm.getCurrentWindowMetrics().getBounds();
 
             final WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(
                     TYPE_APPLICATION_OVERLAY,
                     WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                             | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                             | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
-            wmlp.width = size.getWidth() / 2;
-            wmlp.height = size.getHeight() / 2;
+            wmlp.width = bounds.width() / 2;
+            wmlp.height = bounds.height() / 2;
             wmlp.gravity = Gravity.CENTER | Gravity.LEFT;
             wmlp.setTitle(TAG);
 
diff --git a/core/tests/coretests/src/android/util/GridScenario.java b/core/tests/coretests/src/android/util/GridScenario.java
index 4809a21..e7ee1cd 100644
--- a/core/tests/coretests/src/android/util/GridScenario.java
+++ b/core/tests/coretests/src/android/util/GridScenario.java
@@ -233,7 +233,7 @@
         // turn off title bar
         requestWindowFeature(Window.FEATURE_NO_TITLE);
 
-        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
+        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
 
         final Params params = new Params();
         init(params);
diff --git a/core/tests/coretests/src/android/util/ListScenario.java b/core/tests/coretests/src/android/util/ListScenario.java
index d4e5a43..74dc4b4 100644
--- a/core/tests/coretests/src/android/util/ListScenario.java
+++ b/core/tests/coretests/src/android/util/ListScenario.java
@@ -306,7 +306,7 @@
         requestWindowFeature(Window.FEATURE_NO_TITLE);
 
 
-        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
+        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
 
         final Params params = createParams();
         init(params);
diff --git a/core/tests/coretests/src/android/util/ScrollViewScenario.java b/core/tests/coretests/src/android/util/ScrollViewScenario.java
index 2c0aa73..ab1a642 100644
--- a/core/tests/coretests/src/android/util/ScrollViewScenario.java
+++ b/core/tests/coretests/src/android/util/ScrollViewScenario.java
@@ -239,7 +239,7 @@
 
         // for test stability, turn off title bar
         requestWindowFeature(Window.FEATURE_NO_TITLE);
-        int screenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight()
+        int screenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height()
                 - 25;
         mLinearLayout = new LinearLayout(this);
         mLinearLayout.setOrientation(LinearLayout.VERTICAL);
diff --git a/core/tests/coretests/src/android/view/BigCache.java b/core/tests/coretests/src/android/view/BigCache.java
index e465a85..3038e79 100644
--- a/core/tests/coretests/src/android/view/BigCache.java
+++ b/core/tests/coretests/src/android/view/BigCache.java
@@ -17,8 +17,8 @@
 package android.view;
 
 import android.app.Activity;
+import android.graphics.Rect;
 import android.os.Bundle;
-import android.util.Size;
 import android.widget.LinearLayout;
 import android.widget.ScrollView;
 
@@ -39,9 +39,9 @@
                 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
 
         final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
-        final Size windowSize = getWindowManager().getCurrentWindowMetrics().getSize();
-        final int screenWidth = windowSize.getWidth();
-        final int screenHeight = windowSize.getHeight();
+        final Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds();
+        final int screenWidth = windowBounds.width();
+        final int screenHeight = windowBounds.height();
 
         final View tiny = new View(this);
         tiny.setId(R.id.a);
diff --git a/core/tests/coretests/src/android/view/ScaleGestureDetectorTest.java b/core/tests/coretests/src/android/view/ScaleGestureDetectorTest.java
index 039387c..46e55fa 100644
--- a/core/tests/coretests/src/android/view/ScaleGestureDetectorTest.java
+++ b/core/tests/coretests/src/android/view/ScaleGestureDetectorTest.java
@@ -22,7 +22,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import android.util.Size;
+import android.graphics.Rect;
 import android.widget.TextView;
 
 import androidx.test.filters.LargeTest;
@@ -55,9 +55,9 @@
 
         // Specify start and end coordinates with respect to the window size.
         final WindowManager wm = mScaleGestureActivity.getSystemService(WindowManager.class);
-        final Size windowSize = wm.getCurrentWindowMetrics().getSize();
-        final int windowWidth = windowSize.getWidth();
-        final int windowHeight = windowSize.getHeight();
+        final Rect windowBounds = wm.getCurrentWindowMetrics().getBounds();
+        final int windowWidth = windowBounds.width();
+        final int windowHeight = windowBounds.height();
 
         // Obtain coordinates to perform pinch and zoom from the center, to 75% of the display.
         final int centerX = windowWidth / 2;
diff --git a/core/tests/coretests/src/android/view/WindowMetricsTest.java b/core/tests/coretests/src/android/view/WindowMetricsTest.java
index fa68860..74524bf 100644
--- a/core/tests/coretests/src/android/view/WindowMetricsTest.java
+++ b/core/tests/coretests/src/android/view/WindowMetricsTest.java
@@ -22,10 +22,10 @@
 import static org.junit.Assert.assertTrue;
 
 import android.content.Context;
+import android.graphics.Rect;
 import android.hardware.display.DisplayManager;
 import android.os.Handler;
 import android.platform.test.annotations.Presubmit;
-import android.util.Size;
 
 import androidx.test.filters.FlakyTest;
 import androidx.test.filters.SmallTest;
@@ -87,10 +87,12 @@
 
     private static void verifyMetricsSanity(WindowMetrics currentMetrics,
             WindowMetrics maxMetrics) {
-        Size currentSize = currentMetrics.getSize();
-        Size maxSize = maxMetrics.getSize();
+        Rect currentBounds = currentMetrics.getBounds();
+        Rect maxBounds = maxMetrics.getBounds();
 
-        assertTrue(maxSize.getWidth() >= currentSize.getWidth());
-        assertTrue(maxSize.getHeight() >= currentSize.getHeight());
+        assertTrue(maxBounds.width() >= currentBounds.width());
+        assertTrue(maxBounds.height() >= currentBounds.height());
+        assertTrue(maxBounds.left >= 0);
+        assertTrue(maxBounds.top >= 0);
     }
 }
diff --git a/core/tests/coretests/src/android/view/menu/ContextMenuTest.java b/core/tests/coretests/src/android/view/menu/ContextMenuTest.java
index d5825e2..4bd9ccd 100644
--- a/core/tests/coretests/src/android/view/menu/ContextMenuTest.java
+++ b/core/tests/coretests/src/android/view/menu/ContextMenuTest.java
@@ -16,9 +16,9 @@
 
 package android.view.menu;
 
+import android.graphics.Rect;
 import android.test.ActivityInstrumentationTestCase;
 import android.util.PollingCheck;
-import android.util.Size;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.espresso.ContextMenuUtils;
@@ -81,8 +81,8 @@
      */
     private int getMinScreenDimension() {
         final WindowManager windowManager = getActivity().getSystemService(WindowManager.class);
-        final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
-        return Math.min(maxWindowSize.getWidth(), maxWindowSize.getHeight());
+        final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
+        return Math.min(maxWindowBounds.width(), maxWindowBounds.height());
     }
 
     /**
diff --git a/core/tests/coretests/src/android/widget/focus/ListOfInternalSelectionViews.java b/core/tests/coretests/src/android/widget/focus/ListOfInternalSelectionViews.java
index 8e90a82..d51cc32 100644
--- a/core/tests/coretests/src/android/widget/focus/ListOfInternalSelectionViews.java
+++ b/core/tests/coretests/src/android/widget/focus/ListOfInternalSelectionViews.java
@@ -111,7 +111,7 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
+        mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
 
         Bundle extras = getIntent().getExtras();
         if (extras != null) {
diff --git a/core/tests/coretests/src/android/widget/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java b/core/tests/coretests/src/android/widget/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java
index fd1dbfc..5cedd13 100644
--- a/core/tests/coretests/src/android/widget/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java
+++ b/core/tests/coretests/src/android/widget/gridview/touch/GridTouchVerticalSpacingStackFromBottomTest.java
@@ -106,8 +106,8 @@
 
         int firstTop = firstChild.getTop();
 
-        int windowHeight = mActivity.getWindowManager().getCurrentWindowMetrics().getSize()
-                .getHeight();
+        int windowHeight = mActivity.getWindowManager().getCurrentWindowMetrics().getBounds()
+                .height();
         int distance = TouchUtils.dragViewBy(this, firstChild, 
                 Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, (int) (windowHeight * 0.75f));
         
diff --git a/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java b/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java
index e6195b1..5cca766 100644
--- a/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java
+++ b/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java
@@ -66,7 +66,7 @@
         super.onCreate(savedInstanceState);
 
         final int desiredHeight =
-                (int) (0.8 * getWindowManager().getCurrentWindowMetrics().getSize().getHeight());
+                (int) (0.8 * getWindowManager().getCurrentWindowMetrics().getBounds().height());
 
         mLeftListView = new ListView(this);
         mLeftListView.setAdapter(new AdjacentISVAdapter(desiredHeight));
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/helpers/CameraTestUtils.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/helpers/CameraTestUtils.java
index 2522095..daeb731 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/helpers/CameraTestUtils.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/helpers/CameraTestUtils.java
@@ -2210,14 +2210,14 @@
     }
 
     public static Size getPreviewSizeBound(WindowManager windowManager, Size bound) {
-        Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
+        Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
 
-        int width = windowSize.getWidth();
-        int height = windowSize.getHeight();
+        int width = windowBounds.width();
+        int height = windowBounds.height();
 
         if (height > width) {
             height = width;
-            width = windowSize.getHeight();
+            width = windowBounds.height();
         }
 
         if (bound.getWidth() <= width &&
diff --git a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
index d4eb2a9..a2da23e 100644
--- a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
+++ b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeApp.java
@@ -28,11 +28,11 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.graphics.Rect;
 import android.hardware.display.DisplayManager;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
-import android.util.Size;
 import android.util.Slog;
 import android.view.Display;
 import android.view.ViewGroup;
@@ -134,8 +134,8 @@
         }
         lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
         lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
-        Size maxWindowSize = wm.getMaximumWindowMetrics().getSize();
-        int maxSize = Math.max(maxWindowSize.getWidth(), maxWindowSize.getHeight());
+        Rect maxWindowBounds = wm.getMaximumWindowMetrics().getBounds();
+        int maxSize = Math.max(maxWindowBounds.width(), maxWindowBounds.height());
         maxSize *= 2;
         lp.x = maxSize;
         lp.y = maxSize;
diff --git a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java
index df00eee..e2120f8 100644
--- a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java
+++ b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java
@@ -19,22 +19,22 @@
 import static android.view.Display.DEFAULT_DISPLAY;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
 
-import java.util.ArrayList;
-import java.util.Random;
-
 import android.app.Dialog;
 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Rect;
 import android.hardware.display.DisplayManager;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
-import android.util.Size;
 import android.view.Display;
 import android.view.ViewGroup;
 import android.view.WindowManager;
 
+import java.util.ArrayList;
+import java.util.Random;
+
 public class FakeBackgroundService extends Service {
     final ArrayList<int[]> mAllocs = new ArrayList<int[]>();
 
@@ -99,8 +99,8 @@
         // Create an instance of WindowManager that is adjusted to the area of the display dedicated
         // for windows with type TYPE_APPLICATION_OVERLAY.
         final WindowManager wm = windowContext.getSystemService(WindowManager.class);
-        Size maxWindowSize = wm.getMaximumWindowMetrics().getSize();
-        int maxSize = Math.max(maxWindowSize.getWidth(), maxWindowSize.getHeight());
+        Rect maxWindowBounds = wm.getMaximumWindowMetrics().getBounds();
+        int maxSize = Math.max(maxWindowBounds.width(), maxWindowBounds.height());
         maxSize *= 2;
         lp.x = maxSize;
         lp.y = maxSize;
diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
index 6112da5..fe9f60f 100644
--- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
+++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java
@@ -37,7 +37,6 @@
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.util.Log;
-import android.util.Size;
 import android.view.Display;
 import android.view.View;
 import android.widget.Toast;
@@ -358,8 +357,8 @@
         // Get the crop
         boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
 
-        Size windowSize = getWindowManager().getCurrentWindowMetrics().getSize();
-        boolean isPortrait = windowSize.getWidth() < windowSize.getHeight();
+        Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds();
+        boolean isPortrait = windowBounds.width() < windowBounds.height();
 
         Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(),
                 getDisplay());
diff --git a/test-runner/src/android/test/TouchUtils.java b/test-runner/src/android/test/TouchUtils.java
index bb4e00b..f2f0be7 100644
--- a/test-runner/src/android/test/TouchUtils.java
+++ b/test-runner/src/android/test/TouchUtils.java
@@ -223,7 +223,7 @@
     public static void dragViewToBottom(InstrumentationTestCase test, Activity activity, View v,
             int stepCount) {
         int screenHeight =
-                activity.getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
+                activity.getWindowManager().getCurrentWindowMetrics().getBounds().height();
 
         int[] xy = new int[2];
         v.getLocationOnScreen(xy);
diff --git a/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java b/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
index e255ce2..31532a2 100644
--- a/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
+++ b/tests/MirrorSurfaceTest/src/com/google/android/test/mirrorsurface/MirrorSurfaceActivity.java
@@ -27,7 +27,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
-import android.util.Size;
 import android.view.Gravity;
 import android.view.IWindowManager;
 import android.view.MotionEvent;
@@ -90,8 +89,8 @@
                 .getSystemService(WindowManager.class);
         mIWm = WindowManagerGlobal.getWindowManagerService();
 
-        Size windowSize = mWm.getCurrentWindowMetrics().getSize();
-        mWindowBounds.set(0, 0, windowSize.getWidth(), windowSize.getHeight());
+        Rect windowBounds = mWm.getCurrentWindowMetrics().getBounds();
+        mWindowBounds.set(0, 0, windowBounds.width(), windowBounds.height());
 
         mScaleText = findViewById(R.id.scale);
         mDisplayFrameText = findViewById(R.id.displayFrame);