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

Commit ea3af434 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Revert "Use WindowRelayoutResult for all WM->Client layout"" into main

parents 76dd193a 39aef49c
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
            mOutSurfaceControl = mView.getViewRootImpl().getSurfaceControl();
            mViewVisibility = visibilitySupplier;
            mOutRelayoutResult = new WindowRelayoutResult(mOutFrames, mOutMergedConfiguration,
                    mOutInsetsState, mOutControls);
                            mOutSurfaceControl, mOutInsetsState, mOutControls);
        }

        void runBenchmark(BenchmarkState state) throws RemoteException {
@@ -157,8 +157,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
            while (state.keepRunning()) {
                mRelayoutSeq++;
                session.relayout(mWindow, mParams, mWidth, mHeight, mViewVisibility.getAsInt(),
                        mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */, mOutRelayoutResult,
                        mOutSurfaceControl);
                        mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */, mOutRelayoutResult);
            }
        }
    }
+8 −8
Original line number Diff line number Diff line
@@ -19,12 +19,12 @@ package android.wm;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

import android.graphics.Rect;
import android.os.RemoteException;
import android.os.SystemClock;
import android.perftests.utils.ManualBenchmarkState;
import android.perftests.utils.ManualBenchmarkState.ManualBenchmarkTest;
import android.perftests.utils.PerfManualStatusReporter;
import android.util.MergedConfiguration;
import android.view.Display;
import android.view.IWindowSession;
import android.view.InputChannel;
@@ -34,8 +34,6 @@ import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowRelayoutResult;
import android.window.ClientWindowFrames;

import androidx.test.filters.LargeTest;

@@ -87,9 +85,10 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
    private static class TestWindow extends BaseIWindow {
        final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
        final int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
        final WindowRelayoutResult mRelayoutResult = new WindowRelayoutResult(
                new ClientWindowFrames(), new MergedConfiguration(), new InsetsState(),
                new InsetsSourceControl.Array());
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final Rect mOutAttachedFrame = new Rect();
        final float[] mOutSizeCompatScale = { 1f };

        TestWindow() {
            mLayoutParams.setTitle(TestWindow.class.getName());
@@ -106,8 +105,9 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
                final InputChannel inputChannel = new InputChannel();

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

+53 −26
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app.servertransaction;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ClientTransactionHandler;
@@ -26,7 +28,6 @@ import android.util.Log;
import android.util.MergedConfiguration;
import android.view.IWindow;
import android.view.InsetsState;
import android.view.WindowRelayoutResult;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;

@@ -42,32 +43,44 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
    private static final String TAG = "WindowStateResizeItem";

    @NonNull
    private final WindowRelayoutResult mLayout = new WindowRelayoutResult(new ClientWindowFrames(),
            new MergedConfiguration(), new InsetsState(), null /* insetControls */);
    private final ClientWindowFrames mFrames;

    @NonNull
    private final MergedConfiguration mConfiguration;

    @NonNull
    private final InsetsState mInsetsState;

    /** {@code null} if this is not an Activity window. */
    @Nullable
    private final ActivityWindowInfo mActivityWindowInfo;

    private final boolean mReportDraw;
    private final boolean mForceLayout;
    private final boolean mAlwaysConsumeSystemBars;
    private final int mDisplayId;
    private final int mSyncSeqId;
    private final boolean mDragResizing;

    public WindowStateResizeItem(@NonNull IWindow window,
            @NonNull ClientWindowFrames frames, boolean reportDraw,
            @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState,
            boolean forceLayout, int displayId, int syncSeqId, boolean dragResizing,
            @Nullable ActivityWindowInfo activityWindowInfo) {
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId,
            boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) {
        super(window);
        mLayout.frames.setTo(frames);
        mLayout.mergedConfiguration.setTo(configuration);
        mLayout.insetsState.set(insetsState, true /* copySources */);
        mFrames = new ClientWindowFrames(frames);
        mConfiguration = new MergedConfiguration(configuration);
        mInsetsState = new InsetsState(insetsState, true /* copySources */);
        if (activityWindowInfo != null) {
            mLayout.activityWindowInfo = new ActivityWindowInfo(activityWindowInfo);
            mActivityWindowInfo = new ActivityWindowInfo(activityWindowInfo);
        } else {
            mLayout.activityWindowInfo = null;
            mActivityWindowInfo = null;
        }
        mReportDraw = reportDraw;
        mForceLayout = forceLayout;
        mAlwaysConsumeSystemBars = alwaysConsumeSystemBars;
        mDisplayId = displayId;
        mLayout.syncSeqId = syncSeqId;
        mSyncSeqId = syncSeqId;
        mDragResizing = dragResizing;
    }

@@ -77,7 +90,9 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER,
                mReportDraw ? "windowResizedReport" : "windowResized");
        try {
            window.resized(mLayout, mReportDraw, mForceLayout, mDisplayId, mDragResizing);
            window.resized(mFrames, mReportDraw, mConfiguration, mInsetsState, mForceLayout,
                    mAlwaysConsumeSystemBars, mDisplayId, mSyncSeqId, mDragResizing,
                    mActivityWindowInfo);
        } catch (RemoteException e) {
            // Should be a local call.
            // An exception could happen if the process is restarted. It is safe to ignore since
@@ -93,21 +108,31 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        mLayout.writeToParcel(dest, flags);
        dest.writeTypedObject(mFrames, flags);
        dest.writeBoolean(mReportDraw);
        dest.writeTypedObject(mConfiguration, flags);
        dest.writeTypedObject(mInsetsState, flags);
        dest.writeBoolean(mForceLayout);
        dest.writeBoolean(mAlwaysConsumeSystemBars);
        dest.writeInt(mDisplayId);
        dest.writeInt(mSyncSeqId);
        dest.writeBoolean(mDragResizing);
        dest.writeTypedObject(mActivityWindowInfo, flags);
    }

    /** Reads from Parcel. */
    private WindowStateResizeItem(@NonNull Parcel in) {
        super(in);
        mLayout.readFromParcel(in);
        mFrames = requireNonNull(in.readTypedObject(ClientWindowFrames.CREATOR));
        mReportDraw = in.readBoolean();
        mConfiguration = requireNonNull(in.readTypedObject(MergedConfiguration.CREATOR));
        mInsetsState = requireNonNull(in.readTypedObject(InsetsState.CREATOR));
        mForceLayout = in.readBoolean();
        mAlwaysConsumeSystemBars = in.readBoolean();
        mDisplayId = in.readInt();
        mSyncSeqId = in.readInt();
        mDragResizing = in.readBoolean();
        mActivityWindowInfo = in.readTypedObject(ActivityWindowInfo.CREATOR);
    }

    public static final @NonNull Creator<WindowStateResizeItem> CREATOR = new Creator<>() {
@@ -129,30 +154,32 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
            return false;
        }
        final WindowStateResizeItem other = (WindowStateResizeItem) o;
        return Objects.equals(mLayout.frames, other.mLayout.frames)
                && Objects.equals(mLayout.mergedConfiguration, other.mLayout.mergedConfiguration)
                && Objects.equals(mLayout.insetsState, other.mLayout.insetsState)
        return Objects.equals(mFrames, other.mFrames)
                && mReportDraw == other.mReportDraw
                && Objects.equals(mConfiguration, other.mConfiguration)
                && Objects.equals(mInsetsState, other.mInsetsState)
                && mForceLayout == other.mForceLayout
                && mAlwaysConsumeSystemBars == other.mAlwaysConsumeSystemBars
                && mDisplayId == other.mDisplayId
                && mLayout.syncSeqId == other.mLayout.syncSeqId
                && mSyncSeqId == other.mSyncSeqId
                && mDragResizing == other.mDragResizing
                && Objects.equals(mLayout.activityWindowInfo, other.mLayout.activityWindowInfo);
                && Objects.equals(mActivityWindowInfo, other.mActivityWindowInfo);
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + super.hashCode();
        result = 31 * result + Objects.hashCode(mLayout.frames);
        result = 31 * result + Objects.hashCode(mLayout.mergedConfiguration);
        result = 31 * result + Objects.hashCode(mLayout.insetsState);
        result = 31 * result + Objects.hashCode(mFrames);
        result = 31 * result + (mReportDraw ? 1 : 0);
        result = 31 * result + Objects.hashCode(mConfiguration);
        result = 31 * result + Objects.hashCode(mInsetsState);
        result = 31 * result + (mForceLayout ? 1 : 0);
        result = 31 * result + (mAlwaysConsumeSystemBars ? 1 : 0);
        result = 31 * result + mDisplayId;
        result = 31 * result + mLayout.syncSeqId;
        result = 31 * result + mSyncSeqId;
        result = 31 * result + (mDragResizing ? 1 : 0);
        result = 31 * result + Objects.hashCode(mLayout.activityWindowInfo);
        result = 31 * result + Objects.hashCode(mActivityWindowInfo);
        return result;
    }

@@ -160,8 +187,8 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
    public String toString() {
        return "WindowStateResizeItem{" + super.toString()
                + ", reportDrawn=" + mReportDraw
                + ", configuration=" + mLayout.mergedConfiguration
                + ", activityWindowInfo=" + mLayout.activityWindowInfo
                + ", configuration=" + mConfiguration
                + ", activityWindowInfo=" + mActivityWindowInfo
                + "}";
    }
}
+11 −9
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ import android.view.WindowLayout;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowRelayoutResult;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;
import android.window.ScreenCapture;

@@ -311,7 +312,7 @@ public abstract class WallpaperService extends Service {

        SurfaceControl mSurfaceControl = new SurfaceControl();
        WindowRelayoutResult mRelayoutResult = new WindowRelayoutResult(
                mWinFrames, mMergedConfiguration, mInsetsState, mTempControls);
                mWinFrames, mMergedConfiguration, mSurfaceControl, mInsetsState, mTempControls);

        private final Point mSurfaceSize = new Point();
        private final Point mLastSurfaceSize = new Point();
@@ -483,11 +484,14 @@ public abstract class WallpaperService extends Service {

        final BaseIWindow mWindow = new BaseIWindow() {
            @Override
            public void resized(WindowRelayoutResult layout, boolean reportDraw,
                    boolean forceLayout, int displayId, boolean dragResizing) {
            public void resized(ClientWindowFrames frames, boolean reportDraw,
                    MergedConfiguration mergedConfiguration, InsetsState insetsState,
                    boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
                    int syncSeqId, boolean dragResizing,
                    @Nullable ActivityWindowInfo activityWindowInfo) {
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0,
                        layout.mergedConfiguration);
                        mergedConfiguration);
                mIWallpaperEngine.mPendingResizeCount.incrementAndGet();
                mCaller.sendMessage(msg);
            }
@@ -1287,12 +1291,10 @@ public abstract class WallpaperService extends Service {
                                com.android.internal.R.style.Animation_Wallpaper;
                        InputChannel inputChannel = new InputChannel();

                        final WindowRelayoutResult addRes = new WindowRelayoutResult(
                                new ClientWindowFrames(), new MergedConfiguration(), mInsetsState,
                                mTempControls);
                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), WindowInsets.Type.defaultVisible(),
                                inputChannel, addRes) < 0) {
                                inputChannel, mInsetsState, mTempControls, new Rect(),
                                new float[1]) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
@@ -1312,7 +1314,7 @@ public abstract class WallpaperService extends Service {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, 0, 0, mRelayoutResult, mSurfaceControl);
                            View.VISIBLE, 0, 0, 0, mRelayoutResult);
                    final Rect outMaxBounds = mMergedConfiguration.getMergedConfiguration()
                            .windowConfiguration.getMaxBounds();
                    if (!outMaxBounds.equals(maxBounds)) {
+8 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package android.view;

import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.util.MergedConfiguration;
@@ -29,7 +30,8 @@ import android.view.IScrollCaptureResponseListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.inputmethod.ImeTracker;
import android.view.WindowRelayoutResult;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;

import com.android.internal.os.IResultReceiver;

@@ -57,8 +59,11 @@ oneway interface IWindow {
     * Please dispatch through WindowStateResizeItem instead of directly calling this method from
     * the system server.
     */
    void resized(in WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout,
            int displayId, boolean dragResizing);
    void resized(in ClientWindowFrames frames, boolean reportDraw,
            in MergedConfiguration newMergedConfiguration, in InsetsState insetsState,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            int syncSeqId, boolean dragResizing,
            in @nullable ActivityWindowInfo activityWindowInfo);

    /**
     * Called when this window retrieved control over a specified set of insets sources.
Loading