summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/view/WindowManager.java30
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java4
-rw-r--r--core/res/res/values/attrs.xml10
-rw-r--r--core/tests/coretests/res/values/styles.xml3
-rw-r--r--core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java10
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java4
7 files changed, 51 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt
index 645eae1eb4a6..6787e6014741 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -53871,6 +53871,7 @@ package android.view {
field public static final int LAST_SUB_WINDOW = 1999; // 0x7cf
field public static final int LAST_SYSTEM_WINDOW = 2999; // 0xbb7
field public static final int LAYOUT_CHANGED = 1; // 0x1
+ field public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 3; // 0x3
field public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0; // 0x0
field public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2; // 0x2
field public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1; // 0x1
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index f7d9706a9fce..540e6ef15874 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -2402,7 +2402,8 @@ public interface WindowManager extends ViewManager {
flag = true,
value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES,
- LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER})
+ LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER,
+ LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS})
@interface LayoutInDisplayCutoutMode {}
/**
@@ -2414,6 +2415,7 @@ public interface WindowManager extends ViewManager {
* @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
* @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
* @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
+ * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
* @see DisplayCutout
* @see android.R.attr#windowLayoutInDisplayCutoutMode
* android:windowLayoutInDisplayCutoutMode
@@ -2447,13 +2449,6 @@ public interface WindowManager extends ViewManager {
public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0;
/**
- * @deprecated use {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}
- * @hide
- */
- @Deprecated
- public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 1;
-
- /**
* The window is always allowed to extend into the {@link DisplayCutout} areas on the short
* edges of the screen.
*
@@ -2516,6 +2511,25 @@ public interface WindowManager extends ViewManager {
*/
public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;
+ /**
+ * The window is always allowed to extend into the {@link DisplayCutout} areas on the all
+ * edges of the screen.
+ *
+ * <p>
+ * The window must make sure that no important content overlaps with the
+ * {@link DisplayCutout}.
+ *
+ * <p>
+ * In this mode, the window extends under cutouts on the all edges of the display in both
+ * portrait and landscape, regardless of whether the window is hiding the system bars.
+ *
+ * @see DisplayCutout
+ * @see WindowInsets#getDisplayCutout()
+ * @see #layoutInDisplayCutoutMode
+ * @see android.R.attr#windowLayoutInDisplayCutoutMode
+ * android:windowLayoutInDisplayCutoutMode
+ */
+ public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 3;
/**
* When this window has focus, disable touch pad pointer gesture processing.
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 88a9cb0aefef..4abd39797ba0 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -27,8 +27,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
+import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
-import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import android.annotation.NonNull;
@@ -2466,7 +2466,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (a.hasValue(R.styleable.Window_windowLayoutInDisplayCutoutMode)) {
int mode = a.getInt(R.styleable.Window_windowLayoutInDisplayCutoutMode, -1);
if (mode < LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
- || mode > LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER) {
+ || mode > LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) {
throw new UnsupportedOperationException("Unknown windowLayoutInDisplayCutoutMode: "
+ a.getString(R.styleable.Window_windowLayoutInDisplayCutoutMode));
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 44754157c5b5..e0d849223552 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2217,6 +2217,16 @@
Corresponds to <code>LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER</code>.
-->
<enum name="never" value="2" />
+ <!-- <p>
+ The window is always allowed to extend into the <code>DisplayCutout</code> areas on the
+ all edges of the screen.
+ <p>
+ The window must make sure that no important content overlaps with the
+ <code>DisplayCutout</code>.
+ <p>
+ Corresponds to <code>LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS</code>.
+ -->
+ <enum name="always" value="3" />
</attr>
</declare-styleable>
diff --git a/core/tests/coretests/res/values/styles.xml b/core/tests/coretests/res/values/styles.xml
index 0bf4b9278446..352b4dceb3cc 100644
--- a/core/tests/coretests/res/values/styles.xml
+++ b/core/tests/coretests/res/values/styles.xml
@@ -31,6 +31,9 @@
<style name="LayoutInDisplayCutoutModeNever">
<item name="android:windowLayoutInDisplayCutoutMode">never</item>
</style>
+ <style name="LayoutInDisplayCutoutModeAlways">
+ <item name="android:windowLayoutInDisplayCutoutMode">always</item>
+ </style>
<style name="WindowBackgroundColorLiteral">
<item name="android:windowBackground">#00FF00</item>
</style>
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 6c2d630ac917..916e2b51ea53 100644
--- a/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java
+++ b/core/tests/coretests/src/com/android/internal/policy/PhoneWindowTest.java
@@ -16,6 +16,7 @@
package com.android.internal.policy;
+import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
@@ -94,6 +95,15 @@ public final class PhoneWindowTest {
}
@Test
+ public void layoutInDisplayCutoutMode_always() throws Exception {
+ createPhoneWindowWithTheme(R.style.LayoutInDisplayCutoutModeAlways);
+ installDecor();
+
+ assertThat(mPhoneWindow.getAttributes().layoutInDisplayCutoutMode,
+ is(LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS));
+ }
+
+ @Test
public void testWindowBackground_colorLiteral() {
createPhoneWindowWithTheme(R.style.WindowBackgroundColorLiteral);
installDecor();
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 9c62e9970b48..d6e3c8a8b179 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -58,6 +58,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
+import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT;
@@ -2210,7 +2211,8 @@ public class DisplayPolicy {
// Ensure that windows with a DEFAULT or NEVER display cutout mode are laid out in
// the cutout safe zone.
- if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) {
+ if (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
+ || cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER) {
final Rect displayCutoutSafeExceptMaybeBars = sTmpDisplayCutoutSafeExceptMaybeBarsRect;
displayCutoutSafeExceptMaybeBars.set(displayFrames.mDisplayCutoutSafe);
if (layoutInScreen && layoutInsetDecor && !requestedFullscreen