From a4bb9d3f527663862bcc2abc1cd81489bfc6754e Mon Sep 17 00:00:00 2001
From: Andrii Kulian
- * The size is adjusted based on the current rotation of the display.
- *
* 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
+ * actual raw size (native resolution) of the display.
+ *
+ * 1. The returned size may be adjusted to exclude certain system decor elements
+ * that are always visible.
+ *
+ * 2. It may be scaled to provide compatibility with older applications that
* were originally designed for smaller displays.
+ *
+ * 3. It can be different depending on the WindowManager to which the display belongs.
+ *
+ * - 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.
+ *
*
* 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). *
* * @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); } }