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

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

Merge "Replace Bundle used in IWindowSession#relayout" into main

parents 304e0e82 82d2d775
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.wm;

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

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

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
@@ -35,6 +37,7 @@ import android.view.SurfaceControl;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowRelayoutResult;
import android.widget.LinearLayout;
import android.window.ClientWindowFrames;

@@ -128,7 +131,8 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
        final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
        final Bundle mOutBundle = new Bundle();
        final Bundle mOutBundle = windowSessionRelayoutInfo() ? null : new Bundle();
        final WindowRelayoutResult mOutRelayoutResult;
        final IWindow mWindow;
        final View mView;
        final WindowManager.LayoutParams mParams;
@@ -148,16 +152,26 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
            mHeight = mView.getMeasuredHeight();
            mOutSurfaceControl = mView.getViewRootImpl().getSurfaceControl();
            mViewVisibility = visibilitySupplier;
            mOutRelayoutResult = windowSessionRelayoutInfo()
                    ? new WindowRelayoutResult(mOutFrames, mOutMergedConfiguration,
                            mOutSurfaceControl, mOutInsetsState, mOutControls)
                    : null;
        }

        void runBenchmark(BenchmarkState state) throws RemoteException {
            final IWindowSession session = WindowManagerGlobal.getWindowSession();
            while (state.keepRunning()) {
                mRelayoutSeq++;
                if (windowSessionRelayoutInfo()) {
                    session.relayout(mWindow, mParams, mWidth, mHeight,
                            mViewVisibility.getAsInt(), mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */,
                        mOutFrames, mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState,
                        mOutControls, mOutBundle);
                            mOutRelayoutResult);
                } else {
                    session.relayoutLegacy(mWindow, mParams, mWidth, mHeight,
                            mViewVisibility.getAsInt(), mFlags, mRelayoutSeq, 0 /* lastSyncSeqId */,
                            mOutFrames, mOutMergedConfiguration, mOutSurfaceControl,
                            mOutInsetsState, mOutControls, mOutBundle);
                }
            }
        }
    }
+20 −6
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
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.offloadColorExtraction;
import static com.android.window.flags.Flags.windowSessionRelayoutInfo;

import android.animation.AnimationHandler;
import android.animation.Animator;
@@ -105,6 +106,7 @@ import android.view.WindowInsets;
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;
@@ -299,7 +301,14 @@ public abstract class WallpaperService extends Service {
        final InsetsState mInsetsState = new InsetsState();
        final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
        final Bundle mSyncSeqIdBundle = new Bundle();
        final Bundle mSyncSeqIdBundle = windowSessionRelayoutInfo() ? null : new Bundle();

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

        private final Point mSurfaceSize = new Point();
        private final Point mLastSurfaceSize = new Point();
        private final Matrix mTmpMatrix = new Matrix();
@@ -357,8 +366,6 @@ public abstract class WallpaperService extends Service {
        private float mWallpaperDimAmount = 0f;
        private float mPreviousWallpaperDimAmount = mWallpaperDimAmount;
        private float mDefaultDimAmount = 0.05f;

        SurfaceControl mSurfaceControl = new SurfaceControl();
        SurfaceControl mBbqSurfaceControl;
        BLASTBufferQueue mBlastBufferQueue;
        private SurfaceControl mScreenshotSurfaceControl;
@@ -1268,9 +1275,15 @@ public abstract class WallpaperService extends Service {
                    } else {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                    final int relayoutResult;
                    if (windowSessionRelayoutInfo()) {
                        relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                                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()
                            .windowConfiguration.getMaxBounds();
                    if (!outMaxBounds.equals(maxBounds)) {
@@ -2364,6 +2377,7 @@ public abstract class WallpaperService extends Service {
            if (mSurfaceControl != null) {
                mSurfaceControl.release();
                mSurfaceControl = null;
                mRelayoutResult = null;
            }
        }

+15 −14
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.view.InsetsState;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.WindowRelayoutResult;
import android.window.ClientWindowFrames;
import android.window.InputTransferToken;
import android.window.OnBackInvokedCallbackInfo;
@@ -83,6 +84,16 @@ interface IWindowSession {
     */
    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
     * new parameters, it returns the new frame of the window on screen (the
@@ -98,22 +109,12 @@ interface IWindowSession {
     * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}.
     * @param seq The calling sequence of {@link #relayout} and {@link #relayoutAsync}.
     * @param lastSyncSeqId The last SyncSeqId that the client applied.
     * @param outFrames The window frames used by the client side for layout.
     * @param outMergedConfiguration New config container that holds global, override and merged
     *                               config for window, if it is now becoming visible and the merged
     *                               config has changed since it was last displayed.
     * @param outSurfaceControl Object in which is placed the new display surface.
     * @param insetsState The current insets state in the system.
     * @param activeControls Objects which allow controlling {@link InsetsSource}s.
     * @param bundle A Bundle to contain the latest SyncSeqId and any extra relayout optional infos.
     * @param outRelayoutResult Data object contains the info to be returned from server side.
     * @return int Result flags, defined in {@link WindowManagerGlobal}.
     */
    int relayout(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);
    int relayout(IWindow window, in WindowManager.LayoutParams attrs, int requestedWidth,
            int requestedHeight, int viewVisibility, int flags, int seq, int lastSyncSeqId,
            out @nullable WindowRelayoutResult outRelayoutResult);

    /**
     * Similar to {@link #relayout} but this is an oneway method which doesn't return anything.
+36 −15
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PACK
import static com.android.window.flags.Flags.activityWindowInfoFlag;
import static com.android.window.flags.Flags.enableBufferTransformHintFromDisplay;
import static com.android.window.flags.Flags.setScPropertiesInClient;
import static com.android.window.flags.Flags.windowSessionRelayoutInfo;
import android.Manifest;
import android.accessibilityservice.AccessibilityService;
@@ -1134,7 +1135,14 @@ public final class ViewRootImpl implements ViewParent,
     * we get rid of synchronous relayout, until then, we use this bundle to channel the
     * integer back over relayout.
     */
    private Bundle mRelayoutBundle = new Bundle();
    private final Bundle mRelayoutBundle = windowSessionRelayoutInfo()
            ? null
            : new Bundle();
    private final WindowRelayoutResult mRelayoutResult = windowSessionRelayoutInfo()
            ? new WindowRelayoutResult(mTmpFrames, mPendingMergedConfiguration, mSurfaceControl,
                    mTempInsets, mTempControls)
            : null;
    private static volatile boolean sAnrReported = false;
    static BLASTBufferQueue.TransactionHangCallback sTransactionHangCallback =
@@ -9050,29 +9058,42 @@ public final class ViewRootImpl implements ViewParent,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq,
                    mLastSyncSeqId);
        } else {
            if (windowSessionRelayoutInfo()) {
                relayoutResult = mWindowSession.relayout(mWindow, params,
                        requestedWidth, requestedHeight, viewVisibility,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mRelayoutSeq,
                    mLastSyncSeqId, mTmpFrames, mPendingMergedConfiguration, mSurfaceControl,
                    mTempInsets, mTempControls, mRelayoutBundle);
                        insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                        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;
            if (activityWindowInfoFlag() && mPendingActivityWindowInfo != null) {
                ActivityWindowInfo outInfo = null;
                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);
                        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) {
                    mPendingActivityWindowInfo.set(outInfo);
                }
            }
            final int maybeSyncSeqId = mRelayoutBundle.getInt(
                    IWindowSession.KEY_RELAYOUT_BUNDLE_SEQID);
            final int maybeSyncSeqId = windowSessionRelayoutInfo()
                    ? mRelayoutResult.syncSeqId
                    : mRelayoutBundle.getInt(IWindowSession.KEY_RELAYOUT_BUNDLE_SEQID);
            if (maybeSyncSeqId > 0) {
                mSyncSeqId = maybeSyncSeqId;
            }
+23 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2024, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view;

/**
 * Stores information to pass to {@link IWindowSession#relayout} as AIDL out type.
 * @hide
 */
parcelable WindowRelayoutResult;
Loading