diff options
| author | Andrii Kulian <akulian@google.com> | 2020-01-28 21:00:09 -0800 |
|---|---|---|
| committer | Andrii Kulian <akulian@google.com> | 2020-01-28 21:00:09 -0800 |
| commit | 0271e57bfee4b45673c8de3bbce7bef3194f9355 (patch) | |
| tree | 9583966db7859744e1e59a96687fb65a94237d6e /core/java/android/view/Display.java | |
| parent | 9652ad951405498f1b2c5a305342d7c569b7c292 (diff) | |
Deprecate Display#getSize/RectSize/Metrics
Applications should use WindowMetrics obtained from visual contexts
for UI-related inquiries.
Bug: 128338354
Test: Build, auto test
Change-Id: I685ed4db93c25a05b1f2188e399767d33e5d1a49
Diffstat (limited to 'core/java/android/view/Display.java')
| -rw-r--r-- | core/java/android/view/Display.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 0304328f734a..d79fc9a48116 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 the following methods to query the - * application display area: {@link #getSize}, {@link #getRectSize} and {@link #getMetrics}.</li> + * for decor elements such as the status bar. Use {@link WindowMetrics#getSize()} to query the + * application window size.</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 @@ -97,7 +97,7 @@ public final class Display { // We cache the app width and height properties briefly between calls // to getHeight() and getWidth() to ensure that applications perceive // consistent results when the size changes (most of the time). - // Applications should now be using getSize() instead. + // Applications should now be using WindowMetrics instead. private static final int CACHED_APP_SIZE_DURATION_MILLIS = 20; private long mLastCachedAppSizeUpdate; private int mCachedAppWidthCompat; @@ -674,7 +674,10 @@ public final class Display { * </p> * * @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. */ + @Deprecated public void getSize(Point outSize) { synchronized (this) { updateDisplayInfoLocked(); @@ -688,8 +691,10 @@ 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. - * @see #getSize(Point) + * @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application + * window area. */ + @Deprecated public void getRectSize(Rect outSize) { synchronized (this) { updateDisplayInfoLocked(); @@ -752,7 +757,7 @@ public final class Display { } /** - * @deprecated Use {@link #getSize(Point)} instead. + * @deprecated Use {@link WindowMetrics#getSize()} instead. */ @Deprecated public int getWidth() { @@ -763,7 +768,7 @@ public final class Display { } /** - * @deprecated Use {@link #getSize(Point)} instead. + * @deprecated Use {@link WindowMetrics#getSize()} instead. */ @Deprecated public int getHeight() { @@ -1102,7 +1107,10 @@ 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 + * window area, and {@link Configuration#densityDpi} to get the current density. */ + @Deprecated public void getMetrics(DisplayMetrics outMetrics) { synchronized (this) { updateDisplayInfoLocked(); |
