From fa02da62506267d8acf9c92106206a0583cf0632 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Mon, 15 Jan 2018 16:01:18 +0100 Subject: DisplayCutout: LayoutInDisplayCutoutMode API Replace the FLAG2_LAYOUT_IN_DISPLAY_CUTOUT flag with a dedicated layoutInDisplayCutout field; given the change in behavior of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN with respect to the display cutout, apps that request this now also need a way to request the same behavior as FLAG_FULLSCREEN. Broadly, there's three categories of apps: 1) Apps that want to make dedicated use of the cutout area -> no letterbox ever 2a) Apps that hide the status bar, but don't expect the cutout to be there cutting into their content -> we want those to get letterboxed b) Some apps may only be transiently fullscreen, but always want to get letterboxed -> we want those to get letterboxed even if not currently fullscreen 3) Apps that never go fullscreen, and just draw the status bar background in the cutout area (i.e. the most common type of app) -> these need to get letterboxed whenever the cutout and status bar don't coincide (under our current guidelines that's only in fullscreen and landscape) To cover each use case, we have: ALWAYS: Always allow the app to draw into the cutout, never letterbox it; covers 1 NEVER: Never allow the app to draw into the cutout, always letterbox it; covers 2a and 2b DEFAULT: Allow the app to draw into the cutout if that area is covered by the status bar anyways. This does the right thing for most existing apps (2a and 3). Bug: 65689439 Test: atest PhoneWindowManagerLayoutTest Change-Id: Ib8d551251e9be4ef9d580ca2151bf40a9678acae --- core/java/android/view/ViewRootImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 6c5091c28708..598993774ad8 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -20,7 +20,7 @@ import static android.view.Display.INVALID_DISPLAY; import static android.view.View.PFLAG_DRAW_ANIMATION; import static android.view.WindowCallbacks.RESIZE_MODE_DOCKED_DIVIDER; import static android.view.WindowCallbacks.RESIZE_MODE_FREEFORM; -import static android.view.WindowManager.LayoutParams.FLAG2_LAYOUT_IN_DISPLAY_CUTOUT_AREA; +import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; @@ -1597,9 +1597,9 @@ public final class ViewRootImpl implements ViewParent, void dispatchApplyInsets(View host) { WindowInsets insets = getWindowInsets(true /* forceConstruct */); - final boolean layoutInCutout = - (mWindowAttributes.flags2 & FLAG2_LAYOUT_IN_DISPLAY_CUTOUT_AREA) != 0; - if (!layoutInCutout) { + final boolean dispatchCutout = (mWindowAttributes.layoutInDisplayCutoutMode + == LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS); + if (!dispatchCutout) { // Window is either not laid out in cutout or the status bar inset takes care of // clearing the cutout, so we don't need to dispatch the cutout to the hierarchy. insets = insets.consumeDisplayCutout(); -- cgit v1.2.3