Merge "WindowLayout: Layout IN_SCREEN floating windows in screen" into pi-dev

am: 0767375727

Change-Id: I3ef9b38e239571877f2721d53983d81dcd85c6c3
This commit is contained in:
Adrian Roos
2018-04-10 11:20:07 -07:00
committed by android-build-merger
3 changed files with 32 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
@@ -5411,6 +5412,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final boolean attachedInParent = attached != null && !layoutInScreen; final boolean attachedInParent = attached != null && !layoutInScreen;
final boolean requestedHideNavigation = final boolean requestedHideNavigation =
(requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; (requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
// TYPE_BASE_APPLICATION windows are never considered floating here because they don't get
// cropped / shifted to the displayFrame in WindowState.
final boolean floatingInScreenWindow = !attrs.isFullscreen() && layoutInScreen
&& type != TYPE_BASE_APPLICATION;
// Ensure that windows with a DEFAULT or NEVER display cutout mode are laid out in // Ensure that windows with a DEFAULT or NEVER display cutout mode are laid out in
// the cutout safe zone. // the cutout safe zone.
if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) { if (cutoutMode != LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS) {
@@ -5445,7 +5452,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
// Windows that are attached to a parent and laid out in said parent already avoid // Windows that are attached to a parent and laid out in said parent already avoid
// the cutout according to that parent and don't need to be further constrained. // the cutout according to that parent and don't need to be further constrained.
if (!attachedInParent) { // Floating IN_SCREEN windows get what they ask for and lay out in the full screen.
// They will later be cropped or shifted using the displayFrame in WindowState,
// which prevents overlap with the DisplayCutout.
if (!attachedInParent && !floatingInScreenWindow) {
mTmpRect.set(pf); mTmpRect.set(pf);
pf.intersectUnchecked(displayCutoutSafeExceptMaybeBars); pf.intersectUnchecked(displayCutoutSafeExceptMaybeBars);
parentFrameWasClippedByDisplayCutout |= !mTmpRect.equals(pf); parentFrameWasClippedByDisplayCutout |= !mTmpRect.equals(pf);

View File

@@ -22,6 +22,7 @@ import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -29,6 +30,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@@ -259,6 +261,23 @@ public class PhoneWindowManagerLayoutTest extends PhoneWindowManagerTestBase {
assertInsetBy(mAppWindow.decorFrame, 0, 0, 0, 0); assertInsetBy(mAppWindow.decorFrame, 0, 0, 0, 0);
} }
@Test
public void layoutWindowLw_withDisplayCutout_floatingInScreen() {
addDisplayCutout();
mAppWindow.attrs.flags = FLAG_LAYOUT_IN_SCREEN;
mAppWindow.attrs.type = TYPE_APPLICATION_OVERLAY;
mAppWindow.attrs.width = DISPLAY_WIDTH;
mAppWindow.attrs.height = DISPLAY_HEIGHT;
mPolicy.addWindow(mAppWindow);
mPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mPolicy.layoutWindowLw(mAppWindow, null, mFrames);
assertInsetByTopBottom(mAppWindow.parentFrame, 0, NAV_BAR_HEIGHT);
assertInsetByTopBottom(mAppWindow.displayFrame, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
}
@Test @Test
public void layoutWindowLw_withDisplayCutout_fullscreenInCutout_landscape() { public void layoutWindowLw_withDisplayCutout_fullscreenInCutout_landscape() {
addDisplayCutout(); addDisplayCutout();

View File

@@ -229,7 +229,8 @@ public class PhoneWindowManagerTestBase {
void addWindow(WindowState state) { void addWindow(WindowState state) {
if (state instanceof FakeWindowState) { if (state instanceof FakeWindowState) {
((FakeWindowState) state).surfaceLayer = ((FakeWindowState) state).surfaceLayer =
getWindowLayerFromTypeLw(state.getAttrs().type); getWindowLayerFromTypeLw(state.getAttrs().type,
true /* canAddInternalSystemWindow */);
} }
adjustWindowParamsLw(state, state.getAttrs(), true /* hasStatusBarPermission */); adjustWindowParamsLw(state, state.getAttrs(), true /* hasStatusBarPermission */);
assertEquals(WindowManagerGlobal.ADD_OKAY, prepareAddWindowLw(state, state.getAttrs())); assertEquals(WindowManagerGlobal.ADD_OKAY, prepareAddWindowLw(state, state.getAttrs()));