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

Commit cf1138d4 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Remove outFrame from the parameters of addWindow" into sc-dev

parents 7bd66f29 46252a41
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -19,14 +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.view.Display;
import android.view.DisplayCutout;
import android.view.IWindowSession;
import android.view.InputChannel;
import android.view.InsetsSourceControl;
@@ -85,9 +83,6 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
    private static class TestWindow extends BaseIWindow {
        final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
        final InsetsState mRequestedVisibility = new InsetsState();
        final Rect mOutFrame = new Rect();
        final DisplayCutout.ParcelableWrapper mOutDisplayCutout =
                new DisplayCutout.ParcelableWrapper();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];

@@ -107,7 +102,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase

                long startTime = SystemClock.elapsedRealtimeNanos();
                session.addToDisplay(this, mLayoutParams, View.VISIBLE,
                        Display.DEFAULT_DISPLAY, mRequestedVisibility, mOutFrame, inputChannel,
                        Display.DEFAULT_DISPLAY, mRequestedVisibility, inputChannel,
                        mOutInsetsState, mOutControls);
                final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
                state.addExtraResult("add", elapsedTimeNsOfAdd);
+2 −2
Original line number Diff line number Diff line
@@ -880,8 +880,8 @@ public abstract class WallpaperService extends Service {
                        InputChannel inputChannel = new InputChannel();

                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mInsetsState, mWinFrames.frame,
                                inputChannel, mInsetsState, mTempControls) < 0) {
                                mDisplay.getDisplayId(), mInsetsState, inputChannel, mInsetsState,
                                mTempControls) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
+2 −2
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@ import java.util.List;
interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in InsetsState requestedVisibility,
            out Rect outFrame, out InputChannel outInputChannel, out InsetsState insetsState,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId,
            in InsetsState requestedVisibility, out Rect outFrame, out InputChannel outInputChannel,
            in InsetsState requestedVisibility, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out InsetsState insetsState);
+38 −9
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ import android.os.Trace;
import android.os.UserHandle;
import android.sysprop.DisplayProperties;
import android.util.AndroidRuntimeException;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
@@ -157,6 +158,7 @@ import android.view.View.AttachInfo;
import android.view.View.FocusDirection;
import android.view.View.MeasureSpec;
import android.view.Window.OnContentApplyWindowInsetsListener;
import android.view.WindowInsets.Side.InsetsSide;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
@@ -926,6 +928,33 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    // TODO(b/161810301): Make this private after window layout is moved to the client side.
    public static void computeWindowBounds(WindowManager.LayoutParams attrs, InsetsState state,
            Rect displayFrame, Rect outBounds) {
        final @InsetsType int typesToFit = attrs.getFitInsetsTypes();
        final @InsetsSide int sidesToFit = attrs.getFitInsetsSides();
        final ArraySet<Integer> types = InsetsState.toInternalType(typesToFit);
        final Rect df = displayFrame;
        Insets insets = Insets.of(0, 0, 0, 0);
        for (int i = types.size() - 1; i >= 0; i--) {
            final InsetsSource source = state.peekSource(types.valueAt(i));
            if (source == null) {
                continue;
            }
            insets = Insets.max(insets, source.calculateInsets(
                    df, attrs.isFitInsetsIgnoringVisibility()));
        }
        final int left = (sidesToFit & WindowInsets.Side.LEFT) != 0 ? insets.left : 0;
        final int top = (sidesToFit & WindowInsets.Side.TOP) != 0 ? insets.top : 0;
        final int right = (sidesToFit & WindowInsets.Side.RIGHT) != 0 ? insets.right : 0;
        final int bottom = (sidesToFit & WindowInsets.Side.BOTTOM) != 0 ? insets.bottom : 0;
        outBounds.set(df.left + left, df.top + top, df.right - right, df.bottom - bottom);
    }

    private Configuration getConfiguration() {
        return mContext.getResources().getConfiguration();
    }

    /**
     * We have one child
     */
@@ -1057,18 +1086,15 @@ public final class ViewRootImpl implements ViewParent,
                    controlInsetsForCompatibility(mWindowAttributes);
                    res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
                            getHostVisibility(), mDisplay.getDisplayId(), userId,
                            mInsetsController.getRequestedVisibility(), mTmpFrames.frame,
                            inputChannel, mTempInsets, mTempControls);
                            mInsetsController.getRequestedVisibility(), inputChannel, mTempInsets,
                            mTempControls);
                    if (mTranslator != null) {
                        mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
                        mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                    }
                    setFrame(mTmpFrames.frame);
                } catch (RemoteException e) {
                    mAdded = false;
                    mView = null;
                    mAttachInfo.mRootView = null;
                    inputChannel = null;
                    mFallbackEventHandler.setView(null);
                    unscheduleTraversals();
                    setAccessibilityFocus(null, null);
@@ -1084,6 +1110,9 @@ public final class ViewRootImpl implements ViewParent,
                mPendingAlwaysConsumeSystemBars = mAttachInfo.mAlwaysConsumeSystemBars;
                mInsetsController.onStateChanged(mTempInsets);
                mInsetsController.onControlsChanged(mTempControls);
                computeWindowBounds(mWindowAttributes, mInsetsController.getState(),
                        getConfiguration().windowConfiguration.getBounds(), mTmpFrames.frame);
                setFrame(mTmpFrames.frame);
                if (DEBUG_LAYOUT) Log.v(mTag, "Added window " + mWindow);
                if (res < WindowManagerGlobal.ADD_OKAY) {
                    mAttachInfo.mRootView = null;
@@ -1357,7 +1386,7 @@ public final class ViewRootImpl implements ViewParent,
    }

    private int getNightMode() {
        return mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
        return getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
    }

    private void updateForceDarkMode() {
@@ -2333,7 +2362,7 @@ public final class ViewRootImpl implements ViewParent,

    /* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
        if (mLastWindowInsets == null || forceConstruct) {
            final Configuration config = mContext.getResources().getConfiguration();
            final Configuration config = getConfiguration();
            mLastWindowInsets = mInsetsController.calculateInsets(
                    config.isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars,
                    mWindowAttributes.type, config.windowConfiguration.getWindowingMode(),
@@ -2469,7 +2498,7 @@ public final class ViewRootImpl implements ViewParent,
            mFullRedrawNeeded = true;
            mLayoutRequested = true;

            final Configuration config = mContext.getResources().getConfiguration();
            final Configuration config = getConfiguration();
            if (shouldUseDisplaySize(lp)) {
                // NOTE -- system code, won't try to do compat mode.
                Point size = new Point();
@@ -4762,7 +4791,7 @@ public final class ViewRootImpl implements ViewParent,
        }
        // TODO: Centralize this sanitization? Why do we let setting bad modes?
        // Alternatively, can we just let HWUI figure it out? Do we need to care here?
        if (!mContext.getResources().getConfiguration().isScreenWideColorGamut()) {
        if (!getConfiguration().isScreenWideColorGamut()) {
            colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
        }
        mAttachInfo.mThreadedRenderer.setColorMode(colorMode);
+3 −3
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public class WindowlessWindowManager implements IWindowSession {
     */
    @Override
    public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs,
            int viewVisibility, int displayId, InsetsState requestedVisibility, Rect outFrame,
            int viewVisibility, int displayId, InsetsState requestedVisibility,
            InputChannel outInputChannel, InsetsState outInsetsState,
            InsetsSourceControl[] outActiveControls) {
        final SurfaceControl.Builder b = new SurfaceControl.Builder(mSurfaceSession)
@@ -171,10 +171,10 @@ public class WindowlessWindowManager implements IWindowSession {
    @Override
    public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs,
            int viewVisibility, int displayId, int userId, InsetsState requestedVisibility,
            Rect outFrame, InputChannel outInputChannel, InsetsState outInsetsState,
            InputChannel outInputChannel, InsetsState outInsetsState,
            InsetsSourceControl[] outActiveControls) {
        return addToDisplay(window, attrs, viewVisibility, displayId, requestedVisibility,
                outFrame, outInputChannel, outInsetsState, outActiveControls);
                outInputChannel, outInsetsState, outActiveControls);
    }

    @Override
Loading