diff options
author | Andrii Kulian <akulian@google.com> | 2020-03-27 01:08:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-27 01:08:37 +0000 |
commit | 363edf449a20f7a2568ac19fa2f169debda85f79 (patch) | |
tree | e7176531a086b3daadfc0f05a8f618a191c3178e | |
parent | 9dd6ba8bdf741452bd70abf145e43af66102b999 (diff) | |
parent | 0be1d67b681982e20f87359a810ba6c94e438378 (diff) |
Merge "Report bounds instead of size in WindowMetrics" into rvc-dev
25 files changed, 84 insertions, 94 deletions
diff --git a/api/current.txt b/api/current.txt index fb6f6a92244b..b5e4798f0891 100644 --- a/api/current.txt +++ b/api/current.txt @@ -55766,8 +55766,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 6daded4ee641..782fff2f69e0 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; @@ -1480,8 +1479,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 dffcafe1de0e..0ccb1e055c46 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -57,8 +57,8 @@ import java.util.List; * <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 @@ 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 { * </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 04260c47eda3..4bea623716dc 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 8bf1ade876ca..316a5f2c88d2 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 ab5a06eb99de..86ef87997a07 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}. * <p> * 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. * <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 @@ public final class WindowMetrics { * </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 8d3dc83bca0c..2ead352fd199 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 0aeaa47ba3d8..980943ebea5a 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 79b803a0cda6..0cd0643ee8c0 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 4809a213ab48..e7ee1cd59c7c 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 d4e5a438d855..74dc4b4b34a1 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 2c0aa7362dfa..ab1a642a9327 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 e465a859218a..3038e79abd72 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 039387c85b11..46e55faae8b6 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 fa6886075bfd..74524bf6d76f 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 d5825e20163c..4bd9ccd8d4d3 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<ContextMenu */ 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 8e90a824c873..d51cc328e4fb 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 @@ public class ListOfInternalSelectionViews extends Activity { 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 fd1dbfc63708..5cedd13533e7 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 @@ public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrum 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 e6195b147045..5cca766e1b1e 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 @@ public class AdjacentListsWithAdjacentISVsInside extends Activity { 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 25220951dd7b..daeb731ad457 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 class CameraTestUtils extends Assert { } 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 d4eb2a9c75d0..a2da23e918d2 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 df00eee63b50..e2120f80f1c9 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<int[]> mAllocs = new ArrayList<int[]>(); @@ -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 6112da5cd13b..fe9f60fe2859 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 bb4e00ba1ef9..f2f0be73c010 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 e255ce234c65..31532a226800 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); |