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

Commit 9dbae141 authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Send the attached frame to the client" into tm-qpr-dev am: 228988d5

parents 5e3399b1 228988d5
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line 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_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;


import android.graphics.Rect;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.perftests.utils.ManualBenchmarkState;
import android.perftests.utils.ManualBenchmarkState;
@@ -86,6 +87,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
        final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities();
        final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
        final Rect mOutAttachedFrame = new Rect();


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


+4 −1
Original line number Original line 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.
         * Translate a Rect in screen coordinates into the app window's coordinates.
         */
         */
        @UnsupportedAppUsage
        @UnsupportedAppUsage
        public void translateRectInScreenToAppWindow(Rect rect) {
        public void translateRectInScreenToAppWindow(@Nullable Rect rect) {
            if (rect == null) {
                return;
            }
            rect.scale(applicationInvertedScale);
            rect.scale(applicationInvertedScale);
        }
        }


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


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


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


+21 −20
Original line number Original line 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.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
import static android.view.WindowLayout.UNSPECIFIED_LENGTH;
import static android.view.WindowLayout.UNSPECIFIED_LENGTH;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
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_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
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_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
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.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_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_APPEARANCE_CONTROLLED;
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.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_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
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_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL;
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 final WindowLayout mWindowLayout;


    private ViewRootImpl mParentViewRoot;

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

                    Rect attachedFrame = new Rect();
                    res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
                    res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
                            getHostVisibility(), mDisplay.getDisplayId(), userId,
                            getHostVisibility(), mDisplay.getDisplayId(), userId,
                            mInsetsController.getRequestedVisibilities(), inputChannel, mTempInsets,
                            mInsetsController.getRequestedVisibilities(), inputChannel, mTempInsets,
                            mTempControls);
                            mTempControls, attachedFrame);
                    if (!attachedFrame.isValid()) {
                        attachedFrame = null;
                    }
                    if (mTranslator != null) {
                    if (mTranslator != null) {
                        mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                        mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                        mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
                        mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
                        mTranslator.translateRectInScreenToAppWindow(attachedFrame);
                    }
                    }
                    mTmpFrames.attachedFrame = attachedFrame;
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    mAdded = false;
                    mAdded = false;
                    mView = null;
                    mView = null;
@@ -1260,8 +1261,8 @@ public final class ViewRootImpl implements ViewParent,
                mWindowLayout.computeFrames(mWindowAttributes, state,
                mWindowLayout.computeFrames(mWindowAttributes, state,
                        displayCutoutSafe, winConfig.getBounds(), winConfig.getWindowingMode(),
                        displayCutoutSafe, winConfig.getBounds(), winConfig.getWindowingMode(),
                        UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH,
                        UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH,
                        mInsetsController.getRequestedVisibilities(),
                        mInsetsController.getRequestedVisibilities(), 1f /* compactScale */,
                        getAttachedWindowFrame(), 1f /* compactScale */, mTmpFrames);
                        mTmpFrames);
                setFrame(mTmpFrames.frame);
                setFrame(mTmpFrames.frame);
                registerBackCallbackOnWindow();
                registerBackCallbackOnWindow();
                if (!WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
                if (!WindowOnBackInvokedDispatcher.isOnBackInvokedCallbackEnabled(mContext)) {
@@ -1386,14 +1387,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.
     * Register any kind of listeners if setView was success.
     */
     */
@@ -1751,16 +1744,20 @@ public final class ViewRootImpl implements ViewParent,


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


@@ -1778,6 +1775,9 @@ public final class ViewRootImpl implements ViewParent,


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


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


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