diff options
| author | 2024-04-26 01:12:51 +0000 | |
|---|---|---|
| committer | 2024-04-26 01:12:51 +0000 | |
| commit | 923f102c48d538ea5d7d64551a089386ac2c8dd4 (patch) | |
| tree | db0567eb0a0bf5a079d79a932b8ff4909d0ca569 | |
| parent | 221a5a1fa259c0406c4bc92f9941c5f5f0146307 (diff) | |
| parent | 88dba1b31f5f3641a13d58637156425626f7701f (diff) | |
Merge "Override layout in display cutout mode when needed" into main
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 11 | ||||
| -rw-r--r-- | core/java/com/android/internal/policy/PhoneWindow.java | 17 |
3 files changed, 31 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index dbb42a09f3c7..701b2d3f506a 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -74,6 +74,7 @@ import static android.view.ViewRootImplProto.WIDTH; import static android.view.ViewRootImplProto.WINDOW_ATTRIBUTES; import static android.view.ViewRootImplProto.WIN_FRAME; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS; import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS; @@ -2141,7 +2142,8 @@ public final class ViewRootImpl implements ViewParent, private int adjustLayoutInDisplayCutoutMode(WindowManager.LayoutParams attrs) { final int originalMode = attrs.layoutInDisplayCutoutMode; - if ((attrs.privateFlags & PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED) != 0 + if ((attrs.privateFlags & (PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED + | PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE)) != 0 && attrs.isFullscreen() && attrs.getFitInsetsTypes() == 0 && attrs.getFitInsetsSides() == 0) { diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index afe5b7e15793..0bc2430f8805 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -3386,6 +3386,12 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW = 1 << 17; /** + * Flag to indicate that the window is forcibly to layout under the display cutout. + * @hide + */ + public static final int PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE = 1 << 18; + + /** * Flag to indicate that any window added by an application process that is of type * {@link #TYPE_TOAST} or that requires * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when @@ -3505,6 +3511,7 @@ public interface WindowManager extends ViewManager { PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS, PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, + PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION, @@ -3587,6 +3594,10 @@ public interface WindowManager extends ViewManager { equals = PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, name = "IMMERSIVE_CONFIRMATION_WINDOW"), @ViewDebug.FlagToString( + mask = PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, + equals = PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, + name = "OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE"), + @ViewDebug.FlagToString( mask = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, equals = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 52487fb1ecaa..a091e19e1985 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -37,6 +37,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; +import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE; import android.annotation.NonNull; import android.annotation.Nullable; @@ -46,7 +47,9 @@ import android.app.KeyguardManager; import android.app.SearchManager; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; +import android.compat.annotation.Disabled; import android.compat.annotation.EnabledSince; +import android.compat.annotation.Overridable; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.Intent; @@ -180,6 +183,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) private static final long ENFORCE_EDGE_TO_EDGE = 309578419; + /** + * Override the layout in display cutout mode behavior. This will only apply if the edge to edge + * is not enforced. + */ + @ChangeId + @Disabled + @Overridable + private static final long OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE = 332679525L; + private static final int CUSTOM_TITLE_COMPATIBLE_FEATURES = DEFAULT_FEATURES | (1 << FEATURE_CUSTOM_TITLE) | (1 << FEATURE_CONTENT_TRANSITIONS) | @@ -2475,6 +2487,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { getAttributes().privateFlags |= PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED; mDecorFitsSystemWindows = false; } + if (CompatChanges.isChangeEnabled(OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE) + && !a.getBoolean(R.styleable.Window_windowOptOutEdgeToEdgeEnforcement, + false /* defValue */)) { + getAttributes().privateFlags |= PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE; + } mIsFloating = a.getBoolean(R.styleable.Window_windowIsFloating, false); int flagsToUpdate = (FLAG_LAYOUT_IN_SCREEN|FLAG_LAYOUT_INSET_DECOR) |