diff options
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 7c814f4a5773..ed67075d38d6 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1630,6 +1630,8 @@ public final class ViewRootImpl implements ViewParent, contentInsets.top + outsets.top, contentInsets.right + outsets.right, contentInsets.bottom + outsets.bottom); } + contentInsets = ensureInsetsNonNegative(contentInsets, "content"); + stableInsets = ensureInsetsNonNegative(stableInsets, "stable"); mLastWindowInsets = new WindowInsets(contentInsets, null /* windowDecorInsets */, stableInsets, mContext.getResources().getConfiguration().isScreenRound(), @@ -1638,6 +1640,17 @@ public final class ViewRootImpl implements ViewParent, return mLastWindowInsets; } + private Rect ensureInsetsNonNegative(Rect insets, String kind) { + if (insets.left < 0 || insets.top < 0 || insets.right < 0 || insets.bottom < 0) { + Log.wtf(mTag, "Negative " + kind + "Insets: " + insets + ", mFirst=" + mFirst); + return new Rect(Math.max(0, insets.left), + Math.max(0, insets.top), + Math.max(0, insets.right), + Math.max(0, insets.bottom)); + } + return insets; + } + void dispatchApplyInsets(View host) { WindowInsets insets = getWindowInsets(true /* forceConstruct */); final boolean dispatchCutout = (mWindowAttributes.layoutInDisplayCutoutMode |
