Loading quickstep/src/com/android/quickstep/util/SystemWindowManagerProxy.java +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.view.Display.DEFAULT_DISPLAY; import android.content.Context; import android.graphics.Rect; import android.util.ArrayMap; import android.view.DisplayCutout; import android.view.Surface; import android.view.WindowManager; import android.view.WindowMetrics; Loading Loading @@ -74,4 +75,10 @@ public class SystemWindowManagerProxy extends WindowManagerProxy { } return result; } @Override protected DisplayCutout rotateCutout(DisplayCutout original, int startWidth, int startHeight, int fromRotation, int toRotation) { return original.getRotated(startWidth, startHeight, fromRotation, toRotation); } } quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -163,8 +163,7 @@ public class TaskViewSimulatorTest { helper.sandboxContext.allow(SystemUiProxy.INSTANCE); int rotation = mDisplaySize.x > mDisplaySize.y ? Surface.ROTATION_90 : Surface.ROTATION_0; CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation, new Rect()); CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation); WindowBounds wm = new WindowBounds( new Rect(0, 0, mDisplaySize.x, mDisplaySize.y), mDisplayInsets); Loading @@ -186,7 +185,7 @@ public class TaskViewSimulatorTest { ArrayMap<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache = new ArrayMap<>(); perDisplayBoundsCache.put(cdi.normalize(), allBounds); perDisplayBoundsCache.put(cdi.normalize(wmProxy), allBounds); Configuration configuration = new Configuration(); configuration.densityDpi = mDensityDpi; Loading src/com/android/launcher3/util/DisplayController.java +2 −2 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { WindowManagerProxy wmProxy, Map<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache) { CachedDisplayInfo displayInfo = wmProxy.getDisplayInfo(displayInfoContext); normalizedDisplayInfo = displayInfo.normalize(); normalizedDisplayInfo = displayInfo.normalize(wmProxy); rotation = displayInfo.rotation; currentSize = displayInfo.size; cutout = displayInfo.cutout; cutout = WindowManagerProxy.getSafeInsets(displayInfo.cutout); Configuration config = displayInfoContext.getResources().getConfiguration(); fontScale = config.fontScale; Loading src/com/android/launcher3/util/window/CachedDisplayInfo.java +23 −11 Original line number Diff line number Diff line Loading @@ -16,13 +16,16 @@ package com.android.launcher3.util.window; import static com.android.launcher3.util.RotationUtils.deltaRotation; import static com.android.launcher3.util.RotationUtils.rotateRect; import static com.android.launcher3.util.RotationUtils.rotateSize; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; import android.view.DisplayCutout; import android.view.Surface; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Objects; /** Loading @@ -30,36 +33,40 @@ import java.util.Objects; */ public class CachedDisplayInfo { private static final DisplayCutout NO_CUTOUT = new DisplayCutout(Insets.NONE, null, null, null, null); public final Point size; public final int rotation; public final Rect cutout; @NonNull public final DisplayCutout cutout; public CachedDisplayInfo() { this(new Point(0, 0), 0); } public CachedDisplayInfo(Point size, int rotation) { this(size, rotation, new Rect()); this(size, rotation, NO_CUTOUT); } public CachedDisplayInfo(Point size, int rotation, Rect cutout) { public CachedDisplayInfo(Point size, int rotation, @Nullable DisplayCutout cutout) { this.size = size; this.rotation = rotation; this.cutout = cutout; this.cutout = cutout == null ? NO_CUTOUT : cutout; } /** * Returns a CachedDisplayInfo where the properties are normalized to {@link Surface#ROTATION_0} */ public CachedDisplayInfo normalize() { public CachedDisplayInfo normalize(WindowManagerProxy windowManagerProxy) { if (rotation == Surface.ROTATION_0) { return this; } Point newSize = new Point(size); rotateSize(newSize, deltaRotation(rotation, Surface.ROTATION_0)); Rect newCutout = new Rect(cutout); rotateRect(newCutout, deltaRotation(rotation, Surface.ROTATION_0)); DisplayCutout newCutout = windowManagerProxy.rotateCutout( cutout, size.x, size.y, rotation, Surface.ROTATION_0); return new CachedDisplayInfo(newSize, Surface.ROTATION_0, newCutout); } Loading @@ -79,11 +86,16 @@ public class CachedDisplayInfo { CachedDisplayInfo that = (CachedDisplayInfo) o; return rotation == that.rotation && Objects.equals(size, that.size) && Objects.equals(cutout, that.cutout); && cutout.getSafeInsetLeft() == that.cutout.getSafeInsetLeft() && cutout.getSafeInsetTop() == that.cutout.getSafeInsetTop() && cutout.getSafeInsetRight() == that.cutout.getSafeInsetRight() && cutout.getSafeInsetBottom() == that.cutout.getSafeInsetBottom(); } @Override public int hashCode() { return Objects.hash(size, rotation, cutout); return Objects.hash(size, rotation, cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } } src/com/android/launcher3/util/window/WindowManagerProxy.java +27 −15 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { */ public ArrayMap<CachedDisplayInfo, List<WindowBounds>> estimateInternalDisplayBounds( Context displayInfoContext) { CachedDisplayInfo info = getDisplayInfo(displayInfoContext).normalize(); CachedDisplayInfo info = getDisplayInfo(displayInfoContext).normalize(this); List<WindowBounds> bounds = estimateWindowBounds(displayInfoContext, info); ArrayMap<CachedDisplayInfo, List<WindowBounds>> result = new ArrayMap<>(); result.put(info, bounds); Loading Loading @@ -186,10 +186,9 @@ public class WindowManagerProxy implements ResourceBasedOverride { * Returns a list of possible WindowBounds for the display keyed on the 4 surface rotations */ protected List<WindowBounds> estimateWindowBounds(Context context, CachedDisplayInfo displayInfo) { final CachedDisplayInfo displayInfo) { int densityDpi = context.getResources().getConfiguration().densityDpi; int rotation = displayInfo.rotation; Rect safeCutout = displayInfo.cutout; final int rotation = displayInfo.rotation; int minSize = Math.min(displayInfo.size.x, displayInfo.size.y); int swDp = (int) dpiFromPx(minSize, densityDpi); Loading Loading @@ -247,8 +246,9 @@ public class WindowManagerProxy implements ResourceBasedOverride { statusBarHeight = statusBarHeightLandscape; } Rect insets = new Rect(safeCutout); rotateRect(insets, rotationChange); DisplayCutout rotatedCutout = rotateCutout( displayInfo.cutout, displayInfo.size.x, displayInfo.size.y, rotation, i); Rect insets = getSafeInsets(rotatedCutout); insets.top = Math.max(insets.top, statusBarHeight); insets.bottom = Math.max(insets.bottom, navBarHeight); Loading Loading @@ -298,8 +298,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { Point size = new Point(); Display display = getDisplay(displayInfoContext); display.getRealSize(size); Rect cutoutRect = new Rect(); return new CachedDisplayInfo(size, rotation, cutoutRect); return new CachedDisplayInfo(size, rotation); } } Loading @@ -309,13 +308,8 @@ public class WindowManagerProxy implements ResourceBasedOverride { @TargetApi(Build.VERSION_CODES.S) protected CachedDisplayInfo getDisplayInfo(WindowMetrics windowMetrics, int rotation) { Point size = new Point(windowMetrics.getBounds().right, windowMetrics.getBounds().bottom); Rect cutoutRect = new Rect(); DisplayCutout cutout = windowMetrics.getWindowInsets().getDisplayCutout(); if (cutout != null) { cutoutRect.set(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } return new CachedDisplayInfo(size, rotation, cutoutRect); return new CachedDisplayInfo(size, rotation, windowMetrics.getWindowInsets().getDisplayCutout()); } /** Loading Loading @@ -354,6 +348,16 @@ public class WindowManagerProxy implements ResourceBasedOverride { DEFAULT_DISPLAY); } /** * Returns a DisplayCutout which represents a rotated version of the original */ protected DisplayCutout rotateCutout(DisplayCutout original, int startWidth, int startHeight, int fromRotation, int toRotation) { Rect safeCutout = getSafeInsets(original); rotateRect(safeCutout, deltaRotation(fromRotation, toRotation)); return new DisplayCutout(Insets.of(safeCutout), null, null, null, null); } /** * Returns the current navigation mode from resource. */ Loading @@ -373,4 +377,12 @@ public class WindowManagerProxy implements ResourceBasedOverride { return Utilities.ATLEAST_S ? NavigationMode.NO_BUTTON : NavigationMode.THREE_BUTTONS; } /** * @see DisplayCutout#getSafeInsets */ public static Rect getSafeInsets(DisplayCutout cutout) { return new Rect(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } } Loading
quickstep/src/com/android/quickstep/util/SystemWindowManagerProxy.java +7 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.view.Display.DEFAULT_DISPLAY; import android.content.Context; import android.graphics.Rect; import android.util.ArrayMap; import android.view.DisplayCutout; import android.view.Surface; import android.view.WindowManager; import android.view.WindowMetrics; Loading Loading @@ -74,4 +75,10 @@ public class SystemWindowManagerProxy extends WindowManagerProxy { } return result; } @Override protected DisplayCutout rotateCutout(DisplayCutout original, int startWidth, int startHeight, int fromRotation, int toRotation) { return original.getRotated(startWidth, startHeight, fromRotation, toRotation); } }
quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -163,8 +163,7 @@ public class TaskViewSimulatorTest { helper.sandboxContext.allow(SystemUiProxy.INSTANCE); int rotation = mDisplaySize.x > mDisplaySize.y ? Surface.ROTATION_90 : Surface.ROTATION_0; CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation, new Rect()); CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation); WindowBounds wm = new WindowBounds( new Rect(0, 0, mDisplaySize.x, mDisplaySize.y), mDisplayInsets); Loading @@ -186,7 +185,7 @@ public class TaskViewSimulatorTest { ArrayMap<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache = new ArrayMap<>(); perDisplayBoundsCache.put(cdi.normalize(), allBounds); perDisplayBoundsCache.put(cdi.normalize(wmProxy), allBounds); Configuration configuration = new Configuration(); configuration.densityDpi = mDensityDpi; Loading
src/com/android/launcher3/util/DisplayController.java +2 −2 Original line number Diff line number Diff line Loading @@ -362,10 +362,10 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { WindowManagerProxy wmProxy, Map<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache) { CachedDisplayInfo displayInfo = wmProxy.getDisplayInfo(displayInfoContext); normalizedDisplayInfo = displayInfo.normalize(); normalizedDisplayInfo = displayInfo.normalize(wmProxy); rotation = displayInfo.rotation; currentSize = displayInfo.size; cutout = displayInfo.cutout; cutout = WindowManagerProxy.getSafeInsets(displayInfo.cutout); Configuration config = displayInfoContext.getResources().getConfiguration(); fontScale = config.fontScale; Loading
src/com/android/launcher3/util/window/CachedDisplayInfo.java +23 −11 Original line number Diff line number Diff line Loading @@ -16,13 +16,16 @@ package com.android.launcher3.util.window; import static com.android.launcher3.util.RotationUtils.deltaRotation; import static com.android.launcher3.util.RotationUtils.rotateRect; import static com.android.launcher3.util.RotationUtils.rotateSize; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; import android.view.DisplayCutout; import android.view.Surface; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.Objects; /** Loading @@ -30,36 +33,40 @@ import java.util.Objects; */ public class CachedDisplayInfo { private static final DisplayCutout NO_CUTOUT = new DisplayCutout(Insets.NONE, null, null, null, null); public final Point size; public final int rotation; public final Rect cutout; @NonNull public final DisplayCutout cutout; public CachedDisplayInfo() { this(new Point(0, 0), 0); } public CachedDisplayInfo(Point size, int rotation) { this(size, rotation, new Rect()); this(size, rotation, NO_CUTOUT); } public CachedDisplayInfo(Point size, int rotation, Rect cutout) { public CachedDisplayInfo(Point size, int rotation, @Nullable DisplayCutout cutout) { this.size = size; this.rotation = rotation; this.cutout = cutout; this.cutout = cutout == null ? NO_CUTOUT : cutout; } /** * Returns a CachedDisplayInfo where the properties are normalized to {@link Surface#ROTATION_0} */ public CachedDisplayInfo normalize() { public CachedDisplayInfo normalize(WindowManagerProxy windowManagerProxy) { if (rotation == Surface.ROTATION_0) { return this; } Point newSize = new Point(size); rotateSize(newSize, deltaRotation(rotation, Surface.ROTATION_0)); Rect newCutout = new Rect(cutout); rotateRect(newCutout, deltaRotation(rotation, Surface.ROTATION_0)); DisplayCutout newCutout = windowManagerProxy.rotateCutout( cutout, size.x, size.y, rotation, Surface.ROTATION_0); return new CachedDisplayInfo(newSize, Surface.ROTATION_0, newCutout); } Loading @@ -79,11 +86,16 @@ public class CachedDisplayInfo { CachedDisplayInfo that = (CachedDisplayInfo) o; return rotation == that.rotation && Objects.equals(size, that.size) && Objects.equals(cutout, that.cutout); && cutout.getSafeInsetLeft() == that.cutout.getSafeInsetLeft() && cutout.getSafeInsetTop() == that.cutout.getSafeInsetTop() && cutout.getSafeInsetRight() == that.cutout.getSafeInsetRight() && cutout.getSafeInsetBottom() == that.cutout.getSafeInsetBottom(); } @Override public int hashCode() { return Objects.hash(size, rotation, cutout); return Objects.hash(size, rotation, cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } }
src/com/android/launcher3/util/window/WindowManagerProxy.java +27 −15 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { */ public ArrayMap<CachedDisplayInfo, List<WindowBounds>> estimateInternalDisplayBounds( Context displayInfoContext) { CachedDisplayInfo info = getDisplayInfo(displayInfoContext).normalize(); CachedDisplayInfo info = getDisplayInfo(displayInfoContext).normalize(this); List<WindowBounds> bounds = estimateWindowBounds(displayInfoContext, info); ArrayMap<CachedDisplayInfo, List<WindowBounds>> result = new ArrayMap<>(); result.put(info, bounds); Loading Loading @@ -186,10 +186,9 @@ public class WindowManagerProxy implements ResourceBasedOverride { * Returns a list of possible WindowBounds for the display keyed on the 4 surface rotations */ protected List<WindowBounds> estimateWindowBounds(Context context, CachedDisplayInfo displayInfo) { final CachedDisplayInfo displayInfo) { int densityDpi = context.getResources().getConfiguration().densityDpi; int rotation = displayInfo.rotation; Rect safeCutout = displayInfo.cutout; final int rotation = displayInfo.rotation; int minSize = Math.min(displayInfo.size.x, displayInfo.size.y); int swDp = (int) dpiFromPx(minSize, densityDpi); Loading Loading @@ -247,8 +246,9 @@ public class WindowManagerProxy implements ResourceBasedOverride { statusBarHeight = statusBarHeightLandscape; } Rect insets = new Rect(safeCutout); rotateRect(insets, rotationChange); DisplayCutout rotatedCutout = rotateCutout( displayInfo.cutout, displayInfo.size.x, displayInfo.size.y, rotation, i); Rect insets = getSafeInsets(rotatedCutout); insets.top = Math.max(insets.top, statusBarHeight); insets.bottom = Math.max(insets.bottom, navBarHeight); Loading Loading @@ -298,8 +298,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { Point size = new Point(); Display display = getDisplay(displayInfoContext); display.getRealSize(size); Rect cutoutRect = new Rect(); return new CachedDisplayInfo(size, rotation, cutoutRect); return new CachedDisplayInfo(size, rotation); } } Loading @@ -309,13 +308,8 @@ public class WindowManagerProxy implements ResourceBasedOverride { @TargetApi(Build.VERSION_CODES.S) protected CachedDisplayInfo getDisplayInfo(WindowMetrics windowMetrics, int rotation) { Point size = new Point(windowMetrics.getBounds().right, windowMetrics.getBounds().bottom); Rect cutoutRect = new Rect(); DisplayCutout cutout = windowMetrics.getWindowInsets().getDisplayCutout(); if (cutout != null) { cutoutRect.set(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } return new CachedDisplayInfo(size, rotation, cutoutRect); return new CachedDisplayInfo(size, rotation, windowMetrics.getWindowInsets().getDisplayCutout()); } /** Loading Loading @@ -354,6 +348,16 @@ public class WindowManagerProxy implements ResourceBasedOverride { DEFAULT_DISPLAY); } /** * Returns a DisplayCutout which represents a rotated version of the original */ protected DisplayCutout rotateCutout(DisplayCutout original, int startWidth, int startHeight, int fromRotation, int toRotation) { Rect safeCutout = getSafeInsets(original); rotateRect(safeCutout, deltaRotation(fromRotation, toRotation)); return new DisplayCutout(Insets.of(safeCutout), null, null, null, null); } /** * Returns the current navigation mode from resource. */ Loading @@ -373,4 +377,12 @@ public class WindowManagerProxy implements ResourceBasedOverride { return Utilities.ATLEAST_S ? NavigationMode.NO_BUTTON : NavigationMode.THREE_BUTTONS; } /** * @see DisplayCutout#getSafeInsets */ public static Rect getSafeInsets(DisplayCutout cutout) { return new Rect(cutout.getSafeInsetLeft(), cutout.getSafeInsetTop(), cutout.getSafeInsetRight(), cutout.getSafeInsetBottom()); } }