diff options
18 files changed, 199 insertions, 142 deletions
diff --git a/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java b/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java index 452bb0ab5909..06207215b7be 100644 --- a/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java +++ b/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java @@ -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); diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java index 439c6396f1d0..608e34bd07b4 100644 --- a/core/java/android/content/res/CompatibilityInfo.java +++ b/core/java/android/content/res/CompatibilityInfo.java @@ -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); } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9679a6ab3acb..eb2d64727fc1 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -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); diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 8954a1eaf146..4bf68e23b79f 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -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); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9d671136c6fe..beaa1a37da1d 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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)) { @@ -1387,14 +1388,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. */ @@ -1752,16 +1745,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; } @@ -1779,6 +1776,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); @@ -8073,7 +8073,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, @@ -8093,6 +8093,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); } diff --git a/core/java/android/view/WindowLayout.java b/core/java/android/view/WindowLayout.java index c320b262ebd7..9b6b2b906e8e 100644 --- a/core/java/android/view/WindowLayout.java +++ b/core/java/android/view/WindowLayout.java @@ -66,14 +66,15 @@ public class WindowLayout { 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) { + float compatScale, ClientWindowFrames frames) { final int type = attrs.type; final int fl = attrs.flags; final int pfl = attrs.privateFlags; final boolean layoutInScreen = (fl & FLAG_LAYOUT_IN_SCREEN) == FLAG_LAYOUT_IN_SCREEN; - final Rect outDisplayFrame = outFrames.displayFrame; - final Rect outParentFrame = outFrames.parentFrame; - final Rect outFrame = outFrames.frame; + final Rect attachedWindowFrame = frames.attachedFrame; + final Rect outDisplayFrame = frames.displayFrame; + final Rect outParentFrame = frames.parentFrame; + final Rect outFrame = frames.frame; // Compute bounds restricted by insets final Insets insets = state.calculateInsets(windowBounds, attrs.getFitInsetsTypes(), @@ -104,7 +105,7 @@ public class WindowLayout { final DisplayCutout cutout = state.getDisplayCutout(); final Rect displayCutoutSafeExceptMaybeBars = mTempDisplayCutoutSafeExceptMaybeBarsRect; displayCutoutSafeExceptMaybeBars.set(displayCutoutSafe); - outFrames.isParentFrameClippedByDisplayCutout = false; + frames.isParentFrameClippedByDisplayCutout = false; if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS && !cutout.isEmpty()) { // Ensure that windows with a non-ALWAYS display cutout mode are laid out in // the cutout safe zone. @@ -167,7 +168,7 @@ public class WindowLayout { if (!attachedInParent && !floatingInScreenWindow) { mTempRect.set(outParentFrame); outParentFrame.intersectUnchecked(displayCutoutSafeExceptMaybeBars); - outFrames.isParentFrameClippedByDisplayCutout = !mTempRect.equals(outParentFrame); + frames.isParentFrameClippedByDisplayCutout = !mTempRect.equals(outParentFrame); } outDisplayFrame.intersectUnchecked(displayCutoutSafeExceptMaybeBars); } @@ -287,12 +288,9 @@ public class WindowLayout { } } - if (DEBUG) Log.d(TAG, "computeWindowFrames " + attrs.getTitle() - + " outFrames=" + outFrames + if (DEBUG) Log.d(TAG, "computeFrames " + attrs.getTitle() + + " frames=" + frames + " windowBounds=" + windowBounds.toShortString() - + " attachedWindowFrame=" + (attachedWindowFrame != null - ? attachedWindowFrame.toShortString() - : "null") + " requestedWidth=" + requestedWidth + " requestedHeight=" + requestedHeight + " compatScale=" + compatScale diff --git a/core/java/android/view/WindowlessWindowLayout.java b/core/java/android/view/WindowlessWindowLayout.java index 7cc50c579d0d..5bec5b6b6722 100644 --- a/core/java/android/view/WindowlessWindowLayout.java +++ b/core/java/android/view/WindowlessWindowLayout.java @@ -30,10 +30,10 @@ public class WindowlessWindowLayout extends WindowLayout { 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); + float compatScale, ClientWindowFrames frames) { + frames.frame.set(0, 0, attrs.width, attrs.height); + frames.displayFrame.set(frames.frame); + frames.parentFrame.set(frames.frame); } } diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java index 5832347c1947..3a72f6e069a5 100644 --- a/core/java/android/view/WindowlessWindowManager.java +++ b/core/java/android/view/WindowlessWindowManager.java @@ -149,7 +149,7 @@ public class WindowlessWindowManager implements IWindowSession { public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, int displayId, InsetsVisibilities requestedVisibilities, InputChannel outInputChannel, InsetsState outInsetsState, - InsetsSourceControl[] outActiveControls) { + InsetsSourceControl[] outActiveControls, Rect outAttachedFrame) { final SurfaceControl.Builder b = new SurfaceControl.Builder(mSurfaceSession) .setFormat(attrs.format) .setBLASTLayer() @@ -181,6 +181,7 @@ public class WindowlessWindowManager implements IWindowSession { synchronized (this) { mStateForWindow.put(window.asBinder(), state); } + outAttachedFrame.set(0, 0, -1, -1); final int res = WindowManagerGlobal.ADD_OKAY | WindowManagerGlobal.ADD_FLAG_APP_VISIBLE | WindowManagerGlobal.ADD_FLAG_USE_BLAST; @@ -196,15 +197,15 @@ public class WindowlessWindowManager implements IWindowSession { public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, int displayId, int userId, InsetsVisibilities requestedVisibilities, InputChannel outInputChannel, InsetsState outInsetsState, - InsetsSourceControl[] outActiveControls) { + InsetsSourceControl[] outActiveControls, Rect outAttachedFrame) { return addToDisplay(window, attrs, viewVisibility, displayId, requestedVisibilities, - outInputChannel, outInsetsState, outActiveControls); + outInputChannel, outInsetsState, outActiveControls, outAttachedFrame); } @Override public int addToDisplayWithoutInputChannel(android.view.IWindow window, android.view.WindowManager.LayoutParams attrs, int viewVisibility, int layerStackId, - android.view.InsetsState insetsState) { + android.view.InsetsState insetsState, Rect outAttachedFrame) { return 0; } diff --git a/core/java/android/window/ClientWindowFrames.java b/core/java/android/window/ClientWindowFrames.java index 51f3fe2551ad..929e81ed9044 100644 --- a/core/java/android/window/ClientWindowFrames.java +++ b/core/java/android/window/ClientWindowFrames.java @@ -17,6 +17,7 @@ package android.window; import android.annotation.NonNull; +import android.annotation.Nullable; import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; @@ -40,6 +41,12 @@ public class ClientWindowFrames implements Parcelable { */ public final @NonNull Rect parentFrame = new Rect(); + /** + * The frame this window attaches to. If this is not null, this is the frame of the parent + * window. + */ + public @Nullable Rect attachedFrame; + public boolean isParentFrameClippedByDisplayCutout; public ClientWindowFrames() { @@ -49,6 +56,9 @@ public class ClientWindowFrames implements Parcelable { frame.set(other.frame); displayFrame.set(other.displayFrame); parentFrame.set(other.parentFrame); + if (other.attachedFrame != null) { + attachedFrame = new Rect(other.attachedFrame); + } isParentFrameClippedByDisplayCutout = other.isParentFrameClippedByDisplayCutout; } @@ -61,6 +71,7 @@ public class ClientWindowFrames implements Parcelable { frame.readFromParcel(in); displayFrame.readFromParcel(in); parentFrame.readFromParcel(in); + attachedFrame = in.readTypedObject(Rect.CREATOR); isParentFrameClippedByDisplayCutout = in.readBoolean(); } @@ -69,6 +80,7 @@ public class ClientWindowFrames implements Parcelable { frame.writeToParcel(dest, flags); displayFrame.writeToParcel(dest, flags); parentFrame.writeToParcel(dest, flags); + dest.writeTypedObject(attachedFrame, flags); dest.writeBoolean(isParentFrameClippedByDisplayCutout); } @@ -78,6 +90,7 @@ public class ClientWindowFrames implements Parcelable { return "ClientWindowFrames{frame=" + frame.toShortString(sb) + " display=" + displayFrame.toShortString(sb) + " parentFrame=" + parentFrame.toShortString(sb) + + (attachedFrame != null ? " attachedFrame=" + attachedFrame.toShortString() : "") + " parentClippedByDisplayCutout=" + isParentFrameClippedByDisplayCutout + "}"; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java index 95bc579a4a51..0d309c1cc21a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java @@ -238,7 +238,8 @@ public class TaskSnapshotWindow { try { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#addToDisplay"); final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId, - info.requestedVisibilities, tmpInputChannel, tmpInsetsState, tmpControls); + info.requestedVisibilities, tmpInputChannel, tmpInsetsState, tmpControls, + new Rect()); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); if (res < 0) { Slog.w(TAG, "Failed to add snapshot starting window res=" + res); @@ -260,8 +261,8 @@ public class TaskSnapshotWindow { tmpMergedConfiguration.getMergedConfiguration().windowConfiguration; windowLayout.computeFrames(layoutParams, tmpInsetsState, displayCutoutSafe, winConfig.getBounds(), winConfig.getWindowingMode(), UNSPECIFIED_LENGTH, - UNSPECIFIED_LENGTH, info.requestedVisibilities, - null /* attachedWindowFrame */, 1f /* compatScale */, tmpFrames); + UNSPECIFIED_LENGTH, info.requestedVisibilities, 1f /* compatScale */, + tmpFrames); session.updateLayout(window, layoutParams, 0 /* flags */, tmpFrames, UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH); } else { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java index 630d0d2c827c..14d8ce4682c6 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java @@ -249,7 +249,8 @@ public class StartingSurfaceDrawerTests { any() /* window */, any() /* attrs */, anyInt() /* viewVisibility */, anyInt() /* displayId */, any() /* requestedVisibility */, any() /* outInputChannel */, - any() /* outInsetsState */, any() /* outActiveControls */); + any() /* outInsetsState */, any() /* outActiveControls */, + any() /* outAttachedFrame */); TaskSnapshotWindow mockSnapshotWindow = TaskSnapshotWindow.create(windowInfo, mBinder, snapshot, mTestExecutor, () -> { diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 5c1fc653586e..d3af7d2a19e4 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1523,13 +1523,14 @@ public class DisplayPolicy { */ void simulateLayoutDisplay(DisplayFrames displayFrames) { final InsetsStateController controller = mDisplayContent.getInsetsStateController(); + sTmpClientFrames.attachedFrame = null; for (int i = mInsetsSourceWindowsExceptIme.size() - 1; i >= 0; i--) { final WindowState win = mInsetsSourceWindowsExceptIme.valueAt(i); mWindowLayout.computeFrames(win.mAttrs.forRotation(displayFrames.mRotation), displayFrames.mInsetsState, displayFrames.mDisplayCutoutSafe, displayFrames.mUnrestricted, win.getWindowingMode(), UNSPECIFIED_LENGTH, - UNSPECIFIED_LENGTH, win.getRequestedVisibilities(), - null /* attachedWindowFrame */, win.mGlobalScale, sTmpClientFrames); + UNSPECIFIED_LENGTH, win.getRequestedVisibilities(), win.mGlobalScale, + sTmpClientFrames); final SparseArray<InsetsSource> sources = win.getProvidedInsetsSources(); final InsetsState state = displayFrames.mInsetsState; for (int index = sources.size() - 1; index >= 0; index--) { @@ -1541,13 +1542,14 @@ public class DisplayPolicy { } void updateInsetsSourceFramesExceptIme(DisplayFrames displayFrames) { + sTmpClientFrames.attachedFrame = null; for (int i = mInsetsSourceWindowsExceptIme.size() - 1; i >= 0; i--) { final WindowState win = mInsetsSourceWindowsExceptIme.valueAt(i); mWindowLayout.computeFrames(win.mAttrs.forRotation(displayFrames.mRotation), displayFrames.mInsetsState, displayFrames.mDisplayCutoutSafe, displayFrames.mUnrestricted, win.getWindowingMode(), UNSPECIFIED_LENGTH, - UNSPECIFIED_LENGTH, win.getRequestedVisibilities(), - null /* attachedWindowFrame */, win.mGlobalScale, sTmpClientFrames); + UNSPECIFIED_LENGTH, win.getRequestedVisibilities(), win.mGlobalScale, + sTmpClientFrames); win.updateSourceFrame(sTmpClientFrames.frame); } } @@ -1577,7 +1579,7 @@ public class DisplayPolicy { displayFrames = win.getDisplayFrames(displayFrames); final WindowManager.LayoutParams attrs = win.mAttrs.forRotation(displayFrames.mRotation); - final Rect attachedWindowFrame = attached != null ? attached.getFrame() : null; + sTmpClientFrames.attachedFrame = attached != null ? attached.getFrame() : null; // If this window has different LayoutParams for rotations, we cannot trust its requested // size. Because it might have not sent its requested size for the new rotation. @@ -1587,8 +1589,7 @@ public class DisplayPolicy { mWindowLayout.computeFrames(attrs, win.getInsetsState(), displayFrames.mDisplayCutoutSafe, win.getBounds(), win.getWindowingMode(), requestedWidth, requestedHeight, - win.getRequestedVisibilities(), attachedWindowFrame, win.mGlobalScale, - sTmpClientFrames); + win.getRequestedVisibilities(), win.mGlobalScale, sTmpClientFrames); win.setFrames(sTmpClientFrames, win.mRequestedWidth, win.mRequestedHeight); } diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index 8d03e2e9632a..ff6a45423084 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -195,27 +195,28 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, int displayId, InsetsVisibilities requestedVisibilities, InputChannel outInputChannel, InsetsState outInsetsState, - InsetsSourceControl[] outActiveControls) { + InsetsSourceControl[] outActiveControls, Rect outAttachedFrame) { return mService.addWindow(this, window, attrs, viewVisibility, displayId, UserHandle.getUserId(mUid), requestedVisibilities, outInputChannel, outInsetsState, - outActiveControls); + outActiveControls, outAttachedFrame); } @Override public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, int displayId, int userId, InsetsVisibilities requestedVisibilities, InputChannel outInputChannel, InsetsState outInsetsState, - InsetsSourceControl[] outActiveControls) { + InsetsSourceControl[] outActiveControls, Rect outAttachedFrame) { return mService.addWindow(this, window, attrs, viewVisibility, displayId, userId, - requestedVisibilities, outInputChannel, outInsetsState, outActiveControls); + requestedVisibilities, outInputChannel, outInsetsState, outActiveControls, + outAttachedFrame); } @Override public int addToDisplayWithoutInputChannel(IWindow window, WindowManager.LayoutParams attrs, - int viewVisibility, int displayId, InsetsState outInsetsState) { + int viewVisibility, int displayId, InsetsState outInsetsState, Rect outAttachedFrame) { return mService.addWindow(this, window, attrs, viewVisibility, displayId, UserHandle.getUserId(mUid), mDummyRequestedVisibilities, null /* outInputChannel */, - outInsetsState, mDummyControls); + outInsetsState, mDummyControls, outAttachedFrame); } @Override diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b73ac7bc5d40..e764a05c343b 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1439,7 +1439,7 @@ public class WindowManagerService extends IWindowManager.Stub public int addWindow(Session session, IWindow client, LayoutParams attrs, int viewVisibility, int displayId, int requestUserId, InsetsVisibilities requestedVisibilities, InputChannel outInputChannel, InsetsState outInsetsState, - InsetsSourceControl[] outActiveControls) { + InsetsSourceControl[] outActiveControls, Rect outAttachedFrame) { Arrays.fill(outActiveControls, null); int[] appOp = new int[1]; final boolean isRoundedCornerOverlay = (attrs.privateFlags @@ -1854,6 +1854,13 @@ public class WindowManagerService extends IWindowManager.Stub outInsetsState.set(win.getCompatInsetsState(), win.isClientLocal()); getInsetsSourceControls(win, outActiveControls); + + if (win.mLayoutAttached) { + outAttachedFrame.set(win.getParentWindow().getCompatFrame()); + } else { + // Make this invalid which indicates a null attached frame. + outAttachedFrame.set(0, 0, -1, -1); + } } Binder.restoreCallingIdentity(origId); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 342b04f135c7..6728e63d055f 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1248,7 +1248,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSession.windowAddedLocked(); } - boolean updateGlobalScale() { + void updateGlobalScale() { if (hasCompatScale()) { if (mOverrideScale != 1f) { mGlobalScale = mToken.hasSizeCompatBounds() @@ -1258,11 +1258,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mGlobalScale = mToken.getSizeCompatScale(); } mInvGlobalScale = 1f / mGlobalScale; - return true; + return; } mGlobalScale = mInvGlobalScale = 1f; - return false; } /** @@ -1515,23 +1514,23 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP final boolean dragResizingChanged = isDragResizeChanged() && !isDragResizingChangeReported(); + final boolean attachedFrameChanged = LOCAL_LAYOUT + && mLayoutAttached && getParentWindow().frameChanged(); + if (DEBUG) { Slog.v(TAG_WM, "Resizing " + this + ": configChanged=" + configChanged + " dragResizingChanged=" + dragResizingChanged + " last=" + mWindowFrames.mLastFrame + " frame=" + mWindowFrames.mFrame); } - // We update mLastFrame always rather than in the conditional with the last inset - // variables, because mFrameSizeChanged only tracks the width and height changing. - updateLastFrames(); - // Add a window that is using blastSync to the resizing list if it hasn't been reported // already. This because the window is waiting on a finishDrawing from the client. if (didFrameInsetsChange || configChanged || insetsChanged || dragResizingChanged - || shouldSendRedrawForSync()) { + || shouldSendRedrawForSync() + || attachedFrameChanged) { ProtoLog.v(WM_DEBUG_RESIZE, "Resize reasons for w=%s: %s configChanged=%b dragResizingChanged=%b", this, mWindowFrames.getInsetsChangedInfo(), @@ -1587,6 +1586,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } + private boolean frameChanged() { + return !mWindowFrames.mFrame.equals(mWindowFrames.mLastFrame); + } + boolean getOrientationChanging() { // In addition to the local state flag, we must also consider the difference in the last // reported configuration vs. the current state. If the client code has not been informed of @@ -3838,6 +3841,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP if (mInvGlobalScale != 1.0f && hasCompatScale()) { outFrames.displayFrame.scale(mInvGlobalScale); } + if (mLayoutAttached) { + if (outFrames.attachedFrame == null) { + outFrames.attachedFrame = new Rect(); + } + outFrames.attachedFrame.set(getParentWindow().getCompatFrame()); + } // Note: in the cases where the window is tied to an activity, we should not send a // configuration update when the window has requested to be hidden. Doing so can lead to @@ -3889,6 +3898,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mDragResizingChangeReported = true; mWindowFrames.clearReportResizeHints(); + // We update mLastFrame always rather than in the conditional with the last inset + // variables, because mFrameSizeChanged only tracks the width and height changing. + updateLastFrames(); + final int prevRotation = mLastReportedConfiguration .getMergedConfiguration().windowConfiguration.getRotation(); fillClientWindowFramesAndConfiguration(mClientWindowFrames, mLastReportedConfiguration, diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 2477f6c41d4f..cfeaf850da03 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -1996,7 +1996,8 @@ public class ActivityRecordTests extends WindowTestsBase { any() /* window */, any() /* attrs */, anyInt() /* viewVisibility */, anyInt() /* displayId */, any() /* requestedVisibilities */, any() /* outInputChannel */, - any() /* outInsetsState */, any() /* outActiveControls */); + any() /* outInsetsState */, any() /* outActiveControls */, + any() /* outAttachedFrame */); mAtm.mWindowManager.mStartingSurfaceController .createTaskSnapshotSurface(activity, snapshot); } catch (RemoteException ignored) { diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java index ea18e58fe999..739e783e7c1b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java @@ -72,7 +72,7 @@ public class WindowLayoutTests { private static final Insets WATERFALL_INSETS = Insets.of(6, 0, 12, 0); private final WindowLayout mWindowLayout = new WindowLayout(); - private final ClientWindowFrames mOutFrames = new ClientWindowFrames(); + private final ClientWindowFrames mFrames = new ClientWindowFrames(); private WindowManager.LayoutParams mAttrs; private InsetsState mState; @@ -82,7 +82,6 @@ public class WindowLayoutTests { private int mRequestedWidth; private int mRequestedHeight; private InsetsVisibilities mRequestedVisibilities; - private Rect mAttachedWindowFrame; private float mCompatScale; @Before @@ -100,14 +99,14 @@ public class WindowLayoutTests { mRequestedWidth = DISPLAY_WIDTH; mRequestedHeight = DISPLAY_HEIGHT; mRequestedVisibilities = new InsetsVisibilities(); - mAttachedWindowFrame = null; mCompatScale = 1f; + mFrames.attachedFrame = null; } private void computeFrames() { mWindowLayout.computeFrames(mAttrs, mState, mDisplayCutoutSafe, mWindowBounds, mWindowingMode, mRequestedWidth, mRequestedHeight, mRequestedVisibilities, - mAttachedWindowFrame, mCompatScale, mOutFrames); + mCompatScale, mFrames); } private void addDisplayCutout() { @@ -145,9 +144,9 @@ public class WindowLayoutTests { public void defaultParams() { computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.frame); } @Test @@ -156,9 +155,9 @@ public class WindowLayoutTests { mRequestedHeight = UNSPECIFIED_LENGTH; computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.frame); } @Test @@ -172,9 +171,9 @@ public class WindowLayoutTests { mAttrs.gravity = Gravity.LEFT | Gravity.TOP; computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertRect(0, STATUS_BAR_HEIGHT, width, STATUS_BAR_HEIGHT + height, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertRect(0, STATUS_BAR_HEIGHT, width, STATUS_BAR_HEIGHT + height, mFrames.frame); } @Test @@ -186,11 +185,24 @@ public class WindowLayoutTests { computeFrames(); assertRect(0, top, DISPLAY_WIDTH, DISPLAY_HEIGHT - NAVIGATION_BAR_HEIGHT, - mOutFrames.displayFrame); + mFrames.displayFrame); assertRect(0, top, DISPLAY_WIDTH, DISPLAY_HEIGHT - NAVIGATION_BAR_HEIGHT, - mOutFrames.parentFrame); + mFrames.parentFrame); assertRect(0, top, DISPLAY_WIDTH, DISPLAY_HEIGHT - NAVIGATION_BAR_HEIGHT, - mOutFrames.frame); + mFrames.frame); + } + + @Test + public void attachedFrame() { + final int bottom = (DISPLAY_HEIGHT - STATUS_BAR_HEIGHT - NAVIGATION_BAR_HEIGHT) / 2; + mFrames.attachedFrame = new Rect(0, STATUS_BAR_HEIGHT, DISPLAY_WIDTH, bottom); + mRequestedWidth = UNSPECIFIED_LENGTH; + mRequestedHeight = UNSPECIFIED_LENGTH; + computeFrames(); + + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertEquals(mFrames.attachedFrame, mFrames.parentFrame); + assertEquals(mFrames.attachedFrame, mFrames.frame); } @Test @@ -198,9 +210,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(WindowInsets.Type.statusBars()); computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.frame); } @Test @@ -208,9 +220,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(WindowInsets.Type.navigationBars()); computeFrames(); - assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(0, NAVIGATION_BAR_HEIGHT, mFrames.frame); } @Test @@ -218,9 +230,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); - assertInsetByTopBottom(0, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(0, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(0, 0, mOutFrames.frame); + assertInsetByTopBottom(0, 0, mFrames.displayFrame); + assertInsetByTopBottom(0, 0, mFrames.parentFrame); + assertInsetByTopBottom(0, 0, mFrames.frame); } @Test @@ -228,9 +240,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsSides(WindowInsets.Side.all()); computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.frame); } @Test @@ -238,9 +250,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsSides(WindowInsets.Side.TOP); computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, 0, mFrames.frame); } @Test @@ -248,9 +260,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsSides(0); computeFrames(); - assertInsetByTopBottom(0, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(0, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(0, 0, mOutFrames.frame); + assertInsetByTopBottom(0, 0, mFrames.displayFrame); + assertInsetByTopBottom(0, 0, mFrames.parentFrame); + assertInsetByTopBottom(0, 0, mFrames.frame); } @Test @@ -259,9 +271,9 @@ public class WindowLayoutTests { mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(false); computeFrames(); - assertInsetByTopBottom(0, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(0, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(0, 0, mOutFrames.frame); + assertInsetByTopBottom(0, 0, mFrames.displayFrame); + assertInsetByTopBottom(0, 0, mFrames.parentFrame); + assertInsetByTopBottom(0, 0, mFrames.frame); } @Test @@ -271,9 +283,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsIgnoringVisibility(true); computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.frame); } @Test @@ -284,9 +296,9 @@ public class WindowLayoutTests { mAttrs.privateFlags |= PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME; computeFrames(); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mOutFrames.displayFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, IME_HEIGHT, mOutFrames.parentFrame); - assertInsetByTopBottom(STATUS_BAR_HEIGHT, IME_HEIGHT, mOutFrames.frame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, NAVIGATION_BAR_HEIGHT, mFrames.displayFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, IME_HEIGHT, mFrames.parentFrame); + assertInsetByTopBottom(STATUS_BAR_HEIGHT, IME_HEIGHT, mFrames.frame); } @Test @@ -297,11 +309,11 @@ public class WindowLayoutTests { computeFrames(); assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.displayFrame); + mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.parentFrame); + mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.frame); + mFrames.frame); } @Test @@ -312,11 +324,11 @@ public class WindowLayoutTests { computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.displayFrame); + mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.parentFrame); + mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.frame); + mFrames.frame); } @Test @@ -327,9 +339,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.displayFrame); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.parentFrame); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.frame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.displayFrame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.parentFrame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.frame); } @Test @@ -344,9 +356,9 @@ public class WindowLayoutTests { mAttrs.privateFlags |= PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT; computeFrames(); - assertRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, mOutFrames.displayFrame); - assertRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, mOutFrames.parentFrame); - assertRect(0, 0, DISPLAY_WIDTH, height + DISPLAY_CUTOUT_HEIGHT, mOutFrames.frame); + assertRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, mFrames.displayFrame); + assertRect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, mFrames.parentFrame); + assertRect(0, 0, DISPLAY_WIDTH, height + DISPLAY_CUTOUT_HEIGHT, mFrames.frame); } @Test @@ -359,11 +371,11 @@ public class WindowLayoutTests { computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.displayFrame); + mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.parentFrame); + mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.frame); + mFrames.frame); } @Test @@ -373,9 +385,9 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.displayFrame); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.parentFrame); - assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mOutFrames.frame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.displayFrame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.parentFrame); + assertInsetBy(WATERFALL_INSETS.left, 0, WATERFALL_INSETS.right, 0, mFrames.frame); } @Test @@ -386,11 +398,11 @@ public class WindowLayoutTests { computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.displayFrame); + mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.parentFrame); + mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, - mOutFrames.frame); + mFrames.frame); } @Test @@ -400,8 +412,8 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); - assertInsetByTopBottom(0, 0, mOutFrames.displayFrame); - assertInsetByTopBottom(0, 0, mOutFrames.parentFrame); - assertInsetByTopBottom(0, 0, mOutFrames.frame); + assertInsetByTopBottom(0, 0, mFrames.displayFrame); + assertInsetByTopBottom(0, 0, mFrames.parentFrame); + assertInsetByTopBottom(0, 0, mFrames.frame); } } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java index a0c20c2c6b68..e09a94f3bcf9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java @@ -49,6 +49,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.pm.PackageManager; +import android.graphics.Rect; import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; @@ -281,7 +282,7 @@ public class WindowManagerServiceTests extends WindowTestsBase { mWm.addWindow(session, new TestIWindow(), params, View.VISIBLE, DEFAULT_DISPLAY, UserHandle.USER_SYSTEM, new InsetsVisibilities(), null, new InsetsState(), - new InsetsSourceControl[0]); + new InsetsSourceControl[0], new Rect()); verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(any(), any(), anyInt(), anyInt(), any()); |