Revert "Update display contents when metrics change"
This reverts commit eddb7c0985e1fac8bdbeaaed40c678c0dc9da321.
Reason for revert: b/36518752
Bug: 36518752
Change-Id: I39773db7b8d02aec360ca80d02b3c161ccf02786
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 6dedbde..5494377 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -50,7 +50,7 @@
* <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
+ * using (adb shell am display-size). Use the following methods to query the
* real display area: {@link #getRealSize}, {@link #getRealMetrics}.</li>
* </ul>
* </p><p>
@@ -947,7 +947,7 @@
* 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).
+ * window manager is emulating a smaller display (using adb shell am display-size).
* </p>
*
* @param outSize Set to the real size of the display.
diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java
index f9bc12b..a947b41 100644
--- a/services/core/java/com/android/server/display/LogicalDisplay.java
+++ b/services/core/java/com/android/server/display/LogicalDisplay.java
@@ -62,18 +62,7 @@
private final int mDisplayId;
private final int mLayerStack;
- /**
- * Override information set by the window manager. Will be reported instead of {@link #mInfo}
- * if not null.
- * @see #setDisplayInfoOverrideFromWindowManagerLocked(DisplayInfo)
- * @see #getDisplayInfoLocked()
- */
- private DisplayInfo mOverrideDisplayInfo;
- /**
- * Current display info. Initialized with {@link #mBaseDisplayInfo}. Set to {@code null} if
- * needs to be updated.
- * @see #getDisplayInfoLocked()
- */
+ private DisplayInfo mOverrideDisplayInfo; // set by the window manager
private DisplayInfo mInfo;
// The display device that this logical display is based on and which
@@ -272,9 +261,6 @@
mPrimaryDisplayDeviceInfo = deviceInfo;
mInfo = null;
- // Make sure that WM will be notified of new changes. It will then decide whether to
- // apply them or not and will set the value again.
- mOverrideDisplayInfo = null;
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 01a992f..e5b00f3 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -179,23 +179,11 @@
// Mapping from a token IBinder to a WindowToken object on this display.
private final HashMap<IBinder, WindowToken> mTokenMap = new HashMap();
- // Initial display metrics.
int mInitialDisplayWidth = 0;
int mInitialDisplayHeight = 0;
int mInitialDisplayDensity = 0;
-
- /**
- * Overridden display size. Initialized with {@link #mInitialDisplayWidth}
- * and {@link #mInitialDisplayHeight}, but can be set via shell command "adb shell wm size".
- * @see WindowManagerService#setForcedDisplaySize(int, int, int)
- */
int mBaseDisplayWidth = 0;
int mBaseDisplayHeight = 0;
- /**
- * Overridden display density for current user. Initialized with {@link #mInitialDisplayDensity}
- * but can be set from Settings or via shell command "adb shell wm density".
- * @see WindowManagerService#setForcedDisplayDensityForUser(int, int, int)
- */
int mBaseDisplayDensity = 0;
boolean mDisplayScalingDisabled;
private final DisplayInfo mDisplayInfo = new DisplayInfo();
@@ -1523,10 +1511,6 @@
void updateDisplayInfo() {
mDisplay.getDisplayInfo(mDisplayInfo);
mDisplay.getMetrics(mDisplayMetrics);
-
- // Check if display metrics changed and update base values if needed.
- updateBaseDisplayMetricsIfNeeded();
-
for (int i = mTaskStackContainers.size() - 1; i >= 0; --i) {
mTaskStackContainers.get(i).updateDisplayInfo(null);
}
@@ -1542,11 +1526,10 @@
}
}
- updateBaseDisplayMetrics(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight,
- mDisplayInfo.logicalDensityDpi);
- mInitialDisplayWidth = mDisplayInfo.logicalWidth;
- mInitialDisplayHeight = mDisplayInfo.logicalHeight;
- mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
+ mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth;
+ mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight;
+ mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
+ mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
}
void getLogicalDisplayRect(Rect out) {
@@ -1576,50 +1559,6 @@
}
}
- /**
- * If display metrics changed, overrides are not set and it's not just a rotation - update base
- * values.
- */
- private void updateBaseDisplayMetricsIfNeeded() {
- final int orientation = mDisplayInfo.rotation;
- final boolean rotated = (orientation == ROTATION_90 || orientation == ROTATION_270);
- final int newWidth = rotated ? mDisplayInfo.logicalHeight : mDisplayInfo.logicalWidth;
- final int newHeight = rotated ? mDisplayInfo.logicalWidth : mDisplayInfo.logicalHeight;
- int density = mDisplayInfo.logicalDensityDpi;
-
- boolean displayMetricsChanged = false;
-
- // Check if display size is not forced and changed in new display info.
- boolean isDisplaySizeForced = mBaseDisplayWidth != mInitialDisplayWidth
- || mBaseDisplayHeight != mInitialDisplayHeight;
- if (!isDisplaySizeForced) {
- displayMetricsChanged = mBaseDisplayWidth != newWidth
- || mBaseDisplayHeight != newHeight;
- }
-
- // Check if display density is not forced and changed in new display info.
- final int forcedDensity = mBaseDisplayDensity != mInitialDisplayDensity
- ? mBaseDisplayDensity : 0;
- if (forcedDensity != 0) {
- density = forcedDensity;
- } else {
- displayMetricsChanged |= mBaseDisplayDensity != mDisplayInfo.logicalDensityDpi;
- }
-
- if (displayMetricsChanged) {
- updateBaseDisplayMetrics(newWidth, newHeight, density);
- mService.reconfigureDisplayLocked(this);
- }
- }
-
- /** Update base (override) display metrics. */
- void updateBaseDisplayMetrics(int baseWidth, int baseHeight, int baseDensity) {
- mBaseDisplayWidth = baseWidth;
- mBaseDisplayHeight = baseHeight;
- mBaseDisplayDensity = baseDensity;
- mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
- }
-
void getContentRect(Rect out) {
out.set(mContentRect);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 082491d..7539cd4 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5324,8 +5324,8 @@
if (displayContent.mBaseDisplayWidth != width
|| displayContent.mBaseDisplayHeight != height) {
Slog.i(TAG_WM, "FORCED DISPLAY SIZE: " + width + "x" + height);
- displayContent.updateBaseDisplayMetrics(width, height,
- displayContent.mBaseDisplayDensity);
+ displayContent.mBaseDisplayWidth = width;
+ displayContent.mBaseDisplayHeight = height;
}
} catch (NumberFormatException ex) {
}
@@ -5350,7 +5350,8 @@
// displayContent must not be null
private void setForcedDisplaySizeLocked(DisplayContent displayContent, int width, int height) {
Slog.i(TAG_WM, "Using new display size: " + width + "x" + height);
- displayContent.updateBaseDisplayMetrics(width, height, displayContent.mBaseDisplayDensity);
+ displayContent.mBaseDisplayWidth = width;
+ displayContent.mBaseDisplayHeight = height;
reconfigureDisplayLocked(displayContent);
}