diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java index f7bca5bfe1887..d75ff2fc7dc29 100644 --- a/core/java/android/view/SurfaceControlViewHost.java +++ b/core/java/android/view/SurfaceControlViewHost.java @@ -29,8 +29,6 @@ import android.os.Parcelable; import android.os.RemoteException; import android.util.Log; import android.window.WindowTokenClient; -import android.view.InsetsState; -import android.view.WindowManagerGlobal; import android.view.accessibility.IAccessibilityEmbeddedConnection; import java.util.Objects; @@ -280,7 +278,7 @@ public class SurfaceControlViewHost { public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d, @NonNull WindowlessWindowManager wwm, boolean useSfChoreographer) { mWm = wwm; - mViewRoot = new ViewRootImpl(c, d, mWm, useSfChoreographer); + mViewRoot = new ViewRootImpl(c, d, mWm, new WindowlessWindowLayout(), useSfChoreographer); addConfigCallback(c, d); WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot); @@ -310,7 +308,7 @@ public class SurfaceControlViewHost { mWm = new WindowlessWindowManager(context.getResources().getConfiguration(), mSurfaceControl, hostToken); - mViewRoot = new ViewRootImpl(context, display, mWm); + mViewRoot = new ViewRootImpl(context, display, mWm, new WindowlessWindowLayout()); addConfigCallback(context, display); WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 27a9162443c01..2900a53c839ac 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -564,7 +564,7 @@ public final class ViewRootImpl implements ViewParent, private final Rect mVisRect = new Rect(); // used to retrieve visible rect of focused view. private final Rect mTempRect = new Rect(); - private final WindowLayout mWindowLayout = new WindowLayout(); + private final WindowLayout mWindowLayout; private ViewRootImpl mParentViewRoot; @@ -861,18 +861,20 @@ public final class ViewRootImpl implements ViewParent, private String mTag = TAG; public ViewRootImpl(Context context, Display display) { - this(context, display, WindowManagerGlobal.getWindowSession(), + this(context, display, WindowManagerGlobal.getWindowSession(), new WindowLayout(), false /* useSfChoreographer */); } - public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session) { - this(context, display, session, false /* useSfChoreographer */); + public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, + WindowLayout windowLayout) { + this(context, display, session, windowLayout, false /* useSfChoreographer */); } public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, - boolean useSfChoreographer) { + WindowLayout windowLayout, boolean useSfChoreographer) { mContext = context; mWindowSession = session; + mWindowLayout = windowLayout; mDisplay = display; mBasePackageName = context.getBasePackageName(); mThread = Thread.currentThread(); diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index aae930edb7299..85a5762f7f3d0 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -386,7 +386,7 @@ public final class WindowManagerGlobal { root = new ViewRootImpl(view.getContext(), display); } else { root = new ViewRootImpl(view.getContext(), display, - windowlessSession); + windowlessSession, new WindowlessWindowLayout()); } view.setLayoutParams(wparams); diff --git a/core/java/android/view/WindowlessWindowLayout.java b/core/java/android/view/WindowlessWindowLayout.java new file mode 100644 index 0000000000000..7cc50c579d0d6 --- /dev/null +++ b/core/java/android/view/WindowlessWindowLayout.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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; + +import android.app.WindowConfiguration.WindowingMode; +import android.graphics.Rect; +import android.window.ClientWindowFrames; + +/** + * Computes window frames for the windowless window. + * @hide + */ +public class WindowlessWindowLayout extends WindowLayout { + + @Override + public void computeFrames(WindowManager.LayoutParams attrs, InsetsState state, + Rect displayCutoutSafe, Rect windowBounds, @WindowingMode int windowingMode, + int requestedWidth, int requestedHeight, InsetsVisibilities requestedVisibilities, + Rect attachedWindowFrame, float compatScale, ClientWindowFrames outFrames) { + outFrames.frame.set(0, 0, attrs.width, attrs.height); + outFrames.displayFrame.set(outFrames.frame); + outFrames.parentFrame.set(outFrames.frame); + } +} +