diff options
| author | 2022-03-26 12:56:12 +0800 | |
|---|---|---|
| committer | 2022-03-26 12:56:12 +0800 | |
| commit | ead6d20c1a3e6d81d5893507d1b29638e6274a5c (patch) | |
| tree | ac8fd9572bf0c3cc7d3a146f8f226d74ce6a48e2 | |
| parent | 5b19a1584a3cdd6ea17480c9e56c0ac694c421ae (diff) | |
Let setFrames can take frames passed from the client
This is a step to move the window layout to the client.
If the frames passed to WindowState#setFrames are from the client, we
need to apply mGlobalScale to them; if the frames are from the server,
we only need to apply mInvGlobalScale to mCompatFrame.
This CL also
- moves logic from mPerformLayout to setFrames, such as updateLastFrames
and layoutLetterbox, because we won't need mPerformLayout when
LOCAL_LAYOUT is enabled.
- removes a redundant performLayout from getNavBarPosition, because we
don't update mNavigationBarPosition in performLayout now.
Bug: 161810301
Test: ApiDemos > App > Activity > Max Aspect Ratio > 1:1, verify navbar
is visible
Change-Id: I0d892b4773d950c4f1f85503c43742f5990f6117
4 files changed, 59 insertions, 29 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 8eb0046ff923..2b31d02c8465 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -839,10 +839,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp w.onResizeHandled(); } - if (w.mActivityRecord != null) { - w.mActivityRecord.layoutLetterbox(w); - } - if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.getFrame() + " mParentFrame=" + w.getParentFrame() + " mDisplayFrame=" + w.getDisplayFrame()); diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 4573ede13f7f..011725b7bca4 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1552,7 +1552,7 @@ public class DisplayPolicy { win.getRequestedVisibilities(), attachedWindowFrame, win.mGlobalScale, sTmpClientFrames); - win.setFrames(sTmpClientFrames); + win.setFrames(sTmpClientFrames, win.mRequestedWidth, win.mRequestedHeight); } WindowState getTopFullscreenOpaqueWindow() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index cbb39d2ce275..1c07ccc02aa2 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2640,7 +2640,17 @@ public class WindowManagerService extends IWindowManager.Stub void updateWindowLayout(Session session, IWindow client, LayoutParams attrs, int flags, ClientWindowFrames clientWindowFrames, int requestedWidth, int requestedHeight) { - // TODO(b/161810301): Finish the implementation. + final long origId = Binder.clearCallingIdentity(); + synchronized (mGlobalLock) { + final WindowState win = windowForClientLocked(session, client, false); + if (win == null) { + return; + } + win.setFrames(clientWindowFrames, requestedWidth, requestedHeight); + + // TODO(b/161810301): Finish the implementation. + } + Binder.restoreCallingIdentity(origId); } public boolean outOfMemoryWindow(Session session, IWindow client) { @@ -6304,8 +6314,6 @@ public class WindowManagerService extends IWindowManager.Stub + " callers=" + Debug.getCallers(3)); return NAV_BAR_INVALID; } - displayContent.performLayout(false /* initial */, - false /* updateInputWindows */); return displayContent.getDisplayPolicy().getNavBarPosition(); } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 7bf7295fd2cb..2da106100124 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -33,6 +33,7 @@ import static android.view.InsetsState.ITYPE_INVALID; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.SurfaceControl.Transaction; import static android.view.SurfaceControl.getGlobalTransaction; +import static android.view.ViewRootImpl.LOCAL_LAYOUT; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; @@ -1399,31 +1400,36 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mActivityRecord != null && mActivityRecord.mWaitForEnteringPinnedMode; } - // TODO(b/161810301): Make the frame be passed from the client side. - void setFrames(ClientWindowFrames clientWindowFrames) { - mHaveFrame = true; - + void setFrames(ClientWindowFrames clientWindowFrames, int requestedWidth, int requestedHeight) { final WindowFrames windowFrames = mWindowFrames; mTmpRect.set(windowFrames.mParentFrame); - windowFrames.mDisplayFrame.set(clientWindowFrames.displayFrame); - windowFrames.mParentFrame.set(clientWindowFrames.parentFrame); - windowFrames.mFrame.set(clientWindowFrames.frame); - windowFrames.setParentFrameWasClippedByDisplayCutout( - clientWindowFrames.isParentFrameClippedByDisplayCutout); - - if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight - || !mTmpRect.equals(windowFrames.mParentFrame)) { - mLastRequestedWidth = mRequestedWidth; - mLastRequestedHeight = mRequestedHeight; - windowFrames.setContentChanged(true); - } - windowFrames.mCompatFrame.set(windowFrames.mFrame); - if (hasCompatScale()) { - // Also the scaled frame that we report to the app needs to be - // adjusted to be in its coordinate space. - windowFrames.mCompatFrame.scale(mInvGlobalScale); + if (LOCAL_LAYOUT) { + windowFrames.mCompatFrame.set(clientWindowFrames.frame); + + windowFrames.mFrame.set(clientWindowFrames.frame); + windowFrames.mDisplayFrame.set(clientWindowFrames.displayFrame); + windowFrames.mParentFrame.set(clientWindowFrames.parentFrame); + if (hasCompatScale()) { + // The frames sent from the client need to be adjusted to the real coordinate space. + windowFrames.mFrame.scale(mGlobalScale); + windowFrames.mDisplayFrame.scale(mGlobalScale); + windowFrames.mParentFrame.scale(mGlobalScale); + } + } else { + windowFrames.mDisplayFrame.set(clientWindowFrames.displayFrame); + windowFrames.mParentFrame.set(clientWindowFrames.parentFrame); + windowFrames.mFrame.set(clientWindowFrames.frame); + + windowFrames.mCompatFrame.set(windowFrames.mFrame); + if (hasCompatScale()) { + // Also, the scaled frame that we report to the app needs to be adjusted to be in + // its coordinate space. + windowFrames.mCompatFrame.scale(mInvGlobalScale); + } } + windowFrames.setParentFrameWasClippedByDisplayCutout( + clientWindowFrames.isParentFrameClippedByDisplayCutout); // Calculate relative frame windowFrames.mRelFrame.set(windowFrames.mFrame); @@ -1441,6 +1447,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP windowFrames.mRelFrame.offsetTo(windowFrames.mFrame.left - parentLeft, windowFrames.mFrame.top - parentTop); + if (requestedWidth != mLastRequestedWidth || requestedHeight != mLastRequestedHeight + || !mTmpRect.equals(windowFrames.mParentFrame)) { + mLastRequestedWidth = requestedWidth; + mLastRequestedHeight = requestedHeight; + windowFrames.setContentChanged(true); + } + if (mAttrs.type == TYPE_DOCK_DIVIDER) { if (!windowFrames.mFrame.equals(windowFrames.mLastFrame)) { mMovedByResize = true; @@ -1456,6 +1469,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } updateSourceFrame(windowFrames.mFrame); + + if (LOCAL_LAYOUT) { + if (!mHaveFrame) { + // The first frame should not be considered as moved. + updateLastFrames(); + } + } + + if (mActivityRecord != null && !mIsChildWindow) { + mActivityRecord.layoutLetterbox(this); + } + mSurfacePlacementNeeded = true; + mHaveFrame = true; } void updateSourceFrame(Rect winFrame) { |