diff options
Diffstat (limited to 'core/java/android/view/Display.java')
| -rw-r--r-- | core/java/android/view/Display.java | 80 |
1 files changed, 26 insertions, 54 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 8de8be8c2040..c664ccba4ca7 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -25,8 +25,8 @@ import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.TestApi; import android.app.KeyguardManager; -import android.app.WindowConfiguration; import android.compat.annotation.UnsupportedAppUsage; +import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; @@ -59,8 +59,12 @@ import java.util.List; * 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#getBounds()} to query the - * application window bounds. Generally, use {@link WindowManager#getCurrentWindowMetrics()} to - * query the metrics and perform UI-related actions.</li> + * 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 + * using (adb shell wm size). Use the following methods to query the + * real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li> * </ul> * </p><p> * A logical display does not necessarily represent a particular physical display device @@ -673,9 +677,9 @@ public final class Display { @UnsupportedAppUsage public DisplayAdjustments getDisplayAdjustments() { if (mResources != null) { - final DisplayAdjustments currentAdjustments = mResources.getDisplayAdjustments(); - if (!mDisplayAdjustments.equals(currentAdjustments)) { - mDisplayAdjustments = new DisplayAdjustments(currentAdjustments); + final DisplayAdjustments currentAdjustements = mResources.getDisplayAdjustments(); + if (!mDisplayAdjustments.equals(currentAdjustements)) { + mDisplayAdjustments = new DisplayAdjustments(currentAdjustements); } } @@ -1187,34 +1191,30 @@ public final class Display { } /** - * Provides the largest {@link Point outSize} an app may expect in the current system state, - * without subtracting any window decor. + * Gets the real size of the display without subtracting any window decor or + * applying any compatibility scale factors. * <p> - * The size describes the largest potential area the window might occupy. The size is adjusted - * based on the current rotation of the 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 wm size). - * </p> + * </p><p> + * In general, {@link #getRealSize(Point)} and {@link WindowManager#getMaximumWindowMetrics()} + * report the same bounds except that certain areas of the display may not be available to + * windows created in the {@link WindowManager}'s {@link Context}. + * + * For example, imagine a device which has a multi-task mode that limits windows to half of the + * screen. In this case, {@link WindowManager#getMaximumWindowMetrics()} reports the + * bounds of the screen half where the window is located, while {@link #getRealSize(Point)} + * still reports the bounds of the whole display. * * @param outSize Set to the real size of the display. + * + * @see WindowManager#getMaximumWindowMetrics() */ public void getRealSize(Point outSize) { synchronized (this) { updateDisplayInfoLocked(); - if (shouldReportMaxBounds()) { - final Rect bounds = mResources.getConfiguration() - .windowConfiguration.getMaxBounds(); - outSize.x = bounds.width(); - outSize.y = bounds.height(); - if (DEBUG) { - Log.d(TAG, "getRealSize determined from max bounds: " + outSize - + " for uid " + Process.myUid()); - } - // Skip adjusting by fixed rotation, since if it is necessary, the configuration - // should already reflect the expected rotation. - return; - } outSize.x = mDisplayInfo.logicalWidth; outSize.y = mDisplayInfo.logicalHeight; if (mMayAdjustByFixedRotation) { @@ -1224,11 +1224,9 @@ public final class Display { } /** - * Provides the largest {@link DisplayMetrics outMetrics} an app may expect in the current - * system state, without subtracting any window decor. + * Gets display metrics based on the real size of this display. * <p> - * The size describes the largest potential area the window might occupy. The size is adjusted - * based on the current rotation of the 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 wm size). @@ -1239,18 +1237,6 @@ public final class Display { public void getRealMetrics(DisplayMetrics outMetrics) { synchronized (this) { updateDisplayInfoLocked(); - if (shouldReportMaxBounds()) { - mDisplayInfo.getMaxBoundsMetrics(outMetrics, - CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, - mResources.getConfiguration()); - if (DEBUG) { - Log.d(TAG, "getRealMetrics determined from max bounds: " + outMetrics - + " for uid " + Process.myUid()); - } - // Skip adjusting by fixed rotation, since if it is necessary, the configuration - // should already reflect the expected rotation. - return; - } mDisplayInfo.getLogicalMetrics(outMetrics, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); if (mMayAdjustByFixedRotation) { @@ -1260,20 +1246,6 @@ public final class Display { } /** - * Determines if {@link WindowConfiguration#getMaxBounds()} should be reported as the - * display dimensions. The max bounds field may be smaller than the logical dimensions - * when apps need to be sandboxed. - * @return {@code true} when max bounds should be applied. - */ - private boolean shouldReportMaxBounds() { - if (mResources == null) { - return false; - } - final Configuration config = mResources.getConfiguration(); - return config != null && !config.windowConfiguration.getMaxBounds().isEmpty(); - } - - /** * Gets the state of the display, such as whether it is on or off. * * @return The state of the display: one of {@link #STATE_OFF}, {@link #STATE_ON}, |
