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

Commit e6dc134a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Compare letterbox and bar content frame with the same rotation" into...

Merge "Compare letterbox and bar content frame with the same rotation" into rvc-dev am: 65ddf5fa am: d99d55fc am: 727468c9 am: e4ec90c6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11541407

Change-Id: Id975491251eaf9426d9e081de63a73bcd4a071dc
parents 86641795 e4ec90c6
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ public class BarController {
    private final int mTransparentFlag;
    private final int mTransparentFlag;
    private final int mStatusBarManagerId;
    private final int mStatusBarManagerId;
    private final int mTranslucentWmFlag;
    private final int mTranslucentWmFlag;
    private final int mWindowType;
    protected final Handler mHandler;
    protected final Handler mHandler;
    private final Object mServiceAquireLock = new Object();
    private final Object mServiceAquireLock = new Object();
    private StatusBarManagerInternal mStatusBarInternal;
    private StatusBarManagerInternal mStatusBarInternal;
@@ -77,13 +78,14 @@ public class BarController {
    private OnBarVisibilityChangedListener mVisibilityChangeListener;
    private OnBarVisibilityChangedListener mVisibilityChangeListener;


    BarController(String tag, int displayId, int transientFlag, int unhideFlag, int translucentFlag,
    BarController(String tag, int displayId, int transientFlag, int unhideFlag, int translucentFlag,
            int statusBarManagerId, int translucentWmFlag, int transparentFlag) {
            int statusBarManagerId, int windowType, int translucentWmFlag, int transparentFlag) {
        mTag = "BarController." + tag;
        mTag = "BarController." + tag;
        mDisplayId = displayId;
        mDisplayId = displayId;
        mTransientFlag = transientFlag;
        mTransientFlag = transientFlag;
        mUnhideFlag = unhideFlag;
        mUnhideFlag = unhideFlag;
        mTranslucentFlag = translucentFlag;
        mTranslucentFlag = translucentFlag;
        mStatusBarManagerId = statusBarManagerId;
        mStatusBarManagerId = statusBarManagerId;
        mWindowType = windowType;
        mTranslucentWmFlag = translucentWmFlag;
        mTranslucentWmFlag = translucentWmFlag;
        mTransparentFlag = transparentFlag;
        mTransparentFlag = transparentFlag;
        mHandler = new BarHandler();
        mHandler = new BarHandler();
@@ -168,7 +170,12 @@ public class BarController {
    }
    }


    boolean isTransparentAllowed(WindowState win) {
    boolean isTransparentAllowed(WindowState win) {
        return win == null || win.letterboxNotIntersectsOrFullyContains(mContentFrame);
        if (win == null) {
            return true;
        }
        final Rect rotatedContentFrame = win.mToken.getFixedRotationBarContentFrame(mWindowType);
        final Rect contentFrame = rotatedContentFrame != null ? rotatedContentFrame : mContentFrame;
        return win.letterboxNotIntersectsOrFullyContains(contentFrame);
    }
    }


    boolean setBarShowingLw(final boolean show) {
    boolean setBarShowingLw(final boolean show) {
+41 −23
Original line number Original line Diff line number Diff line
@@ -151,6 +151,7 @@ import android.util.IntArray;
import android.util.Pair;
import android.util.Pair;
import android.util.PrintWriterPrinter;
import android.util.PrintWriterPrinter;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayCutout;
import android.view.DisplayCutout;
import android.view.Gravity;
import android.view.Gravity;
import android.view.InputChannel;
import android.view.InputChannel;
@@ -199,6 +200,7 @@ import com.android.server.wallpaper.WallpaperManagerInternal;
import com.android.server.wm.utils.InsetUtils;
import com.android.server.wm.utils.InsetUtils;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.function.Consumer;


/**
/**
 * The policy that provides the basic behaviors and states of a display to show UI.
 * The policy that provides the basic behaviors and states of a display to show UI.
@@ -471,6 +473,7 @@ public class DisplayPolicy {
                View.NAVIGATION_BAR_UNHIDE,
                View.NAVIGATION_BAR_UNHIDE,
                View.NAVIGATION_BAR_TRANSLUCENT,
                View.NAVIGATION_BAR_TRANSLUCENT,
                StatusBarManager.WINDOW_NAVIGATION_BAR,
                StatusBarManager.WINDOW_NAVIGATION_BAR,
                TYPE_NAVIGATION_BAR,
                FLAG_TRANSLUCENT_NAVIGATION,
                FLAG_TRANSLUCENT_NAVIGATION,
                View.NAVIGATION_BAR_TRANSPARENT);
                View.NAVIGATION_BAR_TRANSPARENT);


@@ -1171,6 +1174,11 @@ public class DisplayPolicy {
                displayFrames.mDisplayCutoutSafe.top);
                displayFrames.mDisplayCutoutSafe.top);
    }
    }


    @VisibleForTesting
    StatusBarController getStatusBarController() {
        return mStatusBarController;
    }

    WindowState getStatusBar() {
    WindowState getStatusBar() {
        return mStatusBar;
        return mStatusBar;
    }
    }
@@ -1469,13 +1477,16 @@ public class DisplayPolicy {
    }
    }


    private void simulateLayoutDecorWindow(WindowState win, DisplayFrames displayFrames,
    private void simulateLayoutDecorWindow(WindowState win, DisplayFrames displayFrames,
            InsetsState insetsState, WindowFrames simulatedWindowFrames, Runnable layout) {
            InsetsState insetsState, WindowFrames simulatedWindowFrames,
            SparseArray<Rect> contentFrames, Consumer<Rect> layout) {
        win.setSimulatedWindowFrames(simulatedWindowFrames);
        win.setSimulatedWindowFrames(simulatedWindowFrames);
        final Rect contentFrame = new Rect();
        try {
        try {
            layout.run();
            layout.accept(contentFrame);
        } finally {
        } finally {
            win.setSimulatedWindowFrames(null);
            win.setSimulatedWindowFrames(null);
        }
        }
        contentFrames.put(win.mAttrs.type, contentFrame);
        mDisplayContent.getInsetsStateController().computeSimulatedState(insetsState, win,
        mDisplayContent.getInsetsStateController().computeSimulatedState(insetsState, win,
                displayFrames, simulatedWindowFrames);
                displayFrames, simulatedWindowFrames);
    }
    }
@@ -1487,24 +1498,25 @@ public class DisplayPolicy {
     * state and some temporal states. In other words, it doesn't change the window frames used to
     * state and some temporal states. In other words, it doesn't change the window frames used to
     * show on screen.
     * show on screen.
     */
     */
    void simulateLayoutDisplay(DisplayFrames displayFrames, InsetsState insetsState, int uiMode) {
    void simulateLayoutDisplay(DisplayFrames displayFrames, InsetsState insetsState,
            SparseArray<Rect> barContentFrames) {
        displayFrames.onBeginLayout();
        displayFrames.onBeginLayout();
        updateInsetsStateForDisplayCutout(displayFrames, insetsState);
        updateInsetsStateForDisplayCutout(displayFrames, insetsState);
        insetsState.setDisplayFrame(displayFrames.mUnrestricted);
        insetsState.setDisplayFrame(displayFrames.mUnrestricted);
        final WindowFrames simulatedWindowFrames = new WindowFrames();
        final WindowFrames simulatedWindowFrames = new WindowFrames();
        if (mNavigationBar != null) {
        if (mNavigationBar != null) {
            simulateLayoutDecorWindow(
            simulateLayoutDecorWindow(mNavigationBar, displayFrames, insetsState,
                    mNavigationBar, displayFrames, insetsState, simulatedWindowFrames,
                    simulatedWindowFrames, barContentFrames,
                    () -> layoutNavigationBar(displayFrames, uiMode, mLastNavVisible,
                    contentFrame -> layoutNavigationBar(displayFrames,
                            mDisplayContent.getConfiguration().uiMode, mLastNavVisible,
                            mLastNavTranslucent, mLastNavAllowedHidden,
                            mLastNavTranslucent, mLastNavAllowedHidden,
                            mLastNotificationShadeForcesShowingNavigation,
                            mLastNotificationShadeForcesShowingNavigation, contentFrame));
                            false /* isRealLayout */));
        }
        }
        if (mStatusBar != null) {
        if (mStatusBar != null) {
            simulateLayoutDecorWindow(
            simulateLayoutDecorWindow(mStatusBar, displayFrames, insetsState,
                    mStatusBar, displayFrames, insetsState, simulatedWindowFrames,
                    simulatedWindowFrames, barContentFrames,
                    () -> layoutStatusBar(displayFrames, mLastSystemUiFlags,
                    contentFrame -> layoutStatusBar(displayFrames, mLastSystemUiFlags,
                            false /* isRealLayout */));
                            contentFrame));
        }
        }
        layoutScreenDecorWindows(displayFrames, simulatedWindowFrames);
        layoutScreenDecorWindows(displayFrames, simulatedWindowFrames);
        postAdjustDisplayFrames(displayFrames);
        postAdjustDisplayFrames(displayFrames);
@@ -1556,9 +1568,10 @@ public class DisplayPolicy {


        boolean updateSysUiVisibility = layoutNavigationBar(displayFrames, uiMode, navVisible,
        boolean updateSysUiVisibility = layoutNavigationBar(displayFrames, uiMode, navVisible,
                navTranslucent, navAllowedHidden, notificationShadeForcesShowingNavigation,
                navTranslucent, navAllowedHidden, notificationShadeForcesShowingNavigation,
                true /* isRealLayout */);
                null /* simulatedContentFrame */);
        if (DEBUG_LAYOUT) Slog.i(TAG, "mDock rect:" + displayFrames.mDock);
        if (DEBUG_LAYOUT) Slog.i(TAG, "mDock rect:" + displayFrames.mDock);
        updateSysUiVisibility |= layoutStatusBar(displayFrames, sysui, true /* isRealLayout */);
        updateSysUiVisibility |= layoutStatusBar(displayFrames, sysui,
                null /* simulatedContentFrame */);
        if (updateSysUiVisibility) {
        if (updateSysUiVisibility) {
            updateSystemUiVisibilityLw();
            updateSystemUiVisibilityLw();
        }
        }
@@ -1730,7 +1743,8 @@ public class DisplayPolicy {
        displayFrames.mContent.set(dockFrame);
        displayFrames.mContent.set(dockFrame);
    }
    }


    private boolean layoutStatusBar(DisplayFrames displayFrames, int sysui, boolean isRealLayout) {
    private boolean layoutStatusBar(DisplayFrames displayFrames, int sysui,
            Rect simulatedContentFrame) {
        // decide where the status bar goes ahead of time
        // decide where the status bar goes ahead of time
        if (mStatusBar == null) {
        if (mStatusBar == null) {
            return false;
            return false;
@@ -1753,12 +1767,14 @@ public class DisplayPolicy {
        displayFrames.mStable.top = Math.max(displayFrames.mStable.top,
        displayFrames.mStable.top = Math.max(displayFrames.mStable.top,
                displayFrames.mDisplayCutoutSafe.top);
                displayFrames.mDisplayCutoutSafe.top);


        if (isRealLayout) {
        // Tell the bar controller where the collapsed status bar content is.
        // Tell the bar controller where the collapsed status bar content is.
        sTmpRect.set(windowFrames.mContentFrame);
        sTmpRect.set(windowFrames.mContentFrame);
        sTmpRect.intersect(displayFrames.mDisplayCutoutSafe);
        sTmpRect.intersect(displayFrames.mDisplayCutoutSafe);
        sTmpRect.top = windowFrames.mContentFrame.top; // Ignore top display cutout inset
        sTmpRect.top = windowFrames.mContentFrame.top; // Ignore top display cutout inset
        sTmpRect.bottom = displayFrames.mStable.top; // Use collapsed status bar size
        sTmpRect.bottom = displayFrames.mStable.top; // Use collapsed status bar size
        if (simulatedContentFrame != null) {
            simulatedContentFrame.set(sTmpRect);
        } else {
            mStatusBarController.setContentFrame(sTmpRect);
            mStatusBarController.setContentFrame(sTmpRect);
        }
        }


@@ -1795,7 +1811,7 @@ public class DisplayPolicy {


    private boolean layoutNavigationBar(DisplayFrames displayFrames, int uiMode, boolean navVisible,
    private boolean layoutNavigationBar(DisplayFrames displayFrames, int uiMode, boolean navVisible,
            boolean navTranslucent, boolean navAllowedHidden,
            boolean navTranslucent, boolean navAllowedHidden,
            boolean statusBarForcesShowingNavigation, boolean isRealLayout) {
            boolean statusBarForcesShowingNavigation, Rect simulatedContentFrame) {
        if (mNavigationBar == null) {
        if (mNavigationBar == null) {
            return false;
            return false;
        }
        }
@@ -1899,7 +1915,9 @@ public class DisplayPolicy {
                navigationFrame /* visibleFrame */, sTmpRect /* decorFrame */,
                navigationFrame /* visibleFrame */, sTmpRect /* decorFrame */,
                navigationFrame /* stableFrame */);
                navigationFrame /* stableFrame */);
        mNavigationBar.computeFrame(displayFrames);
        mNavigationBar.computeFrame(displayFrames);
        if (isRealLayout) {
        if (simulatedContentFrame != null) {
            simulatedContentFrame.set(windowFrames.mContentFrame);
        } else {
            mNavigationBarPosition = navBarPosition;
            mNavigationBarPosition = navBarPosition;
            mNavigationBarController.setContentFrame(windowFrames.mContentFrame);
            mNavigationBarController.setContentFrame(windowFrames.mContentFrame);
        }
        }
+2 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;
package com.android.server.wm;


import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;


import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;
import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;


@@ -90,6 +91,7 @@ public class StatusBarController extends BarController {
                View.STATUS_BAR_UNHIDE,
                View.STATUS_BAR_UNHIDE,
                View.STATUS_BAR_TRANSLUCENT,
                View.STATUS_BAR_TRANSLUCENT,
                StatusBarManager.WINDOW_STATUS_BAR,
                StatusBarManager.WINDOW_STATUS_BAR,
                TYPE_STATUS_BAR,
                FLAG_TRANSLUCENT_STATUS,
                FLAG_TRANSLUCENT_STATUS,
                View.STATUS_BAR_TRANSPARENT);
                View.STATUS_BAR_TRANSPARENT);
    }
    }
+15 −8
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ import android.os.Debug;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayAdjustments.FixedRotationAdjustments;
import android.view.DisplayAdjustments.FixedRotationAdjustments;
import android.view.DisplayInfo;
import android.view.DisplayInfo;
@@ -124,7 +125,7 @@ class WindowToken extends WindowContainer<WindowState> {
    private static class FixedRotationTransformState {
    private static class FixedRotationTransformState {
        final DisplayInfo mDisplayInfo;
        final DisplayInfo mDisplayInfo;
        final DisplayFrames mDisplayFrames;
        final DisplayFrames mDisplayFrames;
        final InsetsState mInsetsState;
        final InsetsState mInsetsState = new InsetsState();
        final Configuration mRotatedOverrideConfiguration;
        final Configuration mRotatedOverrideConfiguration;
        final SeamlessRotator mRotator;
        final SeamlessRotator mRotator;
        /**
        /**
@@ -133,14 +134,14 @@ class WindowToken extends WindowContainer<WindowState> {
         */
         */
        final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(3);
        final ArrayList<WindowToken> mAssociatedTokens = new ArrayList<>(3);
        final ArrayList<WindowContainer<?>> mRotatedContainers = new ArrayList<>(3);
        final ArrayList<WindowContainer<?>> mRotatedContainers = new ArrayList<>(3);
        final SparseArray<Rect> mBarContentFrames = new SparseArray<>();
        boolean mIsTransforming = true;
        boolean mIsTransforming = true;


        FixedRotationTransformState(DisplayInfo rotatedDisplayInfo,
        FixedRotationTransformState(DisplayInfo rotatedDisplayInfo,
                DisplayFrames rotatedDisplayFrames, InsetsState rotatedInsetsState,
                DisplayFrames rotatedDisplayFrames, Configuration rotatedConfig,
                Configuration rotatedConfig, int currentRotation) {
                int currentRotation) {
            mDisplayInfo = rotatedDisplayInfo;
            mDisplayInfo = rotatedDisplayInfo;
            mDisplayFrames = rotatedDisplayFrames;
            mDisplayFrames = rotatedDisplayFrames;
            mInsetsState = rotatedInsetsState;
            mRotatedOverrideConfiguration = rotatedConfig;
            mRotatedOverrideConfiguration = rotatedConfig;
            // This will use unrotate as rotate, so the new and old rotation are inverted.
            // This will use unrotate as rotate, so the new and old rotation are inverted.
            mRotator = new SeamlessRotator(rotatedDisplayInfo.rotation, currentRotation,
            mRotator = new SeamlessRotator(rotatedDisplayInfo.rotation, currentRotation,
@@ -516,6 +517,12 @@ class WindowToken extends WindowContainer<WindowState> {
                : null;
                : null;
    }
    }


    Rect getFixedRotationBarContentFrame(int windowType) {
        return isFixedRotationTransforming()
                ? mFixedRotationTransformState.mBarContentFrames.get(windowType)
                : null;
    }

    InsetsState getFixedRotationTransformInsetsState() {
    InsetsState getFixedRotationTransformInsetsState() {
        return isFixedRotationTransforming() ? mFixedRotationTransformState.mInsetsState : null;
        return isFixedRotationTransforming() ? mFixedRotationTransformState.mInsetsState : null;
    }
    }
@@ -526,12 +533,12 @@ class WindowToken extends WindowContainer<WindowState> {
        if (mFixedRotationTransformState != null) {
        if (mFixedRotationTransformState != null) {
            return;
            return;
        }
        }
        final InsetsState insetsState = new InsetsState();
        mDisplayContent.getDisplayPolicy().simulateLayoutDisplay(displayFrames, insetsState,
                mDisplayContent.getConfiguration().uiMode);
        mFixedRotationTransformState = new FixedRotationTransformState(info, displayFrames,
        mFixedRotationTransformState = new FixedRotationTransformState(info, displayFrames,
                insetsState, new Configuration(config), mDisplayContent.getRotation());
                new Configuration(config), mDisplayContent.getRotation());
        mFixedRotationTransformState.mAssociatedTokens.add(this);
        mFixedRotationTransformState.mAssociatedTokens.add(this);
        mDisplayContent.getDisplayPolicy().simulateLayoutDisplay(displayFrames,
                mFixedRotationTransformState.mInsetsState,
                mFixedRotationTransformState.mBarContentFrames);
        onConfigurationChanged(getParent().getConfiguration());
        onConfigurationChanged(getParent().getConfiguration());
        notifyFixedRotationTransform(true /* enabled */);
        notifyFixedRotationTransform(true /* enabled */);
    }
    }
+4 −3
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;
import android.util.Pair;
import android.util.Pair;
import android.util.SparseArray;
import android.view.DisplayCutout;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
import android.view.DisplayInfo;
import android.view.InsetsState;
import android.view.InsetsState;
@@ -776,15 +777,15 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
    }
    }


    private void assertSimulateLayoutSameDisplayFrames() {
    private void assertSimulateLayoutSameDisplayFrames() {
        final int uiMode = 0;
        final String prefix = "";
        final String prefix = "";
        final InsetsState simulatedInsetsState = new InsetsState();
        final InsetsState simulatedInsetsState = new InsetsState();
        final DisplayFrames simulatedDisplayFrames = createDisplayFrames();
        final DisplayFrames simulatedDisplayFrames = createDisplayFrames();
        mDisplayPolicy.beginLayoutLw(mFrames, uiMode);
        mDisplayPolicy.beginLayoutLw(mFrames, mDisplayContent.getConfiguration().uiMode);
        // Force the display bounds because it is not synced with display frames in policy test.
        // Force the display bounds because it is not synced with display frames in policy test.
        mDisplayContent.getWindowConfiguration().setBounds(mFrames.mUnrestricted);
        mDisplayContent.getWindowConfiguration().setBounds(mFrames.mUnrestricted);
        mDisplayContent.getInsetsStateController().onPostLayout();
        mDisplayContent.getInsetsStateController().onPostLayout();
        mDisplayPolicy.simulateLayoutDisplay(simulatedDisplayFrames, simulatedInsetsState, uiMode);
        mDisplayPolicy.simulateLayoutDisplay(simulatedDisplayFrames, simulatedInsetsState,
                new SparseArray<>() /* barContentFrames */);


        final StringWriter realFramesDump = new StringWriter();
        final StringWriter realFramesDump = new StringWriter();
        mFrames.dump(prefix, new PrintWriter(realFramesDump));
        mFrames.dump(prefix, new PrintWriter(realFramesDump));
Loading