diff options
| author | Naomi Musgrave <nmusgrave@google.com> | 2021-10-05 13:38:18 +0100 |
|---|---|---|
| committer | Naomi Musgrave <nmusgrave@google.com> | 2021-10-14 07:57:39 +0000 |
| commit | a77d7425a41f4fe28a27a2b25ceef80d71df8048 (patch) | |
| tree | a0f4a2e4e2163c3fd6ff3609d406cd09567c796b /core/java/android/view/WindowManagerImpl.java | |
| parent | b4fabe9b087e767e9272ca572d7e9fbff28824a1 (diff) | |
PossibleMaximumWindowMetrics reports physical display insets for each
DisplayInfo (current and non-current display)
Changes behaviour from dumbly applying the insets of the current
DisplayInfo to all other DisplayInfo, to reading the insets of each
DisplayInfo into WindowMetrics. Additionally, applies the appropriate
rotation to the insets of each DisplayInfo, so the WindowMetrics
contain the correctly-rotated insets.
Bug: 201546646
Test: Manual
Change-Id: I5756a768b7544939d55d5759f838b27278ca1da6
Diffstat (limited to 'core/java/android/view/WindowManagerImpl.java')
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 7631269d9c1c..1c915cb016d4 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -352,25 +352,11 @@ public final class WindowManagerImpl implements WindowManager { throw e.rethrowFromSystemServer(); } - int size = possibleDisplayInfos.size(); - DisplayInfo currentDisplayInfo; - WindowInsets windowInsets = null; - if (size > 0) { - currentDisplayInfo = possibleDisplayInfos.get(0); - - final WindowManager.LayoutParams params = new WindowManager.LayoutParams(); - final boolean isScreenRound = (currentDisplayInfo.flags & Display.FLAG_ROUND) != 0; - // TODO(181127261) not computing insets correctly - need to have underlying - // frame reflect the faked orientation. - windowInsets = getWindowInsetsFromServerForDisplay( - currentDisplayInfo.displayId, params, - new Rect(0, 0, currentDisplayInfo.getNaturalWidth(), - currentDisplayInfo.getNaturalHeight()), isScreenRound, - WINDOWING_MODE_FULLSCREEN); - } - Set<WindowMetrics> maxMetrics = new HashSet<>(); - for (int i = 0; i < size; i++) { + WindowInsets windowInsets; + DisplayInfo currentDisplayInfo; + final WindowManager.LayoutParams params = new WindowManager.LayoutParams(); + for (int i = 0; i < possibleDisplayInfos.size(); i++) { currentDisplayInfo = possibleDisplayInfos.get(i); // Calculate max bounds for this rotation and state. @@ -378,7 +364,18 @@ public final class WindowManagerImpl implements WindowManager { currentDisplayInfo.logicalHeight); // Calculate insets for the rotated max bounds. - // TODO(181127261) calculate insets for each display rotation and state. + final boolean isScreenRound = (currentDisplayInfo.flags & Display.FLAG_ROUND) != 0; + // Initialize insets based upon display rotation. Note any window-provided insets + // will not be set. + windowInsets = getWindowInsetsFromServerForDisplay( + currentDisplayInfo.displayId, params, + new Rect(0, 0, currentDisplayInfo.getNaturalWidth(), + currentDisplayInfo.getNaturalHeight()), isScreenRound, + WINDOWING_MODE_FULLSCREEN); + // Set the hardware-provided insets. + windowInsets = new WindowInsets.Builder(windowInsets).setRoundedCorners( + currentDisplayInfo.roundedCorners) + .setDisplayCutout(currentDisplayInfo.displayCutout).build(); maxMetrics.add(new WindowMetrics(maxBounds, windowInsets)); } |
