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

Commit bcf67744 authored by Yunfan Chen's avatar Yunfan Chen Committed by Android (Google) Code Review
Browse files

Merge "Rotate Display Cutout for Status Bar with Cutout Util" into main

parents 5ca74cb3 e62275b1
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ package com.android.internal.policy;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Insets;
import android.util.RotationUtils;
import android.view.Display;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.Surface;

import com.android.internal.R;
@@ -56,21 +57,21 @@ public final class SystemBarUtils {
     */
    public static int getStatusBarHeightForRotation(
            Context context, @Surface.Rotation int targetRot) {
        final int rotation = context.getDisplay().getRotation();
        final DisplayCutout cutout = context.getDisplay().getCutout();

        Insets insets = cutout == null ? Insets.NONE : Insets.of(cutout.getSafeInsets());
        Insets waterfallInsets = cutout == null ? Insets.NONE : cutout.getWaterfallInsets();
        // rotate insets to target rotation if needed.
        if (rotation != targetRot) {
            if (!insets.equals(Insets.NONE)) {
                insets = RotationUtils.rotateInsets(
                        insets, RotationUtils.deltaRotation(rotation, targetRot));
            }
            if (!waterfallInsets.equals(Insets.NONE)) {
                waterfallInsets = RotationUtils.rotateInsets(
                        waterfallInsets, RotationUtils.deltaRotation(rotation, targetRot));
            }
        final Display display = context.getDisplay();
        final int rotation = display.getRotation();
        final DisplayCutout cutout = display.getCutout();
        DisplayInfo info = new DisplayInfo();
        display.getDisplayInfo(info);
        Insets insets;
        Insets waterfallInsets;
        if (cutout == null) {
            insets = Insets.NONE;
            waterfallInsets = Insets.NONE;
        } else {
            DisplayCutout rotated =
                    cutout.getRotated(info.logicalWidth, info.logicalHeight, rotation, targetRot);
            insets = Insets.of(rotated.getSafeInsets());
            waterfallInsets = rotated.getWaterfallInsets();
        }
        final int defaultSize =
                context.getResources().getDimensionPixelSize(R.dimen.status_bar_height_default);