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

Commit b262a3fb authored by Tiger's avatar Tiger
Browse files

Stop allocating memory for non-existing controls

Before this CL, we would create an fixed-length array of to collect all
the possible controls from binder calls. The length is the number of
pre-defined internal insets types which is much longer than needed.
Also, when the internal insets types are removed, a client can receive
unlimited controls. This make it impossible to use an fixed-size array
to collect controls from the out parameters of a binder call.

This CL adds a static inner class: InsetsSourceControl.Array. It can be
used as a parameter to collect controls, and it won't waste memory for
non-existing ones.

Bug: 234093736
Test: atest RelayoutPerfTest WindowAddRemovePerfTest
      WindowManagerServiceTests
Change-Id: Ie544ade65f4be3eb6ace81cde1dd53c171b191b9
parent 4c58d93f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
        final ClientWindowFrames mOutFrames = new ClientWindowFrames();
        final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final IWindow mWindow;
        final View mView;
        final WindowManager.LayoutParams mParams;
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
        final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
        final int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final Rect mOutAttachedFrame = new Rect();
        final float[] mOutSizeCompatScale = { 1f };

+1 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ public abstract class WallpaperService extends Service {
        final Rect mDispatchedStableInsets = new Rect();
        DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
        final InsetsState mInsetsState = new InsetsState();
        final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0];
        final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
        final Bundle mSyncSeqIdBundle = new Bundle();
        private final Point mSurfaceSize = new Point();
+3 −3
Original line number Diff line number Diff line
@@ -49,12 +49,12 @@ interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, int requestedVisibleTypes,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls, out Rect attachedFrame,
            out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
            out float[] sizeCompatScale);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId, int requestedVisibleTypes,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls, out Rect attachedFrame,
            out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
            out float[] sizeCompatScale);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out InsetsState insetsState,
@@ -91,7 +91,7 @@ interface IWindowSession {
            int requestedWidth, int requestedHeight, int viewVisibility,
            int flags, int seq, int lastSyncSeqId, out ClientWindowFrames outFrames,
            out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls,
            out InsetsState insetsState, out InsetsSourceControl.Array activeControls,
            out Bundle bundle);

    /**
+1 −0
Original line number Diff line number Diff line
@@ -17,3 +17,4 @@
package android.view;

parcelable InsetsSourceControl;
parcelable InsetsSourceControl.Array;
Loading