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

Commit fe4f84bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove Session#getDisplayFrame"

parents 63c6d398 ccaeffc0
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
@@ -21,14 +21,12 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat
import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.RemoteException;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfTestActivity;
import android.platform.test.annotations.Presubmit;
import android.util.MergedConfiguration;
import android.view.DisplayCutout;
import android.view.IWindow;
import android.view.IWindowSession;
import android.view.InsetsSourceControl;
@@ -38,6 +36,7 @@ import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.widget.LinearLayout;
import android.window.ClientWindowFrames;

import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -125,13 +124,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
    }

    private static class RelayoutRunner {
        final Rect mOutFrame = new Rect();
        final Rect mOutContentInsets = new Rect();
        final Rect mOutVisibleInsets = new Rect();
        final Rect mOutStableInsets = new Rect();
        final Rect mOutBackDropFrame = new Rect();
        final DisplayCutout.ParcelableWrapper mOutDisplayCutout =
                new DisplayCutout.ParcelableWrapper(DisplayCutout.NO_CUTOUT);
        final ClientWindowFrames mOutFrames = new ClientWindowFrames();
        final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
        final InsetsState mOutInsetsState = new InsetsState();
        final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
@@ -164,11 +157,9 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
            final IWindowSession session = WindowManagerGlobal.getWindowSession();
            while (state.keepRunning()) {
                session.relayout(mWindow, mSeq, mParams, mWidth, mHeight,
                        mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrame,
                        mOutContentInsets, mOutVisibleInsets, mOutStableInsets,
                        mOutBackDropFrame, mOutDisplayCutout, mOutMergedConfiguration,
                        mOutSurfaceControl, mOutInsetsState, mOutControls, mOutSurfaceSize,
                        mOutBlastSurfaceControl);
                        mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrames,
                        mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls,
                        mOutSurfaceSize, mOutBlastSurfaceControl);
            }
        }
    }
+29 −40
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.window.ClientWindowFrames;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.HandlerCaller;
@@ -186,17 +187,11 @@ public abstract class WallpaperService extends Service {
        int mCurWindowFlags = mWindowFlags;
        int mCurWindowPrivateFlags = mWindowPrivateFlags;
        Rect mPreviewSurfacePosition;
        final Rect mVisibleInsets = new Rect();
        final Rect mWinFrame = new Rect();
        final Rect mContentInsets = new Rect();
        final Rect mStableInsets = new Rect();
        final ClientWindowFrames mWinFrames = new ClientWindowFrames();
        final Rect mDispatchedContentInsets = new Rect();
        final Rect mDispatchedStableInsets = new Rect();
        final Rect mFinalSystemInsets = new Rect();
        final Rect mFinalStableInsets = new Rect();
        final Rect mBackdropFrame = new Rect();
        final DisplayCutout.ParcelableWrapper mDisplayCutout =
                new DisplayCutout.ParcelableWrapper();
        DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
        final InsetsState mInsetsState = new InsetsState();
        final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0];
@@ -332,11 +327,9 @@ public abstract class WallpaperService extends Service {

        final BaseIWindow mWindow = new BaseIWindow() {
            @Override
            public void resized(Rect frame, Rect contentInsets,
                    Rect visibleInsets, Rect stableInsets, boolean reportDraw,
                    MergedConfiguration mergedConfiguration, Rect backDropRect, boolean forceLayout,
                    boolean alwaysConsumeSystemBars, int displayId,
                    DisplayCutout.ParcelableWrapper displayCutout) {
            public void resized(ClientWindowFrames frames, boolean reportDraw,
                    MergedConfiguration mergedConfiguration, boolean forceLayout,
                    boolean alwaysConsumeSystemBars, int displayId) {
                Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0);
                mCaller.sendMessage(msg);
@@ -749,10 +742,7 @@ public abstract class WallpaperService extends Service {
                    out.print(" mCurWindowFlags="); out.println(mCurWindowFlags);
            out.print(prefix); out.print("mWindowPrivateFlags="); out.print(mWindowPrivateFlags);
                    out.print(" mCurWindowPrivateFlags="); out.println(mCurWindowPrivateFlags);
            out.print(prefix); out.print("mVisibleInsets=");
                    out.print(mVisibleInsets.toShortString());
                    out.print(" mWinFrame="); out.print(mWinFrame.toShortString());
                    out.print(" mContentInsets="); out.println(mContentInsets.toShortString());
            out.print(prefix); out.println("mWinFrames="); out.println(mWinFrames);
            out.print(prefix); out.print("mConfiguration=");
                    out.println(mMergedConfiguration.getMergedConfiguration());
            out.print(prefix); out.print("mLayout="); out.println(mLayout);
@@ -890,8 +880,8 @@ public abstract class WallpaperService extends Service {
                        InputChannel inputChannel = new InputChannel();

                        if (mSession.addToDisplay(mWindow, mWindow.mSeq, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mWinFrame, mContentInsets, mStableInsets,
                                mDisplayCutout, inputChannel,
                                mDisplay.getDisplayId(), mWinFrames.frame, mWinFrames.contentInsets,
                                mWinFrames.stableInsets, mWinFrames.displayCutout, inputChannel,
                                mInsetsState, mTempControls) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
@@ -914,34 +904,32 @@ public abstract class WallpaperService extends Service {

                    final int relayoutResult = mSession.relayout(
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, -1, mWinFrame, mContentInsets,
                            mVisibleInsets, mStableInsets, mBackdropFrame,
                            mDisplayCutout, mMergedConfiguration, mSurfaceControl,
                            View.VISIBLE, 0, -1, mWinFrames, mMergedConfiguration, mSurfaceControl,
                            mInsetsState, mTempControls, mSurfaceSize, mTmpSurfaceControl);
                    if (mSurfaceControl.isValid()) {
                        mSurfaceHolder.mSurface.copyFrom(mSurfaceControl);
                    }

                    if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
                            + ", frame=" + mWinFrame);
                            + ", frame=" + mWinFrames);

                    int w = mWinFrame.width();
                    int h = mWinFrame.height();
                    int w = mWinFrames.frame.width();
                    int h = mWinFrames.frame.height();

                    if (!fixedSize) {
                        final Rect padding = mIWallpaperEngine.mDisplayPadding;
                        w += padding.left + padding.right;
                        h += padding.top + padding.bottom;
                        mContentInsets.left += padding.left;
                        mContentInsets.top += padding.top;
                        mContentInsets.right += padding.right;
                        mContentInsets.bottom += padding.bottom;
                        mStableInsets.left += padding.left;
                        mStableInsets.top += padding.top;
                        mStableInsets.right += padding.right;
                        mStableInsets.bottom += padding.bottom;
                        mDisplayCutout.set(mDisplayCutout.get().inset(-padding.left, -padding.top,
                                -padding.right, -padding.bottom));
                        mWinFrames.contentInsets.left += padding.left;
                        mWinFrames.contentInsets.top += padding.top;
                        mWinFrames.contentInsets.right += padding.right;
                        mWinFrames.contentInsets.bottom += padding.bottom;
                        mWinFrames.stableInsets.left += padding.left;
                        mWinFrames.stableInsets.top += padding.top;
                        mWinFrames.stableInsets.right += padding.right;
                        mWinFrames.stableInsets.bottom += padding.bottom;
                        mWinFrames.displayCutout.set(mWinFrames.displayCutout.get().inset(
                                -padding.left, -padding.top, -padding.right, -padding.bottom));
                    } else {
                        w = myWidth;
                        h = myHeight;
@@ -960,9 +948,10 @@ public abstract class WallpaperService extends Service {
                        Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight);
                    }

                    insetsChanged |= !mDispatchedContentInsets.equals(mContentInsets);
                    insetsChanged |= !mDispatchedStableInsets.equals(mStableInsets);
                    insetsChanged |= !mDispatchedDisplayCutout.equals(mDisplayCutout.get());
                    final DisplayCutout displayCutout = mWinFrames.displayCutout.get();
                    insetsChanged |= !mDispatchedContentInsets.equals(mWinFrames.contentInsets);
                    insetsChanged |= !mDispatchedStableInsets.equals(mWinFrames.stableInsets);
                    insetsChanged |= !mDispatchedDisplayCutout.equals(displayCutout);

                    mSurfaceHolder.setSurfaceFrameSize(w, h);
                    mSurfaceHolder.mSurfaceLock.unlock();
@@ -1021,9 +1010,9 @@ public abstract class WallpaperService extends Service {
                        }

                        if (insetsChanged) {
                            mDispatchedContentInsets.set(mContentInsets);
                            mDispatchedStableInsets.set(mStableInsets);
                            mDispatchedDisplayCutout = mDisplayCutout.get();
                            mDispatchedContentInsets.set(mWinFrames.contentInsets);
                            mDispatchedStableInsets.set(mWinFrames.stableInsets);
                            mDispatchedDisplayCutout = displayCutout;
                            mFinalStableInsets.set(mDispatchedStableInsets);
                            WindowInsets insets = new WindowInsets(mFinalSystemInsets,
                                    mFinalStableInsets,
+4 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.InsetsState;
import android.view.IScrollCaptureController;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.window.ClientWindowFrames;

import com.android.internal.os.IResultReceiver;

@@ -52,11 +53,9 @@ oneway interface IWindow {
     */
    void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);

    void resized(in Rect frame, in Rect contentInsets,
            in Rect visibleInsets, in Rect stableInsets, boolean reportDraw,
            in MergedConfiguration newMergedConfiguration, in Rect backDropFrame,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            in DisplayCutout.ParcelableWrapper displayCutout);
    void resized(in ClientWindowFrames frames, boolean reportDraw,
            in MergedConfiguration newMergedConfiguration,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId);

    /**
     * Called when the window location in parent display has changed. The offset will only be a
+2 −10
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.view.InsetsState;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.window.ClientWindowFrames;

import java.util.List;

@@ -107,10 +108,7 @@ interface IWindowSession {
     */
    int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            int requestedWidth, int requestedHeight, int viewVisibility,
            int flags, long frameNumber, out Rect outFrame,
            out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
            out Rect outBackdropFrame,
            out DisplayCutout.ParcelableWrapper displayCutout,
            int flags, long frameNumber, out ClientWindowFrames outFrames,
            out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls,
            out Point outSurfaceSize, out SurfaceControl outBlastSurfaceControl);
@@ -151,12 +149,6 @@ interface IWindowSession {
    void setInsets(IWindow window, int touchableInsets, in Rect contentInsets,
            in Rect visibleInsets, in Region touchableRegion);

    /**
     * Return the current display size in which the window is being laid out,
     * accounting for screen decorations around it.
     */
    void getDisplayFrame(IWindow window, out Rect outDisplayFrame);

    /**
     * Called when the client has finished drawing the surface, if needed.
     *
+2 −14
Original line number Diff line number Diff line
@@ -14940,20 +14940,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * inside.  In effect, this tells you the available area where content can
     * be placed and remain visible to users.
     *
     * <p>This function requires an IPC back to the window manager to retrieve
     * the requested information, so should not be used in performance critical
     * code like drawing.
     *
     * @param outRect Filled in with the visible display frame.  If the view
     * is not attached to a window, this is simply the raw display size.
     */
    public void getWindowVisibleDisplayFrame(Rect outRect) {
        if (mAttachInfo != null) {
            try {
                mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
            } catch (RemoteException e) {
                return;
            }
            mAttachInfo.mViewRootImpl.getDisplayFrame(outRect);
            // XXX This is really broken, and probably all needs to be done
            // in the window manager, and we need to know more about whether
            // we want the area behind or in front of the IME.
@@ -14979,11 +14971,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    @UnsupportedAppUsage
    public void getWindowDisplayFrame(Rect outRect) {
        if (mAttachInfo != null) {
            try {
                mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
            } catch (RemoteException e) {
                return;
            }
            mAttachInfo.mViewRootImpl.getDisplayFrame(outRect);
            return;
        }
        // The view is not attached to a display so we don't have a context.
Loading