summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorYunfan Chen <yunfanc@google.com>2020-02-22 20:57:57 +0900
committerYunfan Chen <yunfanc@google.com>2020-03-26 06:58:07 +0000
commitfae0aeabe0e5b63cbe4844c6f0e02f9a4a1e6947 (patch)
treea07bbf71751a3db63b23d8ed9b7a429c1d2994b5 /core/java/android/view/ViewRootImpl.java
parent6f3e64a56e33a9fd3c553a56fc0da7c40f82e918 (diff)
Make caption a insets source
This patch introduced setCaptionInsets, and set the Insets in ViewRootImpl when dispatch the insets if there's a caption. Modification is made in Window and DecorCaptionView to make caption overlay with the app content, and pass the value to ViewRootImpl to apply when dispatch. It is necessary to trigger a dispatch when caption enabled status chanaged, otherwise sometimes it will not be updated. Because caption is now updated locally on the client side. Some old logic to deal with the overlay caption without insets are removed, including the touch event dispatch override, the color override. Bug: 134531136 Test: go/wm-smoke Test: Manually change the value in dispatchApplyInsets, can observe a blank content area when there's a caption bar. Test: atest InsetsStateTest Test: atest InsetsControllerTest Change-Id: I356344a13c8569512d8f51f7ea19a5603f778252
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 50202aed36d2..51304dcfe8cb 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -158,6 +158,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
+import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneFallbackEventHandler;
import com.android.internal.util.Preconditions;
import com.android.internal.view.BaseSurfaceHolder;
@@ -2221,6 +2222,19 @@ public final class ViewRootImpl implements ViewParent,
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
}
+ private boolean updateCaptionInsets() {
+ if (!(mView instanceof DecorView)) return false;
+ final int captionInsetsHeight = ((DecorView) mView).getCaptionInsetsHeight();
+ final Rect captionFrame = new Rect();
+ if (captionInsetsHeight != 0) {
+ captionFrame.set(mWinFrame.left, mWinFrame.top, mWinFrame.right,
+ mWinFrame.top + captionInsetsHeight);
+ }
+ if (mAttachInfo.mCaptionInsets.equals(captionFrame)) return false;
+ mAttachInfo.mCaptionInsets.set(captionFrame);
+ return true;
+ }
+
private boolean shouldDispatchCutout() {
return mWindowAttributes.layoutInDisplayCutoutMode
== LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
@@ -2592,6 +2606,9 @@ public final class ViewRootImpl implements ViewParent,
mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars;
dispatchApplyInsets = true;
}
+ if (updateCaptionInsets()) {
+ dispatchApplyInsets = true;
+ }
if (dispatchApplyInsets || mLastSystemUiVisibility !=
mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested) {
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;