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

Commit ec1a69e8 authored by Tiger Huang's avatar Tiger Huang
Browse files

Send display cutout to client via insetsChanged

Since the display cutout is a type of insets and the display cutout can
be obtained from WindowInsets, it makes sense that InsetsState has the
display cutout instance. In this way, we can send the display cutout to
client via W#insetsChanged instead of W#resized.

This can be a step to remove the class of ClientWindowFrames, and can
also be a step to make client compute its window frame locally.

Fix: 175858810
Bug: 161810301
Test: atest WindowAddRemovePerfTest ImeInsetsSourceConsumerTest
            InsetsControllerTest InsetsStateTest ViewRootImplTest
            WindowInsetsControllerTests ActivityRecordTests
            DisplayPolicyLayoutTests LaunchParamsControllerTests
            TaskSnapshotSurfaceTest WindowMetricsActivityTests
            WindowMetricsWindowContextTests WindowMetricsTest
            WindowFrameTests WindowStateTests WmDisplayCutoutTest
Change-Id: I9a930b1d2f7df3cea2b29629b767a4a5f31bca17
parent 5e6d6114
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -107,8 +107,8 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase

                long startTime = SystemClock.elapsedRealtimeNanos();
                session.addToDisplay(this, mLayoutParams, View.VISIBLE,
                        Display.DEFAULT_DISPLAY, mRequestedVisibility, mOutFrame,
                        mOutDisplayCutout, inputChannel, mOutInsetsState, mOutControls);
                        Display.DEFAULT_DISPLAY, mRequestedVisibility, mOutFrame, inputChannel,
                        mOutInsetsState, mOutControls);
                final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
                state.addExtraResult("add", elapsedTimeNsOfAdd);

+3 −4
Original line number Diff line number Diff line
@@ -881,8 +881,7 @@ public abstract class WallpaperService extends Service {

                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mInsetsState, mWinFrames.frame,
                                mWinFrames.displayCutout, inputChannel, mInsetsState,
                                mTempControls) < 0) {
                                inputChannel, mInsetsState, mTempControls) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
@@ -924,13 +923,13 @@ public abstract class WallpaperService extends Service {
                    int w = mWinFrames.frame.width();
                    int h = mWinFrames.frame.height();

                    final DisplayCutout rawCutout = mWinFrames.displayCutout.get();
                    final DisplayCutout rawCutout = mInsetsState.getDisplayCutout();
                    final Configuration config = getResources().getConfiguration();
                    final Rect visibleFrame = new Rect(mWinFrames.frame);
                    visibleFrame.intersect(mInsetsState.getDisplayFrame());
                    WindowInsets windowInsets = mInsetsState.calculateInsets(visibleFrame,
                            null /* ignoringVisibilityState */, config.isScreenRound(),
                            false /* alwaysConsumeSystemBars */, rawCutout, mLayout.softInputMode,
                            false /* alwaysConsumeSystemBars */, mLayout.softInputMode,
                            mLayout.flags, SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
                            config.windowConfiguration.getWindowingMode(), null /* typeSideMap */);

+16 −0
Original line number Diff line number Diff line
@@ -196,6 +196,12 @@ public final class DisplayCutout {
            return rects;
        }

        private void scale(float scale) {
            for (int i = 0; i < BOUNDS_POSITION_LENGTH; ++i) {
                mRects[i].scale(scale);
            }
        }

        @Override
        public int hashCode() {
            int result = 0;
@@ -871,6 +877,16 @@ public final class DisplayCutout {
            mInner = cutout;
        }

        public void scale(float scale) {
            final Rect safeInsets = mInner.getSafeInsets();
            safeInsets.scale(scale);
            final Bounds bounds = new Bounds(mInner.mBounds.mRects, true);
            bounds.scale(scale);
            final Rect waterfallInsets = mInner.mWaterfallInsets.toRect();
            waterfallInsets.scale(scale);
            mInner = new DisplayCutout(safeInsets, Insets.of(waterfallInsets), bounds);
        }

        @Override
        public int hashCode() {
            return mInner.hashCode();
+1 −1
Original line number Diff line number Diff line
@@ -728,7 +728,7 @@ interface IWindowManager
     * @return {@code true} if system bars are always comsumed.
     */
    boolean getWindowInsets(in WindowManager.LayoutParams attrs, int displayId,
            out DisplayCutout.ParcelableWrapper outDisplayCutout, out InsetsState outInsetsState);
            out InsetsState outInsetsState);

    /**
     * Called to show global actions.
+2 −4
Original line number Diff line number Diff line
@@ -47,13 +47,11 @@ import java.util.List;
interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in InsetsState requestedVisibility,
            out Rect outFrame, out DisplayCutout.ParcelableWrapper displayCutout,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out Rect outFrame, out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId,
            in InsetsState requestedVisibility, out Rect outFrame,
            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel,
            in InsetsState requestedVisibility, out Rect outFrame, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out InsetsState insetsState);
Loading