From 6f7e60ed8c3a374f7ed18fb53adbca6ef1b0c9d9 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Thu, 24 Nov 2022 10:35:10 +0000 Subject: [PATCH] Fixed test failures of WindowTest When cutout mode is always/shortEdges and the system window insets are consumed, the cutout isn't consumed and is inset to an empty cutout which causes the test failure. We should also consume cutout when the system window insets contain cutout and are consumed. Bug: 253995206 Test: atest WindowTest WindowInsetsTest DecorInsetTests Change-Id: I8a4fd56675509cc27dfa91de1138458fb1e7b0f0 --- core/java/android/view/WindowInsets.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index d77e499357b91..03b25c25ab997 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -29,6 +29,7 @@ import static android.view.WindowInsets.Type.STATUS_BARS; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.all; +import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.systemBars; @@ -597,7 +598,10 @@ public final class WindowInsets { return new WindowInsets(null, null, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, - displayCutoutCopyConstructorArgument(this), + // If the system window insets types contain displayCutout, we should also consume + // it. + (mCompatInsetsTypes & displayCutout()) != 0 + ? null : displayCutoutCopyConstructorArgument(this), mRoundedCorners, mPrivacyIndicatorBounds, mCompatInsetsTypes, mCompatIgnoreVisibility); }