Loading core/java/android/view/WindowLayout.java +8 −17 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ package android.view; import static android.view.InsetsSource.ID_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.systemBars; 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_NO_LIMITS; Loading Loading @@ -109,14 +109,6 @@ public class WindowLayout { // Ensure that windows with a non-ALWAYS display cutout mode are laid out in // the cutout safe zone. final Rect displayFrame = state.getDisplayFrame(); final InsetsSource statusBarSource = state.peekSource(ITYPE_STATUS_BAR); if (statusBarSource != null && displayCutoutSafe.top > displayFrame.top) { // Make sure that the zone we're avoiding for the cutout is at least as tall as the // status bar; otherwise fullscreen apps will end up cutting halfway into the status // bar. displayCutoutSafeExceptMaybeBars.top = Math.max(statusBarSource.getFrame().bottom, displayCutoutSafe.top); } if (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) { if (displayFrame.width() < displayFrame.height()) { displayCutoutSafeExceptMaybeBars.top = MIN_Y; Loading @@ -131,7 +123,7 @@ public class WindowLayout { && (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT || cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)) { final Insets systemBarsInsets = state.calculateInsets( displayFrame, WindowInsets.Type.systemBars(), requestedVisibleTypes); displayFrame, systemBars(), requestedVisibleTypes); if (systemBarsInsets.left > 0) { displayCutoutSafeExceptMaybeBars.left = MIN_X; } Loading @@ -145,13 +137,12 @@ public class WindowLayout { displayCutoutSafeExceptMaybeBars.bottom = MAX_Y; } } if (type == TYPE_INPUT_METHOD) { final InsetsSource navSource = state.peekSource(ITYPE_NAVIGATION_BAR); if (navSource != null && navSource.calculateInsets(displayFrame, true).bottom > 0) { if (type == TYPE_INPUT_METHOD && displayCutoutSafeExceptMaybeBars.bottom != MAX_Y && state.calculateInsets(displayFrame, navigationBars(), true).bottom > 0) { // The IME can always extend under the bottom cutout if the navbar is there. displayCutoutSafeExceptMaybeBars.bottom = MAX_Y; } } final boolean attachedInParent = attachedWindowFrame != null && !layoutInScreen; // TYPE_BASE_APPLICATION windows are never considered floating here because they don't Loading services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java→core/tests/coretests/src/android/view/WindowLayoutTests.java +24 −28 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,11 +14,9 @@ * limitations under the License. */ package com.android.server.wm; package android.view; import static android.view.InsetsSource.ID_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.navigationBars; Loading @@ -39,13 +37,6 @@ import android.app.WindowConfiguration; import android.graphics.Insets; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.view.DisplayCutout; import android.view.Gravity; import android.view.InsetsSource; import android.view.InsetsState; import android.view.WindowInsets; import android.view.WindowLayout; import android.view.WindowManager; import android.window.ClientWindowFrames; import androidx.test.filters.SmallTest; Loading @@ -72,6 +63,11 @@ public class WindowLayoutTests { new Rect(DISPLAY_WIDTH / 4, 0, DISPLAY_WIDTH * 3 / 4, DISPLAY_CUTOUT_HEIGHT); private static final Insets WATERFALL_INSETS = Insets.of(6, 0, 12, 0); private static final int ID_STATUS_BAR = InsetsSource.createId( null /* owner */, 0 /* index */, statusBars()); private static final int ID_NAVIGATION_BAR = InsetsSource.createId( null /* owner */, 0 /* index */, navigationBars()); private final WindowLayout mWindowLayout = new WindowLayout(); private final ClientWindowFrames mFrames = new ClientWindowFrames(); Loading @@ -90,9 +86,9 @@ public class WindowLayoutTests { mAttrs = new WindowManager.LayoutParams(); mState = new InsetsState(); mState.setDisplayFrame(new Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT)); mState.getOrCreateSource(ITYPE_STATUS_BAR, statusBars()).setFrame( mState.getOrCreateSource(ID_STATUS_BAR, statusBars()).setFrame( 0, 0, DISPLAY_WIDTH, STATUS_BAR_HEIGHT); mState.getOrCreateSource(ITYPE_NAVIGATION_BAR, navigationBars()).setFrame( mState.getOrCreateSource(ID_NAVIGATION_BAR, navigationBars()).setFrame( 0, DISPLAY_HEIGHT - NAVIGATION_BAR_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT); mState.getDisplayCutoutSafe(mDisplayCutoutSafe); mWindowBounds = new Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); Loading Loading @@ -268,8 +264,8 @@ public class WindowLayoutTests { @Test public void fitInvisibleInsets() { mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); computeFrames(); assertInsetByTopBottom(0, 0, mFrames.displayFrame); Loading @@ -279,8 +275,8 @@ public class WindowLayoutTests { @Test public void fitInvisibleInsetsIgnoringVisibility() { mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); mAttrs.setFitInsetsIgnoringVisibility(true); computeFrames(); Loading Loading @@ -324,11 +320,11 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading Loading @@ -365,17 +361,17 @@ public class WindowLayoutTests { @Test public void layoutInDisplayCutoutModeDefaultWithInvisibleSystemBars() { addDisplayCutout(); mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading @@ -398,11 +394,11 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading Loading
core/java/android/view/WindowLayout.java +8 −17 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ package android.view; import static android.view.InsetsSource.ID_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.systemBars; 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_NO_LIMITS; Loading Loading @@ -109,14 +109,6 @@ public class WindowLayout { // Ensure that windows with a non-ALWAYS display cutout mode are laid out in // the cutout safe zone. final Rect displayFrame = state.getDisplayFrame(); final InsetsSource statusBarSource = state.peekSource(ITYPE_STATUS_BAR); if (statusBarSource != null && displayCutoutSafe.top > displayFrame.top) { // Make sure that the zone we're avoiding for the cutout is at least as tall as the // status bar; otherwise fullscreen apps will end up cutting halfway into the status // bar. displayCutoutSafeExceptMaybeBars.top = Math.max(statusBarSource.getFrame().bottom, displayCutoutSafe.top); } if (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) { if (displayFrame.width() < displayFrame.height()) { displayCutoutSafeExceptMaybeBars.top = MIN_Y; Loading @@ -131,7 +123,7 @@ public class WindowLayout { && (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT || cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)) { final Insets systemBarsInsets = state.calculateInsets( displayFrame, WindowInsets.Type.systemBars(), requestedVisibleTypes); displayFrame, systemBars(), requestedVisibleTypes); if (systemBarsInsets.left > 0) { displayCutoutSafeExceptMaybeBars.left = MIN_X; } Loading @@ -145,13 +137,12 @@ public class WindowLayout { displayCutoutSafeExceptMaybeBars.bottom = MAX_Y; } } if (type == TYPE_INPUT_METHOD) { final InsetsSource navSource = state.peekSource(ITYPE_NAVIGATION_BAR); if (navSource != null && navSource.calculateInsets(displayFrame, true).bottom > 0) { if (type == TYPE_INPUT_METHOD && displayCutoutSafeExceptMaybeBars.bottom != MAX_Y && state.calculateInsets(displayFrame, navigationBars(), true).bottom > 0) { // The IME can always extend under the bottom cutout if the navbar is there. displayCutoutSafeExceptMaybeBars.bottom = MAX_Y; } } final boolean attachedInParent = attachedWindowFrame != null && !layoutInScreen; // TYPE_BASE_APPLICATION windows are never considered floating here because they don't Loading
services/tests/wmtests/src/com/android/server/wm/WindowLayoutTests.java→core/tests/coretests/src/android/view/WindowLayoutTests.java +24 −28 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -14,11 +14,9 @@ * limitations under the License. */ package com.android.server.wm; package android.view; import static android.view.InsetsSource.ID_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.navigationBars; Loading @@ -39,13 +37,6 @@ import android.app.WindowConfiguration; import android.graphics.Insets; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.view.DisplayCutout; import android.view.Gravity; import android.view.InsetsSource; import android.view.InsetsState; import android.view.WindowInsets; import android.view.WindowLayout; import android.view.WindowManager; import android.window.ClientWindowFrames; import androidx.test.filters.SmallTest; Loading @@ -72,6 +63,11 @@ public class WindowLayoutTests { new Rect(DISPLAY_WIDTH / 4, 0, DISPLAY_WIDTH * 3 / 4, DISPLAY_CUTOUT_HEIGHT); private static final Insets WATERFALL_INSETS = Insets.of(6, 0, 12, 0); private static final int ID_STATUS_BAR = InsetsSource.createId( null /* owner */, 0 /* index */, statusBars()); private static final int ID_NAVIGATION_BAR = InsetsSource.createId( null /* owner */, 0 /* index */, navigationBars()); private final WindowLayout mWindowLayout = new WindowLayout(); private final ClientWindowFrames mFrames = new ClientWindowFrames(); Loading @@ -90,9 +86,9 @@ public class WindowLayoutTests { mAttrs = new WindowManager.LayoutParams(); mState = new InsetsState(); mState.setDisplayFrame(new Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT)); mState.getOrCreateSource(ITYPE_STATUS_BAR, statusBars()).setFrame( mState.getOrCreateSource(ID_STATUS_BAR, statusBars()).setFrame( 0, 0, DISPLAY_WIDTH, STATUS_BAR_HEIGHT); mState.getOrCreateSource(ITYPE_NAVIGATION_BAR, navigationBars()).setFrame( mState.getOrCreateSource(ID_NAVIGATION_BAR, navigationBars()).setFrame( 0, DISPLAY_HEIGHT - NAVIGATION_BAR_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT); mState.getDisplayCutoutSafe(mDisplayCutoutSafe); mWindowBounds = new Rect(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT); Loading Loading @@ -268,8 +264,8 @@ public class WindowLayoutTests { @Test public void fitInvisibleInsets() { mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); computeFrames(); assertInsetByTopBottom(0, 0, mFrames.displayFrame); Loading @@ -279,8 +275,8 @@ public class WindowLayoutTests { @Test public void fitInvisibleInsetsIgnoringVisibility() { mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); mAttrs.setFitInsetsIgnoringVisibility(true); computeFrames(); Loading Loading @@ -324,11 +320,11 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading Loading @@ -365,17 +361,17 @@ public class WindowLayoutTests { @Test public void layoutInDisplayCutoutModeDefaultWithInvisibleSystemBars() { addDisplayCutout(); mState.setSourceVisible(ITYPE_STATUS_BAR, false); mState.setSourceVisible(ITYPE_NAVIGATION_BAR, false); mState.setSourceVisible(ID_STATUS_BAR, false); mState.setSourceVisible(ID_NAVIGATION_BAR, false); mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading @@ -398,11 +394,11 @@ public class WindowLayoutTests { mAttrs.setFitInsetsTypes(0); computeFrames(); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.displayFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.parentFrame); assertInsetBy(WATERFALL_INSETS.left, STATUS_BAR_HEIGHT, WATERFALL_INSETS.right, 0, assertInsetBy(WATERFALL_INSETS.left, DISPLAY_CUTOUT_HEIGHT, WATERFALL_INSETS.right, 0, mFrames.frame); } Loading