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

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

Merge "Send the attached frame to the client" into tm-qpr-dev

parents cb570a34 15751451
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ 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;
@@ -86,6 +87,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
        final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final Rect mOutAttachedFrame = new Rect();

        TestWindow() {
            mLayoutParams.setTitle(TestWindow.class.getName());
@@ -104,7 +106,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
                long startTime = SystemClock.elapsedRealtimeNanos();
                session.addToDisplay(this, mLayoutParams, View.VISIBLE,
                        Display.DEFAULT_DISPLAY, mRequestedVisibilities, inputChannel,
                        mOutInsetsState, mOutControls);
                        mOutInsetsState, mOutControls, mOutAttachedFrame);
                final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
                state.addExtraResult("add", elapsedTimeNsOfAdd);

+4 −1
Original line number Diff line number Diff line
@@ -420,7 +420,10 @@ public class CompatibilityInfo implements Parcelable {
         * Translate a Rect in screen coordinates into the app window's coordinates.
         */
        @UnsupportedAppUsage
        public void translateRectInScreenToAppWindow(Rect rect) {
        public void translateRectInScreenToAppWindow(@Nullable Rect rect) {
            if (rect == null) {
                return;
            }
            rect.scale(applicationInvertedScale);
        }

+2 −3
Original line number Diff line number Diff line
@@ -1139,7 +1139,7 @@ public abstract class WallpaperService extends Service {

                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mRequestedVisibilities, inputChannel,
                                mInsetsState, mTempControls) < 0) {
                                mInsetsState, mTempControls, new Rect()) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
@@ -1171,8 +1171,7 @@ public abstract class WallpaperService extends Service {
                        mInsetsState.getDisplayCutoutSafe(displayCutoutSafe);
                        mWindowLayout.computeFrames(mLayout, mInsetsState, displayCutoutSafe,
                                winConfig.getBounds(), winConfig.getWindowingMode(), mWidth,
                                mHeight, mRequestedVisibilities, null /* attachedWindowFrame */,
                                1f /* compatScale */, mWinFrames);
                                mHeight, mRequestedVisibilities, 1f /* compatScale */, mWinFrames);

                        mSession.updateLayout(mWindow, mLayout, 0 /* flags */, mWinFrames, mWidth,
                                mHeight);
+5 −3
Original line number Diff line number Diff line
@@ -50,13 +50,15 @@ interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in InsetsVisibilities requestedVisibilities,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls);
            out InsetsSourceControl[] activeControls, out Rect attachedFrame);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId,
            in InsetsVisibilities requestedVisibilities, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls);
            out InsetsState insetsState, out InsetsSourceControl[] activeControls,
            out Rect attachedFrame);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out InsetsState insetsState);
            in int viewVisibility, in int layerStackId, out InsetsState insetsState,
            out Rect attachedFrame);
    @UnsupportedAppUsage
    void remove(IWindow window);

+21 −20
Original line number Diff line number Diff line
@@ -60,13 +60,11 @@ import static android.view.WindowInsetsController.BEHAVIOR_DEFAULT;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
import static android.view.WindowLayout.UNSPECIFIED_LENGTH;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
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_SUB_WINDOW;
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.PRIVATE_FLAG_APPEARANCE_CONTROLLED;
@@ -77,7 +75,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INSET_PARENT_
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL;
@@ -567,8 +564,6 @@ public final class ViewRootImpl implements ViewParent,

    private final WindowLayout mWindowLayout;

    private ViewRootImpl mParentViewRoot;

    // This is used to reduce the race between window focus changes being dispatched from
    // the window manager and input events coming through the input system.
    @GuardedBy("this")
@@ -1196,7 +1191,6 @@ public final class ViewRootImpl implements ViewParent,
                if (panelParentView != null) {
                    mAttachInfo.mPanelParentWindowToken
                            = panelParentView.getApplicationWindowToken();
                    mParentViewRoot = panelParentView.getViewRootImpl();
                }
                mAdded = true;
                int res; /* = WindowManagerImpl.ADD_OKAY; */
@@ -1227,14 +1221,21 @@ public final class ViewRootImpl implements ViewParent,
                    collectViewAttributes();
                    adjustLayoutParamsForCompatibility(mWindowAttributes);
                    controlInsetsForCompatibility(mWindowAttributes);

                    Rect attachedFrame = new Rect();
                    res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
                            getHostVisibility(), mDisplay.getDisplayId(), userId,
                            mInsetsController.getRequestedVisibilities(), inputChannel, mTempInsets,
                            mTempControls);
                            mTempControls, attachedFrame);
                    if (!attachedFrame.isValid()) {
                        attachedFrame = null;
                    }
                    if (mTranslator != null) {
                        mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                        mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
                        mTranslator.translateRectInScreenToAppWindow(attachedFrame);
                    }
                    mTmpFrames.attachedFrame = attachedFrame;
                } catch (RemoteException e) {
                    mAdded = false;
                    mView = null;
@@ -1261,8 +1262,8 @@ public final class ViewRootImpl implements ViewParent,
                mWindowLayout.computeFrames(mWindowAttributes, state,
                        displayCutoutSafe, winConfig.getBounds(), winConfig.getWindowingMode(),
                        UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH,
                        mInsetsController.getRequestedVisibilities(),
                        getAttachedWindowFrame(), 1f /* compactScale */, mTmpFrames);
                        mInsetsController.getRequestedVisibilities(), 1f /* compactScale */,
                        mTmpFrames);
                setFrame(mTmpFrames.frame);
                registerBackCallbackOnWindow();
                if (!WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
@@ -1384,14 +1385,6 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    private Rect getAttachedWindowFrame() {
        final int type = mWindowAttributes.type;
        final boolean layoutAttached = (mParentViewRoot != null
                && type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW
                && type != TYPE_APPLICATION_ATTACHED_DIALOG);
        return layoutAttached ? mParentViewRoot.mWinFrame : null;
    }

    /**
     * Register any kind of listeners if setView was success.
     */
@@ -1749,16 +1742,20 @@ public final class ViewRootImpl implements ViewParent,

        final Rect frame = frames.frame;
        final Rect displayFrame = frames.displayFrame;
        final Rect attachedFrame = frames.attachedFrame;
        if (mTranslator != null) {
            mTranslator.translateRectInScreenToAppWindow(frame);
            mTranslator.translateRectInScreenToAppWindow(displayFrame);
            mTranslator.translateRectInScreenToAppWindow(attachedFrame);
        }
        final boolean frameChanged = !mWinFrame.equals(frame);
        final boolean configChanged = !mLastReportedMergedConfiguration.equals(mergedConfiguration);
        final boolean attachedFrameChanged = LOCAL_LAYOUT
                && !Objects.equals(mTmpFrames.attachedFrame, attachedFrame);
        final boolean displayChanged = mDisplay.getDisplayId() != displayId;
        final boolean resizeModeChanged = mResizeMode != resizeMode;
        if (msg == MSG_RESIZED && !frameChanged && !configChanged && !displayChanged
                && !resizeModeChanged && !forceNextWindowRelayout) {
        if (msg == MSG_RESIZED && !frameChanged && !configChanged && !attachedFrameChanged
                && !displayChanged && !resizeModeChanged && !forceNextWindowRelayout) {
            return;
        }

@@ -1776,6 +1773,9 @@ public final class ViewRootImpl implements ViewParent,

        setFrame(frame);
        mTmpFrames.displayFrame.set(displayFrame);
        if (mTmpFrames.attachedFrame != null && attachedFrame != null) {
            mTmpFrames.attachedFrame.set(attachedFrame);
        }

        if (mDragResizing && mUseMTRenderer) {
            boolean fullscreen = frame.equals(mPendingBackDropFrame);
@@ -8068,7 +8068,7 @@ public final class ViewRootImpl implements ViewParent,
            mWindowLayout.computeFrames(mWindowAttributes, state, displayCutoutSafe,
                    winConfig.getBounds(), winConfig.getWindowingMode(), requestedWidth,
                    requestedHeight, mInsetsController.getRequestedVisibilities(),
                    getAttachedWindowFrame(), 1f /* compatScale */, mTmpFrames);
                    1f /* compatScale */, mTmpFrames);

            mWindowSession.updateLayout(mWindow, params,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mTmpFrames,
@@ -8088,6 +8088,7 @@ public final class ViewRootImpl implements ViewParent,
            if (mTranslator != null) {
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
                mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
            }
Loading