diff options
| author | Andrii Kulian <akulian@google.com> | 2016-03-11 11:52:22 -0800 |
|---|---|---|
| committer | Andrii Kulian <akulian@google.com> | 2016-03-11 15:40:53 -0800 |
| commit | a4bb9d3f527663862bcc2abc1cd81489bfc6754e (patch) | |
| tree | f273406beb72c791926bdc10a7139fd6e78d2fb0 /core/java/android/view/Display.java | |
| parent | 093889409b011b9ace3c188c311e3d63583038cd (diff) | |
Update Display#getRealMetrics() behaviour
Update behaviour of the method to actually return real size of the
display independent of current configuration.
Bug: 27548818
Bug: 26986895
Change-Id: I64ba65f305801d97d30aed1c9a6cf6881c94ceda
Diffstat (limited to 'core/java/android/view/Display.java')
| -rw-r--r-- | core/java/android/view/Display.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 1269ad93d306..fb6a9d552c54 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -762,14 +762,23 @@ public final class Display { /** * Gets display metrics that describe the size and density of this display. + * The size returned by this method does not necessarily represent the + * actual raw size (native resolution) of the display. * <p> - * The size is adjusted based on the current rotation of the display. + * 1. The returned size may be adjusted to exclude certain system decor elements + * that are always visible. * </p><p> - * The size returned by this method does not necessarily represent the - * actual raw size (native resolution) of the display. The returned size may - * be adjusted to exclude certain system decor elements that are always visible. - * It may also be scaled to provide compatibility with older applications that + * 2. It may be scaled to provide compatibility with older applications that * were originally designed for smaller displays. + * </p><p> + * 3. It can be different depending on the WindowManager to which the display belongs. + * <pre> + * - If requested from non-Activity context (e.g. Application context via + * {@code (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)}) + * metrics will report real size of the display based on current rotation. + * - If requested from activity resulting metrics will correspond to current window metrics. + * In this case the size can be smaller than physical size in multi-window mode. + * </pre> * </p> * * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. @@ -807,7 +816,7 @@ public final class Display { * The size is adjusted based on the current rotation of the display. * </p><p> * The real size may be smaller than the physical size of the screen when the - * window manager is emulating a smaller display (using adb shell am display-size). + * window manager is emulating a smaller display (using adb shell wm size). * </p> * * @param outMetrics A {@link DisplayMetrics} object to receive the metrics. @@ -816,8 +825,7 @@ public final class Display { synchronized (this) { updateDisplayInfoLocked(); mDisplayInfo.getLogicalMetrics(outMetrics, - CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, - mDisplayAdjustments.getConfiguration()); + CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); } } |
