Revert "Reland "Make extra navigation bar count towards non decor frame"""
This reverts commit 620e91578c.
Reason for revert: b/238985243
Change-Id: I1fc82c61b445b6f5ceedb2ec8b727e8e745f47c9
This commit is contained in:
@@ -118,11 +118,11 @@ public class WindowLayout {
|
||||
}
|
||||
if (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) {
|
||||
if (displayFrame.width() < displayFrame.height()) {
|
||||
displayCutoutSafeExceptMaybeBars.top = MIN_Y;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
displayCutoutSafeExceptMaybeBars.top = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
} else {
|
||||
displayCutoutSafeExceptMaybeBars.left = MIN_X;
|
||||
displayCutoutSafeExceptMaybeBars.right = MAX_X;
|
||||
displayCutoutSafeExceptMaybeBars.left = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.right = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
final boolean layoutInsetDecor = (attrs.flags & FLAG_LAYOUT_INSET_DECOR) != 0;
|
||||
@@ -132,23 +132,23 @@ public class WindowLayout {
|
||||
final Insets systemBarsInsets = state.calculateInsets(
|
||||
displayFrame, WindowInsets.Type.systemBars(), requestedVisibilities);
|
||||
if (systemBarsInsets.left > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.left = MIN_X;
|
||||
displayCutoutSafeExceptMaybeBars.left = Integer.MIN_VALUE;
|
||||
}
|
||||
if (systemBarsInsets.top > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.top = MIN_Y;
|
||||
displayCutoutSafeExceptMaybeBars.top = Integer.MIN_VALUE;
|
||||
}
|
||||
if (systemBarsInsets.right > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.right = MAX_X;
|
||||
displayCutoutSafeExceptMaybeBars.right = Integer.MAX_VALUE;
|
||||
}
|
||||
if (systemBarsInsets.bottom > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
if (type == TYPE_INPUT_METHOD) {
|
||||
final InsetsSource navSource = state.peekSource(ITYPE_NAVIGATION_BAR);
|
||||
if (navSource != null && navSource.calculateInsets(displayFrame, true).bottom > 0) {
|
||||
// The IME can always extend under the bottom cutout if the navbar is there.
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
final boolean attachedInParent = attachedWindowFrame != null && !layoutInScreen;
|
||||
|
||||
@@ -308,6 +308,7 @@ import android.util.TypedXmlPullParser;
|
||||
import android.util.TypedXmlSerializer;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.AppTransitionAnimationSpec;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.IAppTransitionAnimationSpecsFuture;
|
||||
import android.view.InputApplicationHandle;
|
||||
@@ -351,7 +352,6 @@ import com.android.server.wm.ActivityMetricsLogger.TransitionInfoSnapshot;
|
||||
import com.android.server.wm.SurfaceAnimator.AnimationType;
|
||||
import com.android.server.wm.WindowManagerService.H;
|
||||
import com.android.server.wm.utils.InsetUtils;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import dalvik.annotation.optimization.NeverCompile;
|
||||
|
||||
@@ -9609,8 +9609,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
|
||||
final int dw = rotated ? display.mBaseDisplayHeight : display.mBaseDisplayWidth;
|
||||
final int dh = rotated ? display.mBaseDisplayWidth : display.mBaseDisplayHeight;
|
||||
final WmDisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation);
|
||||
policy.getNonDecorInsetsLw(rotation, dw, dh, cutout, mNonDecorInsets[rotation]);
|
||||
final DisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation)
|
||||
.getDisplayCutout();
|
||||
policy.getNonDecorInsetsLw(rotation, cutout, mNonDecorInsets[rotation]);
|
||||
mStableInsets[rotation].set(mNonDecorInsets[rotation]);
|
||||
policy.convertNonDecorInsetsToStableInsets(mStableInsets[rotation], rotation);
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
*/
|
||||
final DisplayMetrics mRealDisplayMetrics = new DisplayMetrics();
|
||||
|
||||
/** @see #computeCompatSmallestWidth(boolean, int, int) */
|
||||
/** @see #computeCompatSmallestWidth(boolean, int, int, int) */
|
||||
private final DisplayMetrics mTmpDisplayMetrics = new DisplayMetrics();
|
||||
|
||||
/**
|
||||
@@ -2012,7 +2012,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
// the top of the method, the caller is obligated to call computeNewConfigurationLocked().
|
||||
// By updating the Display info here it will be available to
|
||||
// #computeScreenConfiguration() later.
|
||||
updateDisplayAndOrientation(null /* outConfig */);
|
||||
updateDisplayAndOrientation(getConfiguration().uiMode, null /* outConfig */);
|
||||
|
||||
// NOTE: We disable the rotation in the emulator because
|
||||
// it doesn't support hardware OpenGL emulation yet.
|
||||
@@ -2062,7 +2062,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
* changed.
|
||||
* Do not call if {@link WindowManagerService#mDisplayReady} == false.
|
||||
*/
|
||||
private DisplayInfo updateDisplayAndOrientation(Configuration outConfig) {
|
||||
private DisplayInfo updateDisplayAndOrientation(int uiMode, Configuration outConfig) {
|
||||
// Use the effective "visual" dimensions based on current rotation
|
||||
final int rotation = getRotation();
|
||||
final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
|
||||
@@ -2074,16 +2074,18 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
final DisplayCutout displayCutout = wmDisplayCutout.getDisplayCutout();
|
||||
final RoundedCorners roundedCorners = calculateRoundedCornersForRotation(rotation);
|
||||
|
||||
final Rect appFrame = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
|
||||
displayCutout);
|
||||
mDisplayInfo.rotation = rotation;
|
||||
mDisplayInfo.logicalWidth = dw;
|
||||
mDisplayInfo.logicalHeight = dh;
|
||||
mDisplayInfo.logicalDensityDpi = mBaseDisplayDensity;
|
||||
mDisplayInfo.physicalXDpi = mBaseDisplayPhysicalXDpi;
|
||||
mDisplayInfo.physicalYDpi = mBaseDisplayPhysicalYDpi;
|
||||
mDisplayInfo.appWidth = appFrame.width();
|
||||
mDisplayInfo.appHeight = appFrame.height();
|
||||
mDisplayInfo.appWidth = appWidth;
|
||||
mDisplayInfo.appHeight = appHeight;
|
||||
if (isDefaultDisplay) {
|
||||
mDisplayInfo.getLogicalMetrics(mRealDisplayMetrics,
|
||||
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
|
||||
@@ -2097,7 +2099,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
mDisplayInfo.flags &= ~Display.FLAG_SCALING_DISABLED;
|
||||
}
|
||||
|
||||
computeSizeRangesAndScreenLayout(mDisplayInfo, rotated, dw, dh,
|
||||
computeSizeRangesAndScreenLayout(mDisplayInfo, rotated, uiMode, dw, dh,
|
||||
mDisplayMetrics.density, outConfig);
|
||||
|
||||
mWmService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId,
|
||||
@@ -2187,8 +2189,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
outConfig.windowConfiguration.setMaxBounds(0, 0, dw, dh);
|
||||
outConfig.windowConfiguration.setBounds(outConfig.windowConfiguration.getMaxBounds());
|
||||
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
computeScreenAppConfiguration(outConfig, dw, dh, rotation, wmDisplayCutout);
|
||||
final int uiMode = getConfiguration().uiMode;
|
||||
final DisplayCutout displayCutout =
|
||||
calculateDisplayCutoutForRotation(rotation).getDisplayCutout();
|
||||
computeScreenAppConfiguration(outConfig, dw, dh, rotation, uiMode, displayCutout);
|
||||
|
||||
final DisplayInfo displayInfo = new DisplayInfo(mDisplayInfo);
|
||||
displayInfo.rotation = rotation;
|
||||
@@ -2197,35 +2201,38 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
final Rect appBounds = outConfig.windowConfiguration.getAppBounds();
|
||||
displayInfo.appWidth = appBounds.width();
|
||||
displayInfo.appHeight = appBounds.height();
|
||||
final DisplayCutout displayCutout = wmDisplayCutout.getDisplayCutout();
|
||||
displayInfo.displayCutout = displayCutout.isEmpty() ? null : displayCutout;
|
||||
computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh,
|
||||
computeSizeRangesAndScreenLayout(displayInfo, rotated, uiMode, dw, dh,
|
||||
mDisplayMetrics.density, outConfig);
|
||||
return displayInfo;
|
||||
}
|
||||
|
||||
/** Compute configuration related to application without changing current display. */
|
||||
private void computeScreenAppConfiguration(Configuration outConfig, int dw, int dh,
|
||||
int rotation, WmDisplayCutout wmDisplayCutout) {
|
||||
DisplayFrames displayFrames =
|
||||
mDisplayPolicy.getSimulatedDisplayFrames(rotation, dw, dh, wmDisplayCutout);
|
||||
final Rect appFrame =
|
||||
mDisplayPolicy.getNonDecorDisplayFrameWithSimulatedFrame(displayFrames);
|
||||
int rotation, int uiMode, DisplayCutout displayCutout) {
|
||||
final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
|
||||
displayCutout);
|
||||
mDisplayPolicy.getNonDecorInsetsLw(rotation, displayCutout, mTmpRect);
|
||||
final int leftInset = mTmpRect.left;
|
||||
final int topInset = mTmpRect.top;
|
||||
// AppBounds at the root level should mirror the app screen size.
|
||||
outConfig.windowConfiguration.setAppBounds(appFrame);
|
||||
outConfig.windowConfiguration.setAppBounds(leftInset /* left */, topInset /* top */,
|
||||
leftInset + appWidth /* right */, topInset + appHeight /* bottom */);
|
||||
outConfig.windowConfiguration.setRotation(rotation);
|
||||
outConfig.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
|
||||
|
||||
final float density = mDisplayMetrics.density;
|
||||
final Point configSize =
|
||||
mDisplayPolicy.getConfigDisplaySizeWithSimulatedFrame(displayFrames);
|
||||
outConfig.screenWidthDp = (int) (configSize.x / density + 0.5f);
|
||||
outConfig.screenHeightDp = (int) (configSize.y / density + 0.5f);
|
||||
outConfig.screenWidthDp = (int) (mDisplayPolicy.getConfigDisplayWidth(dw, dh, rotation,
|
||||
uiMode, displayCutout) / density + 0.5f);
|
||||
outConfig.screenHeightDp = (int) (mDisplayPolicy.getConfigDisplayHeight(dw, dh, rotation,
|
||||
uiMode, displayCutout) / density + 0.5f);
|
||||
outConfig.compatScreenWidthDp = (int) (outConfig.screenWidthDp / mCompatibleScreenScale);
|
||||
outConfig.compatScreenHeightDp = (int) (outConfig.screenHeightDp / mCompatibleScreenScale);
|
||||
|
||||
final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
|
||||
outConfig.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dw, dh);
|
||||
outConfig.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, uiMode, dw, dh);
|
||||
outConfig.windowConfiguration.setDisplayRotation(rotation);
|
||||
}
|
||||
|
||||
@@ -2234,7 +2241,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
* Do not call if mDisplayReady == false.
|
||||
*/
|
||||
void computeScreenConfiguration(Configuration config) {
|
||||
final DisplayInfo displayInfo = updateDisplayAndOrientation(config);
|
||||
final DisplayInfo displayInfo = updateDisplayAndOrientation(config.uiMode, config);
|
||||
final int dw = displayInfo.logicalWidth;
|
||||
final int dh = displayInfo.logicalHeight;
|
||||
mTmpRect.set(0, 0, dw, dh);
|
||||
@@ -2243,8 +2250,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
config.windowConfiguration.setWindowingMode(getWindowingMode());
|
||||
config.windowConfiguration.setDisplayWindowingMode(getWindowingMode());
|
||||
|
||||
computeScreenAppConfiguration(config, dw, dh, displayInfo.rotation,
|
||||
calculateDisplayCutoutForRotation(getRotation()));
|
||||
computeScreenAppConfiguration(config, dw, dh, displayInfo.rotation, config.uiMode,
|
||||
displayInfo.displayCutout);
|
||||
|
||||
config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK)
|
||||
| ((displayInfo.flags & Display.FLAG_ROUND) != 0
|
||||
@@ -2333,7 +2340,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
mWmService.mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
|
||||
}
|
||||
|
||||
private int computeCompatSmallestWidth(boolean rotated, int dw, int dh) {
|
||||
private int computeCompatSmallestWidth(boolean rotated, int uiMode, int dw, int dh) {
|
||||
mTmpDisplayMetrics.setTo(mDisplayMetrics);
|
||||
final DisplayMetrics tmpDm = mTmpDisplayMetrics;
|
||||
final int unrotDw, unrotDh;
|
||||
@@ -2344,20 +2351,25 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
unrotDw = dw;
|
||||
unrotDh = dh;
|
||||
}
|
||||
int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, tmpDm, unrotDw, unrotDh);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, tmpDm, unrotDh, unrotDw);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, tmpDm, unrotDw, unrotDh);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, tmpDm, unrotDh, unrotDw);
|
||||
int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, uiMode, tmpDm, unrotDw,
|
||||
unrotDh);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, uiMode, tmpDm, unrotDh,
|
||||
unrotDw);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, uiMode, tmpDm, unrotDw,
|
||||
unrotDh);
|
||||
sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, uiMode, tmpDm, unrotDh,
|
||||
unrotDw);
|
||||
return sw;
|
||||
}
|
||||
|
||||
private int reduceCompatConfigWidthSize(int curSize, int rotation,
|
||||
private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode,
|
||||
DisplayMetrics dm, int dw, int dh) {
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
final Rect nonDecorSize = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
dm.noncompatWidthPixels = nonDecorSize.width();
|
||||
dm.noncompatHeightPixels = nonDecorSize.height();
|
||||
final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(
|
||||
rotation).getDisplayCutout();
|
||||
dm.noncompatWidthPixels = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
dm.noncompatHeightPixels = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
|
||||
displayCutout);
|
||||
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
|
||||
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
|
||||
if (curSize == 0 || size < curSize) {
|
||||
@@ -2367,7 +2379,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
}
|
||||
|
||||
private void computeSizeRangesAndScreenLayout(DisplayInfo displayInfo, boolean rotated,
|
||||
int dw, int dh, float density, Configuration outConfig) {
|
||||
int uiMode, int dw, int dh, float density, Configuration outConfig) {
|
||||
|
||||
// We need to determine the smallest width that will occur under normal
|
||||
// operation. To this, start with the base screen size and compute the
|
||||
@@ -2385,34 +2397,37 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
displayInfo.smallestNominalAppHeight = 1<<30;
|
||||
displayInfo.largestNominalAppWidth = 0;
|
||||
displayInfo.largestNominalAppHeight = 0;
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, unrotDw, unrotDh);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, unrotDh, unrotDw);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, unrotDw, unrotDh);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, unrotDh, unrotDw);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, uiMode, unrotDw, unrotDh);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, uiMode, unrotDh, unrotDw);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, uiMode, unrotDw, unrotDh);
|
||||
adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, uiMode, unrotDh, unrotDw);
|
||||
|
||||
if (outConfig == null) {
|
||||
return;
|
||||
}
|
||||
int sl = Configuration.resetScreenLayout(outConfig.screenLayout);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh, uiMode);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode);
|
||||
sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode);
|
||||
outConfig.smallestScreenWidthDp =
|
||||
(int) (displayInfo.smallestNominalAppWidth / density + 0.5f);
|
||||
outConfig.screenLayout = sl;
|
||||
}
|
||||
|
||||
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh) {
|
||||
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh,
|
||||
int uiMode) {
|
||||
// Get the display cutout at this rotation.
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(
|
||||
rotation).getDisplayCutout();
|
||||
|
||||
// Get the app screen size at this rotation.
|
||||
final Rect size = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation, wmDisplayCutout);
|
||||
int w = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, displayCutout);
|
||||
int h = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation, displayCutout);
|
||||
|
||||
// Compute the screen layout size class for this rotation.
|
||||
int longSize = size.width();
|
||||
int shortSize = size.height();
|
||||
int longSize = w;
|
||||
int shortSize = h;
|
||||
if (longSize < shortSize) {
|
||||
int tmp = longSize;
|
||||
longSize = shortSize;
|
||||
@@ -2423,20 +2438,25 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
return Configuration.reduceScreenLayout(curLayout, longSize, shortSize);
|
||||
}
|
||||
|
||||
private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int dw, int dh) {
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
final Point size = mDisplayPolicy.getConfigDisplaySize(dw, dh, rotation, wmDisplayCutout);
|
||||
if (size.x < displayInfo.smallestNominalAppWidth) {
|
||||
displayInfo.smallestNominalAppWidth = size.x;
|
||||
private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation,
|
||||
int uiMode, int dw, int dh) {
|
||||
final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(
|
||||
rotation).getDisplayCutout();
|
||||
final int width = mDisplayPolicy.getConfigDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
if (width < displayInfo.smallestNominalAppWidth) {
|
||||
displayInfo.smallestNominalAppWidth = width;
|
||||
}
|
||||
if (size.x > displayInfo.largestNominalAppWidth) {
|
||||
displayInfo.largestNominalAppWidth = size.x;
|
||||
if (width > displayInfo.largestNominalAppWidth) {
|
||||
displayInfo.largestNominalAppWidth = width;
|
||||
}
|
||||
if (size.y < displayInfo.smallestNominalAppHeight) {
|
||||
displayInfo.smallestNominalAppHeight = size.y;
|
||||
final int height = mDisplayPolicy.getConfigDisplayHeight(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
if (height < displayInfo.smallestNominalAppHeight) {
|
||||
displayInfo.smallestNominalAppHeight = height;
|
||||
}
|
||||
if (size.y > displayInfo.largestNominalAppHeight) {
|
||||
displayInfo.largestNominalAppHeight = size.y;
|
||||
if (height > displayInfo.largestNominalAppHeight) {
|
||||
displayInfo.largestNominalAppHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.gui.DropInputMode;
|
||||
@@ -127,8 +126,6 @@ import android.view.InsetsSource;
|
||||
import android.view.InsetsState;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.InsetsVisibilities;
|
||||
import android.view.PrivacyIndicatorBounds;
|
||||
import android.view.RoundedCorners;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
@@ -162,7 +159,6 @@ import com.android.server.policy.WindowManagerPolicy.ScreenOnListener;
|
||||
import com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs;
|
||||
import com.android.server.statusbar.StatusBarManagerInternal;
|
||||
import com.android.server.wallpaper.WallpaperManagerInternal;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -1994,6 +1990,35 @@ public class DisplayPolicy {
|
||||
return mUiContext;
|
||||
}
|
||||
|
||||
private int getNavigationBarWidth(int rotation, int uiMode, int position) {
|
||||
if (mNavigationBar == null) {
|
||||
return 0;
|
||||
}
|
||||
LayoutParams lp = mNavigationBar.mAttrs;
|
||||
if (lp.paramsForRotation != null
|
||||
&& lp.paramsForRotation.length == 4
|
||||
&& lp.paramsForRotation[rotation] != null) {
|
||||
lp = lp.paramsForRotation[rotation];
|
||||
}
|
||||
Insets providedInsetsSize = null;
|
||||
if (lp.providedInsets != null) {
|
||||
for (InsetsFrameProvider provider : lp.providedInsets) {
|
||||
if (provider.type != ITYPE_NAVIGATION_BAR) {
|
||||
continue;
|
||||
}
|
||||
providedInsetsSize = provider.insetsSize;
|
||||
}
|
||||
}
|
||||
if (providedInsetsSize != null) {
|
||||
if (position == NAV_BAR_LEFT) {
|
||||
return providedInsetsSize.left;
|
||||
} else if (position == NAV_BAR_RIGHT) {
|
||||
return providedInsetsSize.right;
|
||||
}
|
||||
}
|
||||
return lp.width;
|
||||
}
|
||||
|
||||
void notifyDisplayReady() {
|
||||
mHandler.post(() -> {
|
||||
final int displayId = getDisplayId();
|
||||
@@ -2010,24 +2035,45 @@ public class DisplayPolicy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the display frame available after excluding any screen decorations that could never be
|
||||
* removed in Honeycomb. That is, system bar or button bar.
|
||||
*
|
||||
* @return display frame excluding all non-decor insets.
|
||||
* Return the display width available after excluding any screen
|
||||
* decorations that could never be removed in Honeycomb. That is, system bar or
|
||||
* button bar.
|
||||
*/
|
||||
Rect getNonDecorDisplayFrame(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout cutout) {
|
||||
final DisplayFrames displayFrames =
|
||||
getSimulatedDisplayFrames(rotation, fullWidth, fullHeight, cutout);
|
||||
return getNonDecorDisplayFrameWithSimulatedFrame(displayFrames);
|
||||
public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode,
|
||||
DisplayCutout displayCutout) {
|
||||
int width = fullWidth;
|
||||
if (hasNavigationBar()) {
|
||||
final int navBarPosition = navigationBarPosition(rotation);
|
||||
if (navBarPosition == NAV_BAR_LEFT || navBarPosition == NAV_BAR_RIGHT) {
|
||||
width -= getNavigationBarWidth(rotation, uiMode, navBarPosition);
|
||||
}
|
||||
}
|
||||
if (displayCutout != null) {
|
||||
width -= displayCutout.getSafeInsetLeft() + displayCutout.getSafeInsetRight();
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
Rect getNonDecorDisplayFrameWithSimulatedFrame(DisplayFrames displayFrames) {
|
||||
final Rect nonDecorInsets =
|
||||
getInsets(displayFrames, Type.displayCutout() | Type.navigationBars()).toRect();
|
||||
final Rect displayFrame = new Rect(displayFrames.mInsetsState.getDisplayFrame());
|
||||
displayFrame.inset(nonDecorInsets);
|
||||
return displayFrame;
|
||||
@VisibleForTesting
|
||||
int getNavigationBarHeight(int rotation) {
|
||||
if (mNavigationBar == null) {
|
||||
return 0;
|
||||
}
|
||||
LayoutParams lp = mNavigationBar.mAttrs.forRotation(rotation);
|
||||
Insets providedInsetsSize = null;
|
||||
if (lp.providedInsets != null) {
|
||||
for (InsetsFrameProvider provider : lp.providedInsets) {
|
||||
if (provider.type != ITYPE_NAVIGATION_BAR) {
|
||||
continue;
|
||||
}
|
||||
providedInsetsSize = provider.insetsSize;
|
||||
if (providedInsetsSize != null) {
|
||||
return providedInsetsSize.bottom;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lp.height;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2049,24 +2095,53 @@ public class DisplayPolicy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the available screen size that we should report for the
|
||||
* configuration. This must be no larger than
|
||||
* {@link #getNonDecorDisplayFrame(int, int, int, DisplayCutout)}; it may be smaller
|
||||
* than that to account for more transient decoration like a status bar.
|
||||
* Return the display height available after excluding any screen
|
||||
* decorations that could never be removed in Honeycomb. That is, system bar or
|
||||
* button bar.
|
||||
*/
|
||||
public Point getConfigDisplaySize(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout wmDisplayCutout) {
|
||||
final DisplayFrames displayFrames = getSimulatedDisplayFrames(rotation, fullWidth,
|
||||
fullHeight, wmDisplayCutout);
|
||||
return getConfigDisplaySizeWithSimulatedFrame(displayFrames);
|
||||
public int getNonDecorDisplayHeight(int fullHeight, int rotation, DisplayCutout displayCutout) {
|
||||
int height = fullHeight;
|
||||
final int navBarPosition = navigationBarPosition(rotation);
|
||||
if (navBarPosition == NAV_BAR_BOTTOM) {
|
||||
height -= getNavigationBarHeight(rotation);
|
||||
}
|
||||
if (displayCutout != null) {
|
||||
height -= displayCutout.getSafeInsetTop() + displayCutout.getSafeInsetBottom();
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
Point getConfigDisplaySizeWithSimulatedFrame(DisplayFrames displayFrames) {
|
||||
final Insets insets = getInsets(displayFrames,
|
||||
Type.displayCutout() | Type.navigationBars() | Type.statusBars());
|
||||
Rect configFrame = new Rect(displayFrames.mInsetsState.getDisplayFrame());
|
||||
configFrame.inset(insets);
|
||||
return new Point(configFrame.width(), configFrame.height());
|
||||
/**
|
||||
* Return the available screen width that we should report for the
|
||||
* configuration. This must be no larger than
|
||||
* {@link #getNonDecorDisplayWidth(int, int, int, int, DisplayCutout)}; it may be smaller
|
||||
* than that to account for more transient decoration like a status bar.
|
||||
*/
|
||||
public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode,
|
||||
DisplayCutout displayCutout) {
|
||||
return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation, uiMode, displayCutout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the available screen height that we should report for the
|
||||
* configuration. This must be no larger than
|
||||
* {@link #getNonDecorDisplayHeight(int, int, DisplayCutout)}; it may be smaller
|
||||
* than that to account for more transient decoration like a status bar.
|
||||
*/
|
||||
public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode,
|
||||
DisplayCutout displayCutout) {
|
||||
// There is a separate status bar at the top of the display. We don't count that as part
|
||||
// of the fixed decor, since it can hide; however, for purposes of configurations,
|
||||
// we do want to exclude it since applications can't generally use that part
|
||||
// of the screen.
|
||||
int statusBarHeight = mStatusBarHeightForRotation[rotation];
|
||||
if (displayCutout != null) {
|
||||
// If there is a cutout, it may already have accounted for some part of the status
|
||||
// bar height.
|
||||
statusBarHeight = Math.max(0, statusBarHeight - displayCutout.getSafeInsetTop());
|
||||
}
|
||||
return getNonDecorDisplayHeight(fullHeight, rotation, displayCutout)
|
||||
- statusBarHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2098,69 +2173,48 @@ public class DisplayPolicy {
|
||||
* Calculates the stable insets without running a layout.
|
||||
*
|
||||
* @param displayRotation the current display rotation
|
||||
* @param displayWidth full display width
|
||||
* @param displayHeight full display height
|
||||
* @param displayCutout the current display cutout
|
||||
* @param outInsets the insets to return
|
||||
*/
|
||||
public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
|
||||
WmDisplayCutout displayCutout, Rect outInsets) {
|
||||
final DisplayFrames displayFrames = getSimulatedDisplayFrames(displayRotation,
|
||||
displayWidth, displayHeight, displayCutout);
|
||||
getStableInsetsWithSimulatedFrame(displayFrames, outInsets);
|
||||
}
|
||||
public void getStableInsetsLw(int displayRotation, DisplayCutout displayCutout,
|
||||
Rect outInsets) {
|
||||
outInsets.setEmpty();
|
||||
|
||||
void getStableInsetsWithSimulatedFrame(DisplayFrames displayFrames, Rect outInsets) {
|
||||
// Navigation bar, status bar, and cutout.
|
||||
outInsets.set(getInsets(displayFrames,
|
||||
Type.displayCutout() | Type.navigationBars() | Type.statusBars()).toRect());
|
||||
// Navigation bar and status bar.
|
||||
getNonDecorInsetsLw(displayRotation, displayCutout, outInsets);
|
||||
convertNonDecorInsetsToStableInsets(outInsets, displayRotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
|
||||
* bar or button bar. See {@link #getNonDecorDisplayFrame}.
|
||||
*
|
||||
* @param displayRotation the current display rotation
|
||||
* @param fullWidth the width of the display, including all insets
|
||||
* @param fullHeight the height of the display, including all insets
|
||||
* @param cutout the current display cutout
|
||||
* bar or button bar. See {@link #getNonDecorDisplayWidth}.
|
||||
* @param displayRotation the current display rotation
|
||||
* @param displayCutout the current display cutout
|
||||
* @param outInsets the insets to return
|
||||
*/
|
||||
public void getNonDecorInsetsLw(int displayRotation, int fullWidth, int fullHeight,
|
||||
WmDisplayCutout cutout, Rect outInsets) {
|
||||
final DisplayFrames displayFrames =
|
||||
getSimulatedDisplayFrames(displayRotation, fullWidth, fullHeight, cutout);
|
||||
getNonDecorInsetsWithSimulatedFrame(displayFrames, outInsets);
|
||||
}
|
||||
public void getNonDecorInsetsLw(int displayRotation, DisplayCutout displayCutout,
|
||||
Rect outInsets) {
|
||||
outInsets.setEmpty();
|
||||
|
||||
void getNonDecorInsetsWithSimulatedFrame(DisplayFrames displayFrames, Rect outInsets) {
|
||||
outInsets.set(getInsets(displayFrames,
|
||||
Type.displayCutout() | Type.navigationBars()).toRect());
|
||||
}
|
||||
// Only navigation bar
|
||||
if (hasNavigationBar()) {
|
||||
final int uiMode = mService.mPolicy.getUiMode();
|
||||
int position = navigationBarPosition(displayRotation);
|
||||
if (position == NAV_BAR_BOTTOM) {
|
||||
outInsets.bottom = getNavigationBarHeight(displayRotation);
|
||||
} else if (position == NAV_BAR_RIGHT) {
|
||||
outInsets.right = getNavigationBarWidth(displayRotation, uiMode, position);
|
||||
} else if (position == NAV_BAR_LEFT) {
|
||||
outInsets.left = getNavigationBarWidth(displayRotation, uiMode, position);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFrames getSimulatedDisplayFrames(int displayRotation, int fullWidth,
|
||||
int fullHeight, WmDisplayCutout cutout) {
|
||||
final DisplayInfo info = new DisplayInfo(mDisplayContent.getDisplayInfo());
|
||||
info.rotation = displayRotation;
|
||||
info.logicalWidth = fullWidth;
|
||||
info.logicalHeight = fullHeight;
|
||||
info.displayCutout = cutout.getDisplayCutout();
|
||||
final RoundedCorners roundedCorners =
|
||||
mDisplayContent.calculateRoundedCornersForRotation(displayRotation);
|
||||
final PrivacyIndicatorBounds indicatorBounds =
|
||||
mDisplayContent.calculatePrivacyIndicatorBoundsForRotation(displayRotation);
|
||||
final DisplayFrames displayFrames = new DisplayFrames(getDisplayId(), new InsetsState(),
|
||||
info, cutout, roundedCorners, indicatorBounds);
|
||||
simulateLayoutDisplay(displayFrames);
|
||||
return displayFrames;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Insets getInsets(DisplayFrames displayFrames, @InsetsType int type) {
|
||||
final InsetsState state = displayFrames.mInsetsState;
|
||||
final Insets insets = state.calculateInsets(state.getDisplayFrame(), type,
|
||||
true /* ignoreVisibility */);
|
||||
return insets;
|
||||
if (displayCutout != null) {
|
||||
outInsets.left += displayCutout.getSafeInsetLeft();
|
||||
outInsets.top += displayCutout.getSafeInsetTop();
|
||||
outInsets.right += displayCutout.getSafeInsetRight();
|
||||
outInsets.bottom += displayCutout.getSafeInsetBottom();
|
||||
}
|
||||
}
|
||||
|
||||
@NavigationBarPosition
|
||||
@@ -2186,7 +2240,7 @@ public class DisplayPolicy {
|
||||
* @see WindowManagerPolicyConstants#NAV_BAR_BOTTOM
|
||||
*/
|
||||
@NavigationBarPosition
|
||||
int getNavBarPosition() {
|
||||
public int getNavBarPosition() {
|
||||
return mNavigationBarPosition;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ import com.android.internal.util.function.pooled.PooledLambda;
|
||||
import com.android.internal.util.function.pooled.PooledPredicate;
|
||||
import com.android.server.am.HostingRecord;
|
||||
import com.android.server.pm.parsing.pkg.AndroidPackage;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -2195,13 +2194,11 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
mTmpBounds.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
|
||||
|
||||
final DisplayPolicy policy = rootTask.mDisplayContent.getDisplayPolicy();
|
||||
final WmDisplayCutout cutout =
|
||||
rootTask.mDisplayContent.calculateDisplayCutoutForRotation(displayInfo.rotation);
|
||||
final DisplayFrames displayFrames = policy.getSimulatedDisplayFrames(displayInfo.rotation,
|
||||
displayInfo.logicalWidth, displayInfo.logicalHeight, cutout);
|
||||
policy.getNonDecorInsetsWithSimulatedFrame(displayFrames, mTmpInsets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation,
|
||||
displayInfo.displayCutout, mTmpInsets);
|
||||
intersectWithInsetsIfFits(outNonDecorBounds, mTmpBounds, mTmpInsets);
|
||||
policy.getStableInsetsWithSimulatedFrame(displayFrames, mTmpInsets);
|
||||
|
||||
policy.convertNonDecorInsetsToStableInsets(mTmpInsets, displayInfo.rotation);
|
||||
intersectWithInsetsIfFits(outStableBounds, mTmpBounds, mTmpInsets);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,6 @@ import com.android.server.policy.WindowManagerPolicy;
|
||||
import com.android.server.policy.WindowManagerPolicy.ScreenOffListener;
|
||||
import com.android.server.power.ShutdownThread;
|
||||
import com.android.server.utils.PriorityDump;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import dalvik.annotation.optimization.NeverCompile;
|
||||
|
||||
@@ -1854,8 +1853,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "addWindow: New client %s"
|
||||
+ ": window=%s Callers=%s", client.asBinder(), win, Debug.getCallers(5));
|
||||
|
||||
if ((win.isVisibleRequestedOrAdding() && displayContent.updateOrientation())
|
||||
|| win.providesNonDecorInsets()) {
|
||||
if (win.isVisibleRequestedOrAdding() && displayContent.updateOrientation()) {
|
||||
displayContent.sendNewConfiguration();
|
||||
}
|
||||
|
||||
@@ -6378,8 +6376,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
+ " callers=" + Debug.getCallers(3));
|
||||
return NAV_BAR_INVALID;
|
||||
}
|
||||
return displayContent.getDisplayPolicy().navigationBarPosition(
|
||||
displayContent.getDisplayRotation().getRotation());
|
||||
return displayContent.getDisplayPolicy().getNavBarPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7220,9 +7217,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
final DisplayContent dc = mRoot.getDisplayContent(displayId);
|
||||
if (dc != null) {
|
||||
final DisplayInfo di = dc.getDisplayInfo();
|
||||
final WmDisplayCutout cutout = dc.calculateDisplayCutoutForRotation(di.rotation);
|
||||
dc.getDisplayPolicy().getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, outInsets);
|
||||
dc.getDisplayPolicy().getStableInsetsLw(di.rotation, di.displayCutout, outInsets);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,6 @@ import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInfo;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
@@ -1922,19 +1921,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
return (mPolicyVisibility & POLICY_VISIBILITY_ALL) == POLICY_VISIBILITY_ALL;
|
||||
}
|
||||
|
||||
boolean providesNonDecorInsets() {
|
||||
if (mProvidedInsetsSources == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = mProvidedInsetsSources.size() - 1; i >= 0; i--) {
|
||||
final int type = mProvidedInsetsSources.keyAt(i);
|
||||
if ((InsetsState.toPublicType(type) & WindowInsets.Type.navigationBars()) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void clearPolicyVisibilityFlag(int policyVisibilityFlag) {
|
||||
mPolicyVisibility &= ~policyVisibilityFlag;
|
||||
mWmService.scheduleAnimationLocked();
|
||||
@@ -2645,19 +2631,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
removeImmediately();
|
||||
boolean sentNewConfig = false;
|
||||
// Removing a visible window will effect the computed orientation
|
||||
// So just update orientation if needed.
|
||||
if (wasVisible) {
|
||||
// Removing a visible window will effect the computed orientation
|
||||
// So just update orientation if needed.
|
||||
final DisplayContent displayContent = getDisplayContent();
|
||||
if (displayContent.updateOrientation()) {
|
||||
displayContent.sendNewConfiguration();
|
||||
sentNewConfig = true;
|
||||
}
|
||||
}
|
||||
if (!sentNewConfig && providesNonDecorInsets()) {
|
||||
getDisplayContent().sendNewConfiguration();
|
||||
}
|
||||
mWmService.updateFocusedWindowLocked(isFocused()
|
||||
? UPDATE_FOCUS_REMOVING_FOCUS
|
||||
: UPDATE_FOCUS_NORMAL,
|
||||
|
||||
@@ -157,7 +157,6 @@ import androidx.test.filters.MediumTest;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.server.wm.ActivityRecord.State;
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -551,8 +550,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
final Rect insets = new Rect();
|
||||
final DisplayInfo displayInfo = task.mDisplayContent.getDisplayInfo();
|
||||
final DisplayPolicy policy = task.mDisplayContent.getDisplayPolicy();
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth,
|
||||
displayInfo.logicalHeight, WmDisplayCutout.NO_CUTOUT, insets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.displayCutout, insets);
|
||||
policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation);
|
||||
Task.intersectWithInsetsIfFits(stableRect, stableRect, insets);
|
||||
|
||||
@@ -593,8 +591,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
final Rect insets = new Rect();
|
||||
final DisplayInfo displayInfo = rootTask.mDisplayContent.getDisplayInfo();
|
||||
final DisplayPolicy policy = rootTask.mDisplayContent.getDisplayPolicy();
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth,
|
||||
displayInfo.logicalHeight, WmDisplayCutout.NO_CUTOUT, insets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.displayCutout, insets);
|
||||
policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation);
|
||||
Task.intersectWithInsetsIfFits(stableRect, stableRect, insets);
|
||||
|
||||
|
||||
@@ -25,13 +25,10 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.util.Pair;
|
||||
import android.view.DisplayInfo;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.server.wm.utils.WmDisplayCutout;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ErrorCollector;
|
||||
@@ -49,8 +46,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void portrait() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_0, false /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_0, false /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT);
|
||||
@@ -59,8 +55,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void portrait_withCutout() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_0, true /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_0, true /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, DISPLAY_CUTOUT_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
@@ -69,8 +64,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void landscape() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_90, false /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_90, false /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0);
|
||||
@@ -85,8 +79,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void landscape_withCutout() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_90, true /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_90, true /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, DISPLAY_CUTOUT_HEIGHT, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0);
|
||||
@@ -101,8 +94,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void seascape() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_270, false /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_270, false /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, 0, 0);
|
||||
@@ -117,8 +109,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void seascape_withCutout() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_270, true /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_270, true /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, DISPLAY_CUTOUT_HEIGHT, 0);
|
||||
@@ -133,8 +124,7 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void upsideDown() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_180, false /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_180, false /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT);
|
||||
@@ -143,34 +133,28 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void upsideDown_withCutout() {
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_180, true /* withCutout */);
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_180, true /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT + DISPLAY_CUTOUT_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT + DISPLAY_CUTOUT_HEIGHT);
|
||||
verifyConsistency(di);
|
||||
}
|
||||
|
||||
private void verifyStableInsets(Pair<DisplayInfo, WmDisplayCutout> diPair, int left, int top,
|
||||
int right, int bottom) {
|
||||
mErrorCollector.checkThat("stableInsets", getStableInsetsLw(diPair.first, diPair.second),
|
||||
equalTo(new Rect(left, top, right, bottom)));
|
||||
}
|
||||
|
||||
private void verifyNonDecorInsets(Pair<DisplayInfo, WmDisplayCutout> diPair, int left, int top,
|
||||
int right, int bottom) {
|
||||
mErrorCollector.checkThat("nonDecorInsets",
|
||||
getNonDecorInsetsLw(diPair.first, diPair.second), equalTo(new Rect(
|
||||
private void verifyStableInsets(DisplayInfo di, int left, int top, int right, int bottom) {
|
||||
mErrorCollector.checkThat("stableInsets", getStableInsetsLw(di), equalTo(new Rect(
|
||||
left, top, right, bottom)));
|
||||
}
|
||||
|
||||
private void verifyConsistency(Pair<DisplayInfo, WmDisplayCutout> diPair) {
|
||||
final DisplayInfo di = diPair.first;
|
||||
final WmDisplayCutout cutout = diPair.second;
|
||||
verifyConsistency("configDisplay", di, getStableInsetsLw(di, cutout),
|
||||
getConfigDisplayWidth(di, cutout), getConfigDisplayHeight(di, cutout));
|
||||
verifyConsistency("nonDecorDisplay", di, getNonDecorInsetsLw(di, cutout),
|
||||
getNonDecorDisplayWidth(di, cutout), getNonDecorDisplayHeight(di, cutout));
|
||||
private void verifyNonDecorInsets(DisplayInfo di, int left, int top, int right, int bottom) {
|
||||
mErrorCollector.checkThat("nonDecorInsets", getNonDecorInsetsLw(di), equalTo(new Rect(
|
||||
left, top, right, bottom)));
|
||||
}
|
||||
|
||||
private void verifyConsistency(DisplayInfo di) {
|
||||
verifyConsistency("configDisplay", di, getStableInsetsLw(di),
|
||||
getConfigDisplayWidth(di), getConfigDisplayHeight(di));
|
||||
verifyConsistency("nonDecorDisplay", di, getNonDecorInsetsLw(di),
|
||||
getNonDecorDisplayWidth(di), getNonDecorDisplayHeight(di));
|
||||
}
|
||||
|
||||
private void verifyConsistency(String what, DisplayInfo di, Rect insets, int width,
|
||||
@@ -181,42 +165,39 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
equalTo(di.logicalHeight - insets.top - insets.bottom));
|
||||
}
|
||||
|
||||
private Rect getStableInsetsLw(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
private Rect getStableInsetsLw(DisplayInfo di) {
|
||||
Rect result = new Rect();
|
||||
mDisplayPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, result);
|
||||
mDisplayPolicy.getStableInsetsLw(di.rotation, di.displayCutout, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Rect getNonDecorInsetsLw(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
private Rect getNonDecorInsetsLw(DisplayInfo di) {
|
||||
Rect result = new Rect();
|
||||
mDisplayPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, result);
|
||||
mDisplayPolicy.getNonDecorInsetsLw(di.rotation, di.displayCutout, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getNonDecorDisplayWidth(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getNonDecorDisplayFrame(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).width();
|
||||
private int getNonDecorDisplayWidth(DisplayInfo di) {
|
||||
return mDisplayPolicy.getNonDecorDisplayWidth(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, 0 /* ui */, di.displayCutout);
|
||||
}
|
||||
|
||||
private int getNonDecorDisplayHeight(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getNonDecorDisplayFrame(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).height();
|
||||
private int getNonDecorDisplayHeight(DisplayInfo di) {
|
||||
return mDisplayPolicy.getNonDecorDisplayHeight(di.logicalHeight, di.rotation,
|
||||
di.displayCutout);
|
||||
}
|
||||
|
||||
private int getConfigDisplayWidth(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getConfigDisplaySize(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).x;
|
||||
private int getConfigDisplayWidth(DisplayInfo di) {
|
||||
return mDisplayPolicy.getConfigDisplayWidth(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, 0 /* ui */, di.displayCutout);
|
||||
}
|
||||
|
||||
private int getConfigDisplayHeight(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getConfigDisplaySize(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).y;
|
||||
private int getConfigDisplayHeight(DisplayInfo di) {
|
||||
return mDisplayPolicy.getConfigDisplayHeight(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, 0 /* ui */, di.displayCutout);
|
||||
}
|
||||
|
||||
private static Pair<DisplayInfo, WmDisplayCutout> displayInfoForRotation(int rotation,
|
||||
boolean withDisplayCutout) {
|
||||
return displayInfoAndCutoutForRotation(rotation, withDisplayCutout, false);
|
||||
private static DisplayInfo displayInfoForRotation(int rotation, boolean withDisplayCutout) {
|
||||
return displayInfoAndCutoutForRotation(rotation, withDisplayCutout, false).first;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,12 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.eq;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
@@ -40,7 +43,6 @@ import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import com.android.server.wm.DisplayWindowSettings.SettingsProvider.SettingsEntry;
|
||||
|
||||
@@ -202,11 +204,7 @@ class TestDisplayContent extends DisplayContent {
|
||||
doReturn(true).when(newDisplay).supportsSystemDecorations();
|
||||
doReturn(true).when(displayPolicy).hasNavigationBar();
|
||||
doReturn(NAV_BAR_BOTTOM).when(displayPolicy).navigationBarPosition(anyInt());
|
||||
doReturn(Insets.of(0, 0, 0, 20)).when(displayPolicy).getInsets(any(),
|
||||
eq(WindowInsets.Type.displayCutout() | WindowInsets.Type.navigationBars()));
|
||||
doReturn(Insets.of(0, 20, 0, 20)).when(displayPolicy).getInsets(any(),
|
||||
eq(WindowInsets.Type.displayCutout() | WindowInsets.Type.navigationBars()
|
||||
| WindowInsets.Type.statusBars()));
|
||||
doReturn(20).when(displayPolicy).getNavigationBarHeight(anyInt());
|
||||
} else {
|
||||
doReturn(false).when(displayPolicy).hasNavigationBar();
|
||||
doReturn(false).when(displayPolicy).hasStatusBar();
|
||||
|
||||
@@ -323,10 +323,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
mNavBarWindow.mAttrs.gravity = Gravity.BOTTOM;
|
||||
mNavBarWindow.mAttrs.paramsForRotation = new WindowManager.LayoutParams[4];
|
||||
mNavBarWindow.mAttrs.setFitInsetsTypes(0);
|
||||
mNavBarWindow.mAttrs.layoutInDisplayCutoutMode =
|
||||
LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
mNavBarWindow.mAttrs.privateFlags |=
|
||||
WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
|
||||
for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) {
|
||||
mNavBarWindow.mAttrs.paramsForRotation[rot] =
|
||||
getNavBarLayoutParamsForRotation(rot);
|
||||
@@ -383,9 +379,6 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
lp.height = height;
|
||||
lp.gravity = gravity;
|
||||
lp.setFitInsetsTypes(0);
|
||||
lp.privateFlags |=
|
||||
WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
|
||||
lp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
return lp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user