Make non-floating PhoneWindow extend into display cutout insets
The exsiting logic already enforces non-floating PhoneWindow to extends
into system bar areas by default. This CL makes it extend into the
cutout area as well if the edge-to-edge enforcement is enabled.
Bug: 309578419
Test: atest PhoneWindowTest
Change-Id: Id264ba939eb04634bb1916551b081b30112278ae
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index dd310dc..201b23c 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -118,6 +118,7 @@
import android.window.ProxyOnBackInvokedDispatcher;
import com.android.internal.R;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.IconMenuPresenter;
import com.android.internal.view.menu.ListMenuPresenter;
@@ -374,7 +375,8 @@
boolean mDecorFitsSystemWindows = true;
- private final boolean mDefaultEdgeToEdge;
+ @VisibleForTesting
+ public final boolean mDefaultEdgeToEdge;
private final ProxyOnBackInvokedDispatcher mProxyOnBackInvokedDispatcher;
@@ -2448,6 +2450,7 @@
// Apply data from current theme.
TypedArray a = getWindowStyle();
+ WindowManager.LayoutParams params = getAttributes();
if (false) {
System.out.println("From style:");
@@ -2467,8 +2470,11 @@
setFlags(0, flagsToUpdate);
} else {
setFlags(FLAG_LAYOUT_IN_SCREEN|FLAG_LAYOUT_INSET_DECOR, flagsToUpdate);
- getAttributes().setFitInsetsSides(0);
- getAttributes().setFitInsetsTypes(0);
+ params.setFitInsetsSides(0);
+ params.setFitInsetsTypes(0);
+ if (mDefaultEdgeToEdge) {
+ params.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+ }
}
if (a.getBoolean(R.styleable.Window_windowNoTitle, false)) {
@@ -2586,8 +2592,6 @@
R.styleable.Window_enforceNavigationBarContrast, true);
}
- WindowManager.LayoutParams params = getAttributes();
-
// Non-floating windows on high end devices must put up decor beneath the system bars and
// therefore must know about visibility changes of those.
if (!mIsFloating) {
diff --git a/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java b/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java
index 916e2b5..6bdc06a 100644
--- a/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java
+++ b/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java
@@ -63,8 +63,13 @@
createPhoneWindowWithTheme(R.style.LayoutInDisplayCutoutModeUnset);
installDecor();
- assertThat(mPhoneWindow.getAttributes().layoutInDisplayCutoutMode,
- is(LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT));
+ if (mPhoneWindow.mDefaultEdgeToEdge && !mPhoneWindow.isFloating()) {
+ assertThat(mPhoneWindow.getAttributes().layoutInDisplayCutoutMode,
+ is(LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS));
+ } else {
+ assertThat(mPhoneWindow.getAttributes().layoutInDisplayCutoutMode,
+ is(LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT));
+ }
}
@Test
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
index 43ae5f4..ae21c4b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
@@ -247,7 +247,7 @@
}
params.layoutInDisplayCutoutMode = a.getInt(
R.styleable.Window_windowLayoutInDisplayCutoutMode,
- params.layoutInDisplayCutoutMode);
+ WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS);
params.windowAnimations = a.getResourceId(R.styleable.Window_windowAnimationStyle, 0);
a.recycle();