Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37c6cf93 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Rotate cutout to ROTATION_0 when getting metrics for natural rotation

The method getPossibleMaximumWindowMetrics() is to let the launcher get
possible display info for different device states. It is expected to
have everything in natural rotation for each device state. All other
fields such as bounds, are rotated.

The DisplayCutout was not rotated as it was always the same across all
rotations. With movable cutout effort, extra rotation is needed to make
sure it always get the natural rotation result.

Test: See verify steps in b/321914205
Bug: 321914205
Bug: 302387383
Change-Id: Ibd7d300b3138714b6d60b6a34a16a9020962ae68
parent f73c4e37
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.window;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.view.Surface.ROTATION_0;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;

@@ -31,6 +32,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.InsetsState;
import android.view.WindowInsets;
@@ -157,10 +159,15 @@ public final class WindowMetricsController {
                    new Rect(0, 0, currentDisplayInfo.getNaturalWidth(),
                            currentDisplayInfo.getNaturalHeight()), isScreenRound,
                    ACTIVITY_TYPE_UNDEFINED);
            // Set the hardware-provided insets.
            // Set the hardware-provided insets. Always with the ROTATION_0 result.
            DisplayCutout cutout = currentDisplayInfo.displayCutout;
            if (cutout != null && currentDisplayInfo.rotation != ROTATION_0) {
                cutout = cutout.getRotated(
                        currentDisplayInfo.logicalWidth, currentDisplayInfo.logicalHeight,
                        currentDisplayInfo.rotation, ROTATION_0);
            }
            windowInsets = new WindowInsets.Builder(windowInsets).setRoundedCorners(
                            currentDisplayInfo.roundedCorners)
                    .setDisplayCutout(currentDisplayInfo.displayCutout).build();
                    currentDisplayInfo.roundedCorners).setDisplayCutout(cutout).build();

            // Multiply default density scale because WindowMetrics provide the density value with
            // the scaling factor for the Density Independent Pixel unit, which is the same unit