From ec1a69e87cb52a27583bcbce2df56788d93812be Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Wed, 23 Dec 2020 19:37:02 +0800 Subject: Send display cutout to client via insetsChanged Since the display cutout is a type of insets and the display cutout can be obtained from WindowInsets, it makes sense that InsetsState has the display cutout instance. In this way, we can send the display cutout to client via W#insetsChanged instead of W#resized. This can be a step to remove the class of ClientWindowFrames, and can also be a step to make client compute its window frame locally. Fix: 175858810 Bug: 161810301 Test: atest WindowAddRemovePerfTest ImeInsetsSourceConsumerTest InsetsControllerTest InsetsStateTest ViewRootImplTest WindowInsetsControllerTests ActivityRecordTests DisplayPolicyLayoutTests LaunchParamsControllerTests TaskSnapshotSurfaceTest WindowMetricsActivityTests WindowMetricsWindowContextTests WindowMetricsTest WindowFrameTests WindowStateTests WmDisplayCutoutTest Change-Id: I9a930b1d2f7df3cea2b29629b767a4a5f31bca17 --- core/java/android/view/ViewRootImpl.java | 38 +++++--------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 52ce5e709990..51820d6afdfa 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -42,7 +42,6 @@ import static android.view.ViewRootImplProto.HEIGHT; import static android.view.ViewRootImplProto.IS_ANIMATING; import static android.view.ViewRootImplProto.IS_DRAWING; import static android.view.ViewRootImplProto.LAST_WINDOW_INSETS; -import static android.view.ViewRootImplProto.PENDING_DISPLAY_CUTOUT; import static android.view.ViewRootImplProto.REMOVED; import static android.view.ViewRootImplProto.SCROLL_Y; import static android.view.ViewRootImplProto.SOFT_INPUT_MODE; @@ -572,8 +571,6 @@ public final class ViewRootImpl implements ViewParent, final Rect mWinFrame; // frame given by window manager. final Rect mPendingBackDropFrame = new Rect(); - final DisplayCutout.ParcelableWrapper mPendingDisplayCutout = - new DisplayCutout.ParcelableWrapper(DisplayCutout.NO_CUTOUT); boolean mPendingAlwaysConsumeSystemBars; private final InsetsState mTempInsets = new InsetsState(); private final InsetsSourceControl[] mTempControls = new InsetsSourceControl[SIZE]; @@ -1056,8 +1053,7 @@ public final class ViewRootImpl implements ViewParent, res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes, getHostVisibility(), mDisplay.getDisplayId(), userId, mInsetsController.getRequestedVisibility(), mTmpFrames.frame, - mAttachInfo.mDisplayCutout, inputChannel, - mTempInsets, mTempControls); + inputChannel, mTempInsets, mTempControls); if (mTranslator != null) { mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame); mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets); @@ -1078,7 +1074,6 @@ public final class ViewRootImpl implements ViewParent, } } - mPendingDisplayCutout.set(mAttachInfo.mDisplayCutout); mAttachInfo.mAlwaysConsumeSystemBars = (res & WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS) != 0; mPendingAlwaysConsumeSystemBars = mAttachInfo.mAlwaysConsumeSystemBars; @@ -1499,15 +1494,13 @@ public final class ViewRootImpl implements ViewParent, final boolean forceNextWindowRelayout = args.argi1 != 0; final int displayId = args.argi3; final Rect backdropFrame = frames.backdropFrame; - final DisplayCutout displayCutout = frames.displayCutout.get(); final boolean frameChanged = !mWinFrame.equals(frames.frame); - final boolean cutoutChanged = !mPendingDisplayCutout.get().equals(displayCutout); final boolean backdropFrameChanged = !mPendingBackDropFrame.equals(backdropFrame); final boolean configChanged = !mLastReportedMergedConfiguration.equals(mergedConfiguration); final boolean displayChanged = mDisplay.getDisplayId() != displayId; - if (msg == MSG_RESIZED && !frameChanged && !cutoutChanged && !backdropFrameChanged - && !configChanged && !displayChanged && !forceNextWindowRelayout) { + if (msg == MSG_RESIZED && !frameChanged && !backdropFrameChanged && !configChanged + && !displayChanged && !forceNextWindowRelayout) { return; } @@ -1522,7 +1515,6 @@ public final class ViewRootImpl implements ViewParent, setFrame(frames.frame); mTmpFrames.displayFrame.set(frames.displayFrame); - mPendingDisplayCutout.set(displayCutout); mPendingBackDropFrame.set(backdropFrame); mForceNextWindowRelayout = forceNextWindowRelayout; mPendingAlwaysConsumeSystemBars = args.argi2 != 0; @@ -1531,7 +1523,7 @@ public final class ViewRootImpl implements ViewParent, reportNextDraw(); } - if (mView != null && (frameChanged || cutoutChanged || configChanged)) { + if (mView != null && (frameChanged || configChanged)) { forceLayout(mView); } requestLayout(); @@ -2331,8 +2323,7 @@ public final class ViewRootImpl implements ViewParent, final Configuration config = mContext.getResources().getConfiguration(); mLastWindowInsets = mInsetsController.calculateInsets( config.isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars, - mPendingDisplayCutout.get(), mWindowAttributes.type, - config.windowConfiguration.getWindowingMode(), + mWindowAttributes.type, config.windowConfiguration.getWindowingMode(), mWindowAttributes.softInputMode, mWindowAttributes.flags, (mWindowAttributes.systemUiVisibility | mWindowAttributes.subtreeSystemUiVisibility)); @@ -2514,8 +2505,6 @@ public final class ViewRootImpl implements ViewParent, // Execute enqueued actions on every traversal in case a detached view enqueued an action getRunQueue().executeActions(mAttachInfo.mHandler); - boolean cutoutChanged = false; - boolean layoutRequested = mLayoutRequested && (!mStopped || mReportNextDraw); if (layoutRequested) { @@ -2527,9 +2516,6 @@ public final class ViewRootImpl implements ViewParent, mAttachInfo.mInTouchMode = !mAddedTouchMode; ensureTouchModeLocally(mAddedTouchMode); } else { - if (!mPendingDisplayCutout.equals(mAttachInfo.mDisplayCutout)) { - cutoutChanged = true; - } if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) { windowSizeMayChange = true; @@ -2655,7 +2641,7 @@ public final class ViewRootImpl implements ViewParent, } } - if (mFirst || windowShouldResize || viewVisibilityChanged || cutoutChanged || params != null + if (mFirst || windowShouldResize || viewVisibilityChanged || params != null || mForceNextWindowRelayout) { mForceNextWindowRelayout = false; @@ -2695,7 +2681,6 @@ public final class ViewRootImpl implements ViewParent, relayoutResult = relayoutWindow(params, viewVisibility, insetsPending); if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString() - + " cutout=" + mPendingDisplayCutout.get().toString() + " surface=" + mSurface); // If the pending {@link MergedConfiguration} handed back from @@ -2711,7 +2696,6 @@ public final class ViewRootImpl implements ViewParent, updatedConfiguration = true; } - cutoutChanged = !mPendingDisplayCutout.equals(mAttachInfo.mDisplayCutout); surfaceSizeChanged = false; if (!mLastSurfaceSize.equals(mSurfaceSize)) { surfaceSizeChanged = true; @@ -2735,14 +2719,6 @@ public final class ViewRootImpl implements ViewParent, mSurfaceSequenceId++; } - if (cutoutChanged) { - mAttachInfo.mDisplayCutout.set(mPendingDisplayCutout); - if (DEBUG_LAYOUT) { - Log.v(mTag, "DisplayCutout changing to: " + mAttachInfo.mDisplayCutout); - } - // Need to relayout with content insets. - dispatchApplyInsets = true; - } if (alwaysConsumeSystemBarsChanged) { mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars; dispatchApplyInsets = true; @@ -7518,7 +7494,6 @@ public final class ViewRootImpl implements ViewParent, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber, mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls, mSurfaceSize); - mPendingDisplayCutout.set(mTmpFrames.displayCutout); mPendingBackDropFrame.set(mTmpFrames.backdropFrame); if (mSurfaceControl.isValid()) { if (!useBLAST()) { @@ -7679,7 +7654,6 @@ public final class ViewRootImpl implements ViewParent, proto.write(IS_DRAWING, mIsDrawing); proto.write(ADDED, mAdded); mWinFrame.dumpDebug(proto, WIN_FRAME); - mPendingDisplayCutout.get().dumpDebug(proto, PENDING_DISPLAY_CUTOUT); proto.write(LAST_WINDOW_INSETS, Objects.toString(mLastWindowInsets)); proto.write(SOFT_INPUT_MODE, InputMethodDebug.softInputModeToString(mSoftInputMode)); proto.write(SCROLL_Y, mScrollY); -- cgit v1.2.3