Merge "Make extra navigation bar count towards non decor frame" into tm-dev
This commit is contained in:
@@ -306,7 +306,6 @@ 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;
|
||||
@@ -349,6 +348,7 @@ 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;
|
||||
|
||||
@@ -9420,9 +9420,8 @@ 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 DisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation)
|
||||
.getDisplayCutout();
|
||||
policy.getNonDecorInsetsLw(rotation, cutout, mNonDecorInsets[rotation]);
|
||||
final WmDisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation);
|
||||
policy.getNonDecorInsetsLw(rotation, dw, dh, cutout, mNonDecorInsets[rotation]);
|
||||
mStableInsets[rotation].set(mNonDecorInsets[rotation]);
|
||||
policy.convertNonDecorInsetsToStableInsets(mStableInsets[rotation], rotation);
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
*/
|
||||
final DisplayMetrics mRealDisplayMetrics = new DisplayMetrics();
|
||||
|
||||
/** @see #computeCompatSmallestWidth(boolean, int, int, int) */
|
||||
/** @see #computeCompatSmallestWidth(boolean, int, int) */
|
||||
private final DisplayMetrics mTmpDisplayMetrics = new DisplayMetrics();
|
||||
|
||||
/**
|
||||
@@ -1967,7 +1967,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(getConfiguration().uiMode, null /* outConfig */);
|
||||
updateDisplayAndOrientation(null /* outConfig */);
|
||||
|
||||
// NOTE: We disable the rotation in the emulator because
|
||||
// it doesn't support hardware OpenGL emulation yet.
|
||||
@@ -2017,7 +2017,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
* changed.
|
||||
* Do not call if {@link WindowManagerService#mDisplayReady} == false.
|
||||
*/
|
||||
private DisplayInfo updateDisplayAndOrientation(int uiMode, Configuration outConfig) {
|
||||
private DisplayInfo updateDisplayAndOrientation(Configuration outConfig) {
|
||||
// Use the effective "visual" dimensions based on current rotation
|
||||
final int rotation = getRotation();
|
||||
final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
|
||||
@@ -2029,16 +2029,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
final DisplayCutout displayCutout = wmDisplayCutout.getDisplayCutout();
|
||||
final RoundedCorners roundedCorners = calculateRoundedCornersForRotation(rotation);
|
||||
|
||||
final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
|
||||
displayCutout);
|
||||
final Rect appFrame = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
mDisplayInfo.rotation = rotation;
|
||||
mDisplayInfo.logicalWidth = dw;
|
||||
mDisplayInfo.logicalHeight = dh;
|
||||
mDisplayInfo.logicalDensityDpi = mBaseDisplayDensity;
|
||||
mDisplayInfo.appWidth = appWidth;
|
||||
mDisplayInfo.appHeight = appHeight;
|
||||
mDisplayInfo.appWidth = appFrame.width();
|
||||
mDisplayInfo.appHeight = appFrame.height();
|
||||
if (isDefaultDisplay) {
|
||||
mDisplayInfo.getLogicalMetrics(mRealDisplayMetrics,
|
||||
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
|
||||
@@ -2052,7 +2050,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
mDisplayInfo.flags &= ~Display.FLAG_SCALING_DISABLED;
|
||||
}
|
||||
|
||||
computeSizeRangesAndScreenLayout(mDisplayInfo, rotated, uiMode, dw, dh,
|
||||
computeSizeRangesAndScreenLayout(mDisplayInfo, rotated, dw, dh,
|
||||
mDisplayMetrics.density, outConfig);
|
||||
|
||||
mWmService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId,
|
||||
@@ -2136,10 +2134,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
outConfig.windowConfiguration.setMaxBounds(0, 0, dw, dh);
|
||||
outConfig.windowConfiguration.setBounds(outConfig.windowConfiguration.getMaxBounds());
|
||||
|
||||
final int uiMode = getConfiguration().uiMode;
|
||||
final DisplayCutout displayCutout =
|
||||
calculateDisplayCutoutForRotation(rotation).getDisplayCutout();
|
||||
computeScreenAppConfiguration(outConfig, dw, dh, rotation, uiMode, displayCutout);
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
computeScreenAppConfiguration(outConfig, dw, dh, rotation, wmDisplayCutout);
|
||||
|
||||
final DisplayInfo displayInfo = new DisplayInfo(mDisplayInfo);
|
||||
displayInfo.rotation = rotation;
|
||||
@@ -2148,38 +2144,33 @@ 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, uiMode, dw, dh,
|
||||
computeSizeRangesAndScreenLayout(displayInfo, rotated, 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, 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;
|
||||
int rotation, WmDisplayCutout wmDisplayCutout) {
|
||||
final Rect appFrame = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
// AppBounds at the root level should mirror the app screen size.
|
||||
outConfig.windowConfiguration.setAppBounds(leftInset /* left */, topInset /* top */,
|
||||
leftInset + appWidth /* right */, topInset + appHeight /* bottom */);
|
||||
outConfig.windowConfiguration.setAppBounds(appFrame);
|
||||
outConfig.windowConfiguration.setRotation(rotation);
|
||||
outConfig.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
|
||||
|
||||
final float density = mDisplayMetrics.density;
|
||||
outConfig.screenWidthDp = (int) (mDisplayPolicy.getConfigDisplayWidth(dw, dh, rotation,
|
||||
uiMode, displayCutout) / density);
|
||||
outConfig.screenHeightDp = (int) (mDisplayPolicy.getConfigDisplayHeight(dw, dh, rotation,
|
||||
uiMode, displayCutout) / density);
|
||||
final Point configSize = mDisplayPolicy.getConfigDisplaySize(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
outConfig.screenWidthDp = (int) (configSize.x / density);
|
||||
outConfig.screenHeightDp = (int) (configSize.y / density);
|
||||
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, uiMode, dw, dh);
|
||||
outConfig.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dw, dh);
|
||||
outConfig.windowConfiguration.setDisplayRotation(rotation);
|
||||
}
|
||||
|
||||
@@ -2188,7 +2179,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
* Do not call if mDisplayReady == false.
|
||||
*/
|
||||
void computeScreenConfiguration(Configuration config) {
|
||||
final DisplayInfo displayInfo = updateDisplayAndOrientation(config.uiMode, config);
|
||||
final DisplayInfo displayInfo = updateDisplayAndOrientation(config);
|
||||
final int dw = displayInfo.logicalWidth;
|
||||
final int dh = displayInfo.logicalHeight;
|
||||
mTmpRect.set(0, 0, dw, dh);
|
||||
@@ -2197,8 +2188,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
config.windowConfiguration.setWindowingMode(getWindowingMode());
|
||||
config.windowConfiguration.setDisplayWindowingMode(getWindowingMode());
|
||||
|
||||
computeScreenAppConfiguration(config, dw, dh, displayInfo.rotation, config.uiMode,
|
||||
displayInfo.displayCutout);
|
||||
computeScreenAppConfiguration(config, dw, dh, displayInfo.rotation,
|
||||
calculateDisplayCutoutForRotation(getRotation()));
|
||||
|
||||
config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK)
|
||||
| ((displayInfo.flags & Display.FLAG_ROUND) != 0
|
||||
@@ -2287,7 +2278,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
mWmService.mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
|
||||
}
|
||||
|
||||
private int computeCompatSmallestWidth(boolean rotated, int uiMode, int dw, int dh) {
|
||||
private int computeCompatSmallestWidth(boolean rotated, int dw, int dh) {
|
||||
mTmpDisplayMetrics.setTo(mDisplayMetrics);
|
||||
final DisplayMetrics tmpDm = mTmpDisplayMetrics;
|
||||
final int unrotDw, unrotDh;
|
||||
@@ -2298,25 +2289,20 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
unrotDw = dw;
|
||||
unrotDh = dh;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
return sw;
|
||||
}
|
||||
|
||||
private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode,
|
||||
private int reduceCompatConfigWidthSize(int curSize, int rotation,
|
||||
DisplayMetrics dm, int dw, int dh) {
|
||||
final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(
|
||||
rotation).getDisplayCutout();
|
||||
dm.noncompatWidthPixels = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
dm.noncompatHeightPixels = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
|
||||
displayCutout);
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
final Rect nonDecorSize = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation,
|
||||
wmDisplayCutout);
|
||||
dm.noncompatWidthPixels = nonDecorSize.width();
|
||||
dm.noncompatHeightPixels = nonDecorSize.height();
|
||||
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
|
||||
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
|
||||
if (curSize == 0 || size < curSize) {
|
||||
@@ -2326,7 +2312,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
}
|
||||
|
||||
private void computeSizeRangesAndScreenLayout(DisplayInfo displayInfo, boolean rotated,
|
||||
int uiMode, int dw, int dh, float density, Configuration outConfig) {
|
||||
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
|
||||
@@ -2344,36 +2330,33 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
displayInfo.smallestNominalAppHeight = 1<<30;
|
||||
displayInfo.largestNominalAppWidth = 0;
|
||||
displayInfo.largestNominalAppHeight = 0;
|
||||
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);
|
||||
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);
|
||||
|
||||
if (outConfig == null) {
|
||||
return;
|
||||
}
|
||||
int sl = Configuration.resetScreenLayout(outConfig.screenLayout);
|
||||
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);
|
||||
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);
|
||||
outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density);
|
||||
outConfig.screenLayout = sl;
|
||||
}
|
||||
|
||||
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh,
|
||||
int uiMode) {
|
||||
private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh) {
|
||||
// Get the display cutout at this rotation.
|
||||
final DisplayCutout displayCutout = calculateDisplayCutoutForRotation(
|
||||
rotation).getDisplayCutout();
|
||||
final WmDisplayCutout wmDisplayCutout = calculateDisplayCutoutForRotation(rotation);
|
||||
|
||||
// Get the app screen size at this rotation.
|
||||
int w = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, displayCutout);
|
||||
int h = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation, displayCutout);
|
||||
final Rect size = mDisplayPolicy.getNonDecorDisplayFrame(dw, dh, rotation, wmDisplayCutout);
|
||||
|
||||
// Compute the screen layout size class for this rotation.
|
||||
int longSize = w;
|
||||
int shortSize = h;
|
||||
int longSize = size.width();
|
||||
int shortSize = size.height();
|
||||
if (longSize < shortSize) {
|
||||
int tmp = longSize;
|
||||
longSize = shortSize;
|
||||
@@ -2384,25 +2367,20 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
return Configuration.reduceScreenLayout(curLayout, longSize, shortSize);
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
if (width > displayInfo.largestNominalAppWidth) {
|
||||
displayInfo.largestNominalAppWidth = width;
|
||||
if (size.x > displayInfo.largestNominalAppWidth) {
|
||||
displayInfo.largestNominalAppWidth = size.x;
|
||||
}
|
||||
final int height = mDisplayPolicy.getConfigDisplayHeight(dw, dh, rotation, uiMode,
|
||||
displayCutout);
|
||||
if (height < displayInfo.smallestNominalAppHeight) {
|
||||
displayInfo.smallestNominalAppHeight = height;
|
||||
if (size.y < displayInfo.smallestNominalAppHeight) {
|
||||
displayInfo.smallestNominalAppHeight = size.y;
|
||||
}
|
||||
if (height > displayInfo.largestNominalAppHeight) {
|
||||
displayInfo.largestNominalAppHeight = height;
|
||||
if (size.y > displayInfo.largestNominalAppHeight) {
|
||||
displayInfo.largestNominalAppHeight = size.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ 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;
|
||||
@@ -125,6 +126,8 @@ 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;
|
||||
@@ -156,6 +159,7 @@ 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;
|
||||
@@ -1967,32 +1971,6 @@ 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];
|
||||
}
|
||||
if (position == NAV_BAR_LEFT) {
|
||||
if (lp.width > lp.providedInternalInsets.right) {
|
||||
return lp.width - lp.providedInternalInsets.right;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (position == NAV_BAR_RIGHT) {
|
||||
if (lp.width > lp.providedInternalInsets.left) {
|
||||
return lp.width - lp.providedInternalInsets.left;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return lp.width;
|
||||
}
|
||||
|
||||
void notifyDisplayReady() {
|
||||
mHandler.post(() -> {
|
||||
final int displayId = getDisplayId();
|
||||
@@ -2009,35 +1987,20 @@ public class DisplayPolicy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the display width available after excluding any screen
|
||||
* decorations that could never be removed in Honeycomb. That is, system bar or
|
||||
* button bar.
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getNavigationBarHeight(int rotation) {
|
||||
if (mNavigationBar == null) {
|
||||
return 0;
|
||||
}
|
||||
LayoutParams lp = mNavigationBar.getLayoutingAttrs(rotation);
|
||||
if (lp.height < lp.providedInternalInsets.top) {
|
||||
return 0;
|
||||
}
|
||||
return lp.height - lp.providedInternalInsets.top;
|
||||
Rect getNonDecorDisplayFrame(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout cutout) {
|
||||
final DisplayFrames displayFrames =
|
||||
getSimulatedDisplayFrames(rotation, fullWidth, fullHeight, cutout);
|
||||
final Rect nonDecorInsets =
|
||||
getInsets(displayFrames, Type.displayCutout() | Type.navigationBars()).toRect();
|
||||
final Rect displayFrame = new Rect(displayFrames.mInsetsState.getDisplayFrame());
|
||||
displayFrame.inset(nonDecorInsets);
|
||||
return displayFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2059,53 +2022,20 @@ public class DisplayPolicy {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the available screen width that we should report for the
|
||||
* Return the available screen size that we should report for the
|
||||
* configuration. This must be no larger than
|
||||
* {@link #getNonDecorDisplayWidth(int, int, int, int, DisplayCutout)}; it may be smaller
|
||||
* {@link #getNonDecorDisplayFrame(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;
|
||||
public Point getConfigDisplaySize(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout wmDisplayCutout) {
|
||||
final DisplayFrames displayFrames = getSimulatedDisplayFrames(rotation, fullWidth,
|
||||
fullHeight, wmDisplayCutout);
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2137,48 +2067,59 @@ 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, DisplayCutout displayCutout,
|
||||
Rect outInsets) {
|
||||
outInsets.setEmpty();
|
||||
|
||||
public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
|
||||
WmDisplayCutout displayCutout, Rect outInsets) {
|
||||
// Navigation bar and status bar.
|
||||
getNonDecorInsetsLw(displayRotation, displayCutout, outInsets);
|
||||
getNonDecorInsetsLw(displayRotation, displayWidth, displayHeight, 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 #getNonDecorDisplayWidth}.
|
||||
* @param displayRotation the current display rotation
|
||||
* @param displayCutout the current display cutout
|
||||
* 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
|
||||
* @param outInsets the insets to return
|
||||
*/
|
||||
public void getNonDecorInsetsLw(int displayRotation, DisplayCutout displayCutout,
|
||||
Rect outInsets) {
|
||||
outInsets.setEmpty();
|
||||
public void getNonDecorInsetsLw(int displayRotation, int fullWidth, int fullHeight,
|
||||
WmDisplayCutout cutout, Rect outInsets) {
|
||||
final DisplayFrames displayFrames =
|
||||
getSimulatedDisplayFrames(displayRotation, fullWidth, fullHeight, cutout);
|
||||
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);
|
||||
}
|
||||
}
|
||||
private 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;
|
||||
}
|
||||
|
||||
if (displayCutout != null) {
|
||||
outInsets.left += displayCutout.getSafeInsetLeft();
|
||||
outInsets.top += displayCutout.getSafeInsetTop();
|
||||
outInsets.right += displayCutout.getSafeInsetRight();
|
||||
outInsets.bottom += displayCutout.getSafeInsetBottom();
|
||||
}
|
||||
private Insets getInsets(DisplayFrames displayFrames, @InsetsType int type) {
|
||||
final InsetsState state = displayFrames.mInsetsState;
|
||||
final Rect displayFrame = new Rect(state.getDisplayFrame());
|
||||
final Insets insets = state.calculateInsets(displayFrame, type,
|
||||
true /* ignoreVisibility */);
|
||||
return insets;
|
||||
}
|
||||
|
||||
@NavigationBarPosition
|
||||
|
||||
@@ -2058,8 +2058,10 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
mTmpBounds.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
|
||||
|
||||
final DisplayPolicy policy = rootTask.mDisplayContent.getDisplayPolicy();
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation,
|
||||
displayInfo.displayCutout, mTmpInsets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth,
|
||||
displayInfo.logicalHeight,
|
||||
rootTask.mDisplayContent.calculateDisplayCutoutForRotation(displayInfo.rotation),
|
||||
mTmpInsets);
|
||||
intersectWithInsetsIfFits(outNonDecorBounds, mTmpBounds, mTmpInsets);
|
||||
|
||||
policy.convertNonDecorInsetsToStableInsets(mTmpInsets, displayInfo.rotation);
|
||||
|
||||
@@ -314,6 +314,7 @@ 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;
|
||||
|
||||
@@ -6247,9 +6248,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
+ " callers=" + Debug.getCallers(3));
|
||||
return NAV_BAR_INVALID;
|
||||
}
|
||||
displayContent.performLayout(false /* initial */,
|
||||
false /* updateInputWindows */);
|
||||
return displayContent.getDisplayPolicy().getNavBarPosition();
|
||||
return displayContent.getDisplayPolicy().navigationBarPosition(
|
||||
displayContent.getDisplayRotation().getRotation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7090,7 +7090,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
final DisplayContent dc = mRoot.getDisplayContent(displayId);
|
||||
if (dc != null) {
|
||||
final DisplayInfo di = dc.getDisplayInfo();
|
||||
dc.getDisplayPolicy().getStableInsetsLw(di.rotation, di.displayCutout, outInsets);
|
||||
final WmDisplayCutout cutout = dc.calculateDisplayCutoutForRotation(di.rotation);
|
||||
dc.getDisplayPolicy().getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, outInsets);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ 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;
|
||||
@@ -542,7 +543,8 @@ 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.displayCutout, insets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth,
|
||||
displayInfo.logicalHeight, WmDisplayCutout.NO_CUTOUT, insets);
|
||||
policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation);
|
||||
Task.intersectWithInsetsIfFits(stableRect, stableRect, insets);
|
||||
|
||||
@@ -583,7 +585,8 @@ 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.displayCutout, insets);
|
||||
policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth,
|
||||
displayInfo.logicalHeight, WmDisplayCutout.NO_CUTOUT, insets);
|
||||
policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation);
|
||||
Task.intersectWithInsetsIfFits(stableRect, stableRect, insets);
|
||||
|
||||
|
||||
@@ -25,10 +25,13 @@ 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;
|
||||
@@ -46,7 +49,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void portrait() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_0, false /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_0, false /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT);
|
||||
@@ -55,7 +59,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void portrait_withCutout() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_0, true /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> 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);
|
||||
@@ -64,7 +69,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void landscape() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_90, false /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_90, false /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0);
|
||||
@@ -79,7 +85,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void landscape_withCutout() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_90, true /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_90, true /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, DISPLAY_CUTOUT_HEIGHT, STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT, 0);
|
||||
@@ -94,7 +101,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void seascape() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_270, false /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_270, false /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, 0, 0);
|
||||
@@ -109,7 +117,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void seascape_withCutout() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_270, true /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_270, true /* withCutout */);
|
||||
|
||||
if (mDisplayPolicy.navigationBarCanMove()) {
|
||||
verifyStableInsets(di, NAV_BAR_HEIGHT, STATUS_BAR_HEIGHT, DISPLAY_CUTOUT_HEIGHT, 0);
|
||||
@@ -124,7 +133,8 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void upsideDown() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_180, false /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> di =
|
||||
displayInfoForRotation(ROTATION_180, false /* withCutout */);
|
||||
|
||||
verifyStableInsets(di, 0, STATUS_BAR_HEIGHT, 0, NAV_BAR_HEIGHT);
|
||||
verifyNonDecorInsets(di, 0, 0, 0, NAV_BAR_HEIGHT);
|
||||
@@ -133,28 +143,34 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
|
||||
@Test
|
||||
public void upsideDown_withCutout() {
|
||||
final DisplayInfo di = displayInfoForRotation(ROTATION_180, true /* withCutout */);
|
||||
final Pair<DisplayInfo, WmDisplayCutout> 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(DisplayInfo di, int left, int top, int right, int bottom) {
|
||||
mErrorCollector.checkThat("stableInsets", getStableInsetsLw(di), equalTo(new Rect(
|
||||
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(
|
||||
left, top, right, bottom)));
|
||||
}
|
||||
|
||||
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(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 verifyConsistency(String what, DisplayInfo di, Rect insets, int width,
|
||||
@@ -165,39 +181,42 @@ public class DisplayPolicyInsetsTests extends DisplayPolicyTestsBase {
|
||||
equalTo(di.logicalHeight - insets.top - insets.bottom));
|
||||
}
|
||||
|
||||
private Rect getStableInsetsLw(DisplayInfo di) {
|
||||
private Rect getStableInsetsLw(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
Rect result = new Rect();
|
||||
mDisplayPolicy.getStableInsetsLw(di.rotation, di.displayCutout, result);
|
||||
mDisplayPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Rect getNonDecorInsetsLw(DisplayInfo di) {
|
||||
private Rect getNonDecorInsetsLw(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
Rect result = new Rect();
|
||||
mDisplayPolicy.getNonDecorInsetsLw(di.rotation, di.displayCutout, result);
|
||||
mDisplayPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight,
|
||||
cutout, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getNonDecorDisplayWidth(DisplayInfo di) {
|
||||
return mDisplayPolicy.getNonDecorDisplayWidth(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, 0 /* ui */, di.displayCutout);
|
||||
private int getNonDecorDisplayWidth(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getNonDecorDisplayFrame(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).width();
|
||||
}
|
||||
|
||||
private int getNonDecorDisplayHeight(DisplayInfo di) {
|
||||
return mDisplayPolicy.getNonDecorDisplayHeight(di.logicalHeight, di.rotation,
|
||||
di.displayCutout);
|
||||
private int getNonDecorDisplayHeight(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getNonDecorDisplayFrame(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).height();
|
||||
}
|
||||
|
||||
private int getConfigDisplayWidth(DisplayInfo di) {
|
||||
return mDisplayPolicy.getConfigDisplayWidth(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, 0 /* ui */, di.displayCutout);
|
||||
private int getConfigDisplayWidth(DisplayInfo di, WmDisplayCutout cutout) {
|
||||
return mDisplayPolicy.getConfigDisplaySize(di.logicalWidth, di.logicalHeight,
|
||||
di.rotation, cutout).x;
|
||||
}
|
||||
|
||||
private int getConfigDisplayHeight(DisplayInfo di) {
|
||||
return mDisplayPolicy.getConfigDisplayHeight(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 static DisplayInfo displayInfoForRotation(int rotation, boolean withDisplayCutout) {
|
||||
return displayInfoAndCutoutForRotation(rotation, withDisplayCutout, false).first;
|
||||
private static Pair<DisplayInfo, WmDisplayCutout> displayInfoForRotation(int rotation,
|
||||
boolean withDisplayCutout) {
|
||||
return displayInfoAndCutoutForRotation(rotation, withDisplayCutout, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,6 @@ class TestDisplayContent extends DisplayContent {
|
||||
doReturn(true).when(newDisplay).supportsSystemDecorations();
|
||||
doReturn(true).when(displayPolicy).hasNavigationBar();
|
||||
doReturn(NAV_BAR_BOTTOM).when(displayPolicy).navigationBarPosition(anyInt());
|
||||
doReturn(20).when(displayPolicy).getNavigationBarHeight(anyInt());
|
||||
} else {
|
||||
doReturn(false).when(displayPolicy).hasNavigationBar();
|
||||
doReturn(false).when(displayPolicy).hasStatusBar();
|
||||
|
||||
Reference in New Issue
Block a user