diff --git a/api/current.txt b/api/current.txt index eb8ee3cc99420..d1bf4ea85d0bc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -55752,8 +55752,8 @@ package android.view { } 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 c2ee21d5115da..a6d2fa8c3176d 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -60,7 +60,6 @@ import android.text.method.MovementMethod; 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 class InputMethodService extends AbstractInputMethodService { */ 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 dffcafe1de0e7..0ccb1e055c460 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -57,8 +57,8 @@ import java.util.List; *
  • 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.
  • + * for decor elements such as the status bar. Use {@link WindowMetrics#getBounds()} to query the + * application window bounds. *
  • 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 @@ public final class Display { * * @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 @@ public final class Display { * 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 @@ public final class Display { } /** - * @deprecated Use {@link WindowMetrics#getSize()} instead. + * @deprecated Use {@link WindowMetrics#getBounds#width()} instead. */ @Deprecated public int getWidth() { @@ -766,7 +766,7 @@ public final class Display { } /** - * @deprecated Use {@link WindowMetrics#getSize()} instead. + * @deprecated Use {@link WindowMetrics#getBounds()#height()} instead. */ @Deprecated public int getHeight() { @@ -1105,7 +1105,7 @@ public final class Display { *

    * * @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 04260c47eda32..4bea623716dcf 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -23,11 +23,11 @@ import android.compat.annotation.UnsupportedAppUsage; 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 @@ public class ViewConfiguration { // 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 4050da1b5cb11..0942bcabf7426 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -35,7 +35,6 @@ import android.graphics.Region; 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 @@ public final class WindowManagerImpl implements WindowManager { 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 @@ public final class WindowManagerImpl implements WindowManager { @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 ab5a06eb99de8..86ef87997a07c 100644 --- a/core/java/android/view/WindowMetrics.java +++ b/core/java/android/view/WindowMetrics.java @@ -18,10 +18,10 @@ package android.view; 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}. *

    * This is usually obtained from {@link WindowManager#getCurrentWindowMetrics()} and * {@link WindowManager#getMaximumWindowMetrics()}. @@ -31,21 +31,22 @@ import android.util.Size; * @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. *

    - * Note that this reports a different size than {@link Display#getSize(Point)}. - * 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: + * Note that the size of the reported bounds can have different size than + * {@link Display#getSize(Point)}. 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: *

          * final WindowMetrics metrics = windowManager.getCurrentMetrics();
          * // Gets all excluding insets
    @@ -66,16 +67,16 @@ public final class WindowMetrics {
          * 
    *

    * - * @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 8d3dc83bca0cf..2ead352fd199c 100644 --- a/core/java/android/view/autofill/AutofillPopupWindow.java +++ b/core/java/android/view/autofill/AutofillPopupWindow.java @@ -25,7 +25,6 @@ import android.os.IBinder; 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 @@ public class AutofillPopupWindow extends PopupWindow { // 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 0aeaa47ba3d82..980943ebea5a9 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.Nullable; 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 @@ public class MenuPopupHelper implements MenuHelper { @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 79b803a0cda69..0cd0643ee8c07 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.app.Service; 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 @@ public class TestService extends Service { @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 4809a213ab488..e7ee1cd59c7cf 100644 --- a/core/tests/coretests/src/android/util/GridScenario.java +++ b/core/tests/coretests/src/android/util/GridScenario.java @@ -233,7 +233,7 @@ public abstract class GridScenario extends Activity { // 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 d4e5a438d855d..74dc4b4b34a1e 100644 --- a/core/tests/coretests/src/android/util/ListScenario.java +++ b/core/tests/coretests/src/android/util/ListScenario.java @@ -306,7 +306,7 @@ public abstract class ListScenario extends Activity { 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 2c0aa7362dfa2..ab1a642a9327d 100644 --- a/core/tests/coretests/src/android/util/ScrollViewScenario.java +++ b/core/tests/coretests/src/android/util/ScrollViewScenario.java @@ -239,7 +239,7 @@ public abstract class ScrollViewScenario extends Activity { // 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 e465a859218ac..3038e79abd72f 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 @@ public class BigCache extends Activity { 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 039387c85b11c..46e55faae8b63 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 androidx.test.espresso.matcher.ViewMatchers.withId; 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 @@ public class ScaleGestureDetectorTest { // 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 fa6886075bfd0..74524bf6d76f4 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 android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; 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 @@ public class WindowMetricsTest { 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 d5825e20163cc..4bd9ccd8d4d36 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 @@ public class ContextMenuTest extends ActivityInstrumentationTestCase 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 d4eb2a9c75d0f..a2da23e918d21 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.ComponentName; 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 @@ public class FakeApp extends Application { } 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 df00eee63b50e..e2120f80f1c97 100644 --- a/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java +++ b/packages/FakeOemFeatures/src/com/android/fakeoemfeatures/FakeBackgroundService.java @@ -19,22 +19,22 @@ package com.android.fakeoemfeatures; 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 mAllocs = new ArrayList(); @@ -99,8 +99,8 @@ public class FakeBackgroundService extends Service { // 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 6112da5cd13b6..fe9f60fe2859c 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.net.Uri; 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 @@ public class WallpaperCropActivity extends Activity { // 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 bb4e00ba1ef90..f2f0be73c0109 100644 --- a/test-runner/src/android/test/TouchUtils.java +++ b/test-runner/src/android/test/TouchUtils.java @@ -223,7 +223,7 @@ public class TouchUtils { 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 e255ce234c657..31532a2268001 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.graphics.Rect; 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 @@ public class MirrorSurfaceActivity extends Activity implements View.OnClickListe .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);