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

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

Send size-compat scale to the client

The client computes the window frame on its own in ViewRootImpl#setView.
However, the bounds obtained from WindowConfiguration is not size-
compatible, which makes legacy apps produce wrong frames. The frame is
larger than expected, so when computing WindowInsets with size-
compatible InsetsState, the window cannot receive insets.

Although the client will receive the correct window frame from relayout,
but the first WindowInsets has been dispatched before that.

This CL sends the size-compat scale to the client, so the client can use
the correct WindowConfiguration to compute frames.

This is also a step to enable the client to perform local window layout.

Bug: 237749017
Bug: 161810301
Bug: 175861127
Test: atest StartingSurfaceDrawerTests WindowAddRemovePerfTest
      ActivityRecordTests WindowManagerServiceTests
Change-Id: I6b23901f4b1f009444c04da7e078ea971a386ad7
parent bbb51619
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final Rect mOutAttachedFrame = new Rect();
        final float[] mOutSizeCompatScale = { 1f };

        TestWindow() {
            mLayoutParams.setTitle(TestWindow.class.getName());
@@ -106,7 +107,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
                long startTime = SystemClock.elapsedRealtimeNanos();
                session.addToDisplay(this, mLayoutParams, View.VISIBLE,
                        Display.DEFAULT_DISPLAY, mRequestedVisibilities, inputChannel,
                        mOutInsetsState, mOutControls, mOutAttachedFrame);
                        mOutInsetsState, mOutControls, mOutAttachedFrame, mOutSizeCompatScale);
                final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
                state.addExtraResult("add", elapsedTimeNsOfAdd);

+9 −0
Original line number Diff line number Diff line
@@ -460,6 +460,15 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        setDisplayWindowingMode(WINDOWING_MODE_UNDEFINED);
    }

    /** @hide */
    public void scale(float scale) {
        mBounds.scale(scale);
        mMaxBounds.scale(scale);
        if (mAppBounds != null) {
            mAppBounds.scale(scale);
        }
    }

    /**
     * Copies the fields from delta into this Configuration object, keeping
     * track of which ones have changed. Any undefined fields in {@code delta}
+1 −6
Original line number Diff line number Diff line
@@ -551,12 +551,7 @@ public class CompatibilityInfo implements Parcelable {
        if (isScalingRequired()) {
            float invertedRatio = applicationInvertedScale;
            inoutConfig.densityDpi = (int)((inoutConfig.densityDpi * invertedRatio) + .5f);
            inoutConfig.windowConfiguration.getMaxBounds().scale(invertedRatio);
            inoutConfig.windowConfiguration.getBounds().scale(invertedRatio);
            final Rect appBounds = inoutConfig.windowConfiguration.getAppBounds();
            if (appBounds != null) {
                appBounds.scale(invertedRatio);
            }
            inoutConfig.windowConfiguration.scale(invertedRatio);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -1134,7 +1134,7 @@ public abstract class WallpaperService extends Service {

                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mRequestedVisibilities, inputChannel,
                                mInsetsState, mTempControls, new Rect()) < 0) {
                                mInsetsState, mTempControls, new Rect(), new float[1]) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
+4 −3
Original line number Diff line number Diff line
@@ -50,15 +50,16 @@ interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in InsetsVisibilities requestedVisibilities,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls, out Rect attachedFrame);
            out InsetsSourceControl[] activeControls, out Rect attachedFrame,
            out float[] sizeCompatScale);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId,
            in InsetsVisibilities requestedVisibilities, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls,
            out Rect attachedFrame);
            out Rect attachedFrame, out float[] sizeCompatScale);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out InsetsState insetsState,
            out Rect attachedFrame);
            out Rect attachedFrame, out float[] sizeCompatScale);
    @UnsupportedAppUsage
    void remove(IWindow window);

Loading