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

Commit a92cc5cc authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Cleanup window_session_relayout_info" into main

parents e1f5804c 1dcbcc84
Loading
Loading
Loading
Loading
+4 −18
Original line number Original line Diff line number Diff line
@@ -18,11 +18,8 @@ package android.wm;


import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;


import static com.android.window.flags.Flags.windowSessionRelayoutInfo;

import android.app.Activity;
import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.RemoteException;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfStatusReporter;
@@ -131,7 +128,6 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
        final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
        final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final Bundle mOutBundle = windowSessionRelayoutInfo() ? null : new Bundle();
        final WindowRelayoutResult mOutRelayoutResult;
        final WindowRelayoutResult mOutRelayoutResult;
        final IWindow mWindow;
        final IWindow mWindow;
        final View mView;
        final View mView;
@@ -152,26 +148,16 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
            mHeight = mView.getMeasuredHeight();
            mHeight = mView.getMeasuredHeight();
            mOutSurfaceControl = mView.getViewRootImpl().getSurfaceControl();
            mOutSurfaceControl = mView.getViewRootImpl().getSurfaceControl();
            mViewVisibility = visibilitySupplier;
            mViewVisibility = visibilitySupplier;
            mOutRelayoutResult = windowSessionRelayoutInfo()
            mOutRelayoutResult = new WindowRelayoutResult(mOutFrames, mOutMergedConfiguration,
                    ? new WindowRelayoutResult(mOutFrames, mOutMergedConfiguration,
                            mOutSurfaceControl, mOutInsetsState, mOutControls);
                            mOutSurfaceControl, mOutInsetsState, mOutControls)
                    : null;
        }
        }


        void runBenchmark(BenchmarkState state) throws RemoteException {
        void runBenchmark(BenchmarkState state) throws RemoteException {
            final IWindowSession session = WindowManagerGlobal.getWindowSession();
            final IWindowSession session = WindowManagerGlobal.getWindowSession();
            while (state.keepRunning()) {
            while (state.keepRunning()) {
                mRelayoutSeq++;
                mRelayoutSeq++;
                if (windowSessionRelayoutInfo()) {
                session.relayout(mWindow, mParams, mWidth, mHeight, mViewVisibility.getAsInt(),
                    session.relayout(mWindow, mParams, mWidth, mHeight,
                        mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */, mOutRelayoutResult);
                            mViewVisibility.getAsInt(), mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */,
                            mOutRelayoutResult);
                } else {
                    session.relayoutLegacy(mWindow, mParams, mWidth, mHeight,
                            mViewVisibility.getAsInt(), mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */,
                            mOutFrames, mOutMergedConfiguration, mOutSurfaceControl,
                            mOutInsetsState, mOutControls, mOutBundle);
                }
            }
            }
        }
        }
    }
    }
+4 −15
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import static com.android.window.flags.Flags.FLAG_OFFLOAD_COLOR_EXTRACTION;
import static com.android.window.flags.Flags.noConsecutiveVisibilityEvents;
import static com.android.window.flags.Flags.noConsecutiveVisibilityEvents;
import static com.android.window.flags.Flags.noVisibilityEventOnDisplayStateChange;
import static com.android.window.flags.Flags.noVisibilityEventOnDisplayStateChange;
import static com.android.window.flags.Flags.offloadColorExtraction;
import static com.android.window.flags.Flags.offloadColorExtraction;
import static com.android.window.flags.Flags.windowSessionRelayoutInfo;


import android.animation.AnimationHandler;
import android.animation.AnimationHandler;
import android.animation.Animator;
import android.animation.Animator;
@@ -302,13 +301,10 @@ public abstract class WallpaperService extends Service {
        final InsetsState mInsetsState = new InsetsState();
        final InsetsState mInsetsState = new InsetsState();
        final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
        final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
        final Bundle mSyncSeqIdBundle = windowSessionRelayoutInfo() ? null : new Bundle();


        SurfaceControl mSurfaceControl = new SurfaceControl();
        SurfaceControl mSurfaceControl = new SurfaceControl();
        WindowRelayoutResult mRelayoutResult = windowSessionRelayoutInfo()
        WindowRelayoutResult mRelayoutResult = new WindowRelayoutResult(
                ? new WindowRelayoutResult(mWinFrames, mMergedConfiguration, mSurfaceControl,
                mWinFrames, mMergedConfiguration, mSurfaceControl, mInsetsState, mTempControls);
                        mInsetsState, mTempControls)
                : null;


        private final Point mSurfaceSize = new Point();
        private final Point mSurfaceSize = new Point();
        private final Point mLastSurfaceSize = new Point();
        private final Point mLastSurfaceSize = new Point();
@@ -1277,15 +1273,8 @@ public abstract class WallpaperService extends Service {
                    } else {
                    } else {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }
                    }
                    final int relayoutResult;
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                    if (windowSessionRelayoutInfo()) {
                        relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, 0, 0, mRelayoutResult);
                            View.VISIBLE, 0, 0, 0, mRelayoutResult);
                    } else {
                        relayoutResult = mSession.relayoutLegacy(mWindow, mLayout, mWidth, mHeight,
                                View.VISIBLE, 0, 0, 0, mWinFrames, mMergedConfiguration,
                                mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle);
                    }
                    final Rect outMaxBounds = mMergedConfiguration.getMergedConfiguration()
                    final Rect outMaxBounds = mMergedConfiguration.getMergedConfiguration()
                            .windowConfiguration.getMaxBounds();
                            .windowConfiguration.getMaxBounds();
                    if (!outMaxBounds.equals(maxBounds)) {
                    if (!outMaxBounds.equals(maxBounds)) {
+0 −22
Original line number Original line Diff line number Diff line
@@ -49,18 +49,6 @@ import java.util.List;
 */
 */
interface IWindowSession {
interface IWindowSession {


    /**
     * Bundle key to store the latest sync seq id for the relayout configuration.
     * @see #relayout
     */
    const String KEY_RELAYOUT_BUNDLE_SEQID = "seqid";
    /**
     * Bundle key to store the latest ActivityWindowInfo associated with the relayout configuration.
     * Will only be set if the relayout window is an activity window.
     * @see #relayout
     */
    const String KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO = "activity_window_info";

    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, int requestedVisibleTypes,
            in int viewVisibility, in int layerStackId, int requestedVisibleTypes,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InputChannel outInputChannel, out InsetsState insetsState,
@@ -84,16 +72,6 @@ interface IWindowSession {
     */
     */
    void remove(IBinder clientToken);
    void remove(IBinder clientToken);


    /**
     * @deprecated
     */
    int relayoutLegacy(IWindow window, in WindowManager.LayoutParams attrs,
            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.Array activeControls,
            out Bundle bundle);

    /**
    /**
     * Change the parameters of a window.  You supply the
     * Change the parameters of a window.  You supply the
     * new parameters, it returns the new frame of the window on screen (the
     * new parameters, it returns the new frame of the window on screen (the
+12 −42
Original line number Original line Diff line number Diff line
@@ -25,8 +25,6 @@ import static android.os.Trace.TRACE_TAG_VIEW;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.DragEvent.ACTION_DRAG_LOCATION;
import static android.view.DragEvent.ACTION_DRAG_LOCATION;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED;
import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsSource.ID_IME;
import static android.view.InsetsSource.ID_IME;
import static android.view.Surface.FRAME_RATE_CATEGORY_DEFAULT;
import static android.view.Surface.FRAME_RATE_CATEGORY_DEFAULT;
@@ -90,6 +88,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
@@ -114,6 +113,7 @@ import static android.view.accessibility.Flags.forceInvertColor;
import static android.view.accessibility.Flags.reduceWindowContentChangedEventThrottle;
import static android.view.accessibility.Flags.reduceWindowContentChangedEventThrottle;
import static android.view.flags.Flags.addSchandleToVriSurface;
import static android.view.flags.Flags.addSchandleToVriSurface;
import static android.view.flags.Flags.sensitiveContentAppProtection;
import static android.view.flags.Flags.sensitiveContentAppProtection;
import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix;
import static android.view.flags.Flags.toolkitFrameRateFunctionEnablingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateFunctionEnablingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateTypingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateTypingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateVelocityMappingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateVelocityMappingReadOnly;
@@ -124,12 +124,11 @@ import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodCl
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.text.flags.Flags.disableHandwritingInitiatorForIme;
import static com.android.window.flags.Flags.activityWindowInfoFlag;
import static com.android.window.flags.Flags.activityWindowInfoFlag;
import static com.android.window.flags.Flags.enableBufferTransformHintFromDisplay;
import static com.android.window.flags.Flags.enableBufferTransformHintFromDisplay;
import static com.android.window.flags.Flags.insetsControlChangedItem;
import static com.android.window.flags.Flags.insetsControlChangedItem;
import static com.android.window.flags.Flags.setScPropertiesInClient;
import static com.android.window.flags.Flags.setScPropertiesInClient;
import static com.android.window.flags.Flags.windowSessionRelayoutInfo;
import static com.android.text.flags.Flags.disableHandwritingInitiatorForIme;
import android.Manifest;
import android.Manifest;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityService;
@@ -1138,7 +1137,7 @@ public final class ViewRootImpl implements ViewParent,
     */
     */
    /**
    /**
     * A temporary object used so relayoutWindow can return the latest SyncSeqId
     * Object for relayoutWindow to return the latest window info, including the SyncSeqId
     * system. The SyncSeqId system was designed to work without synchronous relayout
     * system. The SyncSeqId system was designed to work without synchronous relayout
     * window, and actually synchronous relayout window presents a problem.  We could have
     * window, and actually synchronous relayout window presents a problem.  We could have
     * a sequence like this:
     * a sequence like this:
@@ -1152,14 +1151,8 @@ public final class ViewRootImpl implements ViewParent,
     * we get rid of synchronous relayout, until then, we use this bundle to channel the
     * we get rid of synchronous relayout, until then, we use this bundle to channel the
     * integer back over relayout.
     * integer back over relayout.
     */
     */
    private final Bundle mRelayoutBundle = windowSessionRelayoutInfo()
    private final WindowRelayoutResult mRelayoutResult = new WindowRelayoutResult(
            ? null
            mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls);
            : new Bundle();
    private final WindowRelayoutResult mRelayoutResult = windowSessionRelayoutInfo()
            ? new WindowRelayoutResult(mTmpFrames, mPendingMergedConfiguration, mSurfaceControl,
                    mTempInsets, mTempControls)
            : null;
    private static volatile boolean sAnrReported = false;
    private static volatile boolean sAnrReported = false;
    static BLASTBufferQueue.TransactionHangCallback sTransactionHangCallback =
    static BLASTBufferQueue.TransactionHangCallback sTransactionHangCallback =
@@ -9261,42 +9254,19 @@ public final class ViewRootImpl implements ViewParent,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq,
                    mLastSyncSeqId);
                    mLastSyncSeqId);
        } else {
        } else {
            if (windowSessionRelayoutInfo()) {
            relayoutResult = mWindowSession.relayout(mWindow, params,
            relayoutResult = mWindowSession.relayout(mWindow, params,
                    requestedWidth, requestedHeight, viewVisibility,
                    requestedWidth, requestedHeight, viewVisibility,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                    mRelayoutSeq, mLastSyncSeqId, mRelayoutResult);
                    mRelayoutSeq, mLastSyncSeqId, mRelayoutResult);
            } else {
                relayoutResult = mWindowSession.relayoutLegacy(mWindow, params,
                        requestedWidth, requestedHeight, viewVisibility,
                        insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                        mRelayoutSeq, mLastSyncSeqId, mTmpFrames, mPendingMergedConfiguration,
                        mSurfaceControl, mTempInsets, mTempControls, mRelayoutBundle);
            }
            mRelayoutRequested = true;
            mRelayoutRequested = true;
            if (activityWindowInfoFlag() && mPendingActivityWindowInfo != null) {
            if (activityWindowInfoFlag() && mPendingActivityWindowInfo != null) {
                ActivityWindowInfo outInfo = null;
                final ActivityWindowInfo outInfo = mRelayoutResult.activityWindowInfo;
                if (windowSessionRelayoutInfo()) {
                    outInfo = mRelayoutResult != null ? mRelayoutResult.activityWindowInfo : null;
                } else {
                    try {
                        outInfo = mRelayoutBundle.getParcelable(
                                IWindowSession.KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO,
                                ActivityWindowInfo.class);
                        mRelayoutBundle.remove(
                                IWindowSession.KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO);
                    } catch (IllegalStateException e) {
                        Log.e(TAG, "Failed to get ActivityWindowInfo from relayout Bundle", e);
                    }
                }
                if (outInfo != null) {
                if (outInfo != null) {
                    mPendingActivityWindowInfo.set(outInfo);
                    mPendingActivityWindowInfo.set(outInfo);
                }
                }
            }
            }
            final int maybeSyncSeqId = windowSessionRelayoutInfo()
            final int maybeSyncSeqId = mRelayoutResult.syncSeqId;
                    ? mRelayoutResult.syncSeqId
                    : mRelayoutBundle.getInt(IWindowSession.KEY_RELAYOUT_BUNDLE_SEQID);
            if (maybeSyncSeqId > 0) {
            if (maybeSyncSeqId > 0) {
                mSyncSeqId = maybeSyncSeqId;
                mSyncSeqId = maybeSyncSeqId;
            }
            }
+0 −13
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteCallback;
import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -348,18 +347,6 @@ public class WindowlessWindowManager implements IWindowSession {
        return s.mSurfaceControl;
        return s.mSurfaceControl;
    }
    }


    @Override
    public int relayoutLegacy(IWindow window, WindowManager.LayoutParams inAttrs,
            int requestedWidth, int requestedHeight, int viewFlags, int flags, int seq,
            int lastSyncSeqId, ClientWindowFrames outFrames,
            MergedConfiguration outMergedConfiguration, SurfaceControl outSurfaceControl,
            InsetsState outInsetsState, InsetsSourceControl.Array outActiveControls,
            Bundle outSyncSeqIdBundle) {
        return relayoutInner(window, inAttrs, requestedWidth, requestedHeight, viewFlags, flags,
                seq, lastSyncSeqId, outFrames, outMergedConfiguration, outSurfaceControl,
                outInsetsState, outActiveControls);
    }

    @Override
    @Override
    public int relayout(IWindow window, WindowManager.LayoutParams inAttrs,
    public int relayout(IWindow window, WindowManager.LayoutParams inAttrs,
            int requestedWidth, int requestedHeight, int viewFlags, int flags, int seq,
            int requestedWidth, int requestedHeight, int viewFlags, int flags, int seq,
Loading