Merge "Refine the way of calculating insets for configuration (1/3)" into tm-qpr-dev
This commit is contained in:
@@ -412,11 +412,6 @@ interface IWindowManager
|
||||
@UnsupportedAppUsage
|
||||
boolean hasNavigationBar(int displayId);
|
||||
|
||||
/**
|
||||
* Get the position of the nav bar
|
||||
*/
|
||||
int getNavBarPosition(int displayId);
|
||||
|
||||
/**
|
||||
* Lock the device immediately with the specified options (can be null).
|
||||
*/
|
||||
|
||||
@@ -349,6 +349,20 @@ public class InsetsState implements Parcelable {
|
||||
return insets;
|
||||
}
|
||||
|
||||
// TODO: Remove this once the task bar is treated as navigation bar.
|
||||
public Insets calculateInsetsWithInternalTypes(Rect frame, @InternalInsetsType int[] types,
|
||||
boolean ignoreVisibility) {
|
||||
Insets insets = Insets.NONE;
|
||||
for (int i = types.length - 1; i >= 0; i--) {
|
||||
InsetsSource source = mSources[types[i]];
|
||||
if (source == null) {
|
||||
continue;
|
||||
}
|
||||
insets = Insets.max(source.calculateInsets(frame, ignoreVisibility), insets);
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
|
||||
public Insets calculateInsets(Rect frame, @InsetsType int types,
|
||||
InsetsVisibilities overrideVisibilities) {
|
||||
Insets insets = Insets.NONE;
|
||||
|
||||
@@ -118,11 +118,11 @@ public class WindowLayout {
|
||||
}
|
||||
if (cutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) {
|
||||
if (displayFrame.width() < displayFrame.height()) {
|
||||
displayCutoutSafeExceptMaybeBars.top = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.top = MIN_Y;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
} else {
|
||||
displayCutoutSafeExceptMaybeBars.left = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.right = Integer.MAX_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.left = MIN_X;
|
||||
displayCutoutSafeExceptMaybeBars.right = MAX_X;
|
||||
}
|
||||
}
|
||||
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 = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.left = MIN_X;
|
||||
}
|
||||
if (systemBarsInsets.top > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.top = Integer.MIN_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.top = MIN_Y;
|
||||
}
|
||||
if (systemBarsInsets.right > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.right = Integer.MAX_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.right = MAX_X;
|
||||
}
|
||||
if (systemBarsInsets.bottom > 0) {
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
}
|
||||
}
|
||||
if (type == TYPE_INPUT_METHOD) {
|
||||
final InsetsSource navSource = state.peekSource(ITYPE_NAVIGATION_BAR);
|
||||
if (navSource != null && navSource.calculateInsets(displayFrame, true).bottom > 0) {
|
||||
// The IME can always extend under the bottom cutout if the navbar is there.
|
||||
displayCutoutSafeExceptMaybeBars.bottom = Integer.MAX_VALUE;
|
||||
displayCutoutSafeExceptMaybeBars.bottom = MAX_Y;
|
||||
}
|
||||
}
|
||||
final boolean attachedInParent = attachedWindowFrame != null && !layoutInScreen;
|
||||
|
||||
@@ -313,7 +313,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;
|
||||
@@ -357,6 +356,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;
|
||||
|
||||
@@ -9694,9 +9694,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);
|
||||
|
||||
|
||||
@@ -438,7 +438,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();
|
||||
|
||||
/**
|
||||
@@ -2014,7 +2014,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.
|
||||
@@ -2064,7 +2064,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);
|
||||
@@ -2076,18 +2076,16 @@ 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.physicalXDpi = mBaseDisplayPhysicalXDpi;
|
||||
mDisplayInfo.physicalYDpi = mBaseDisplayPhysicalYDpi;
|
||||
mDisplayInfo.appWidth = appWidth;
|
||||
mDisplayInfo.appHeight = appHeight;
|
||||
mDisplayInfo.appWidth = appFrame.width();
|
||||
mDisplayInfo.appHeight = appFrame.height();
|
||||
if (isDefaultDisplay) {
|
||||
mDisplayInfo.getLogicalMetrics(mRealDisplayMetrics,
|
||||
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
|
||||
@@ -2101,7 +2099,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,
|
||||
@@ -2191,10 +2189,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;
|
||||
@@ -2203,38 +2199,35 @@ 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 DisplayFrames displayFrames =
|
||||
mDisplayPolicy.getSimulatedDisplayFrames(rotation, dw, dh, wmDisplayCutout);
|
||||
final Rect appFrame =
|
||||
mDisplayPolicy.getNonDecorDisplayFrameWithSimulatedFrame(displayFrames);
|
||||
// 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 + 0.5f);
|
||||
outConfig.screenHeightDp = (int) (mDisplayPolicy.getConfigDisplayHeight(dw, dh, rotation,
|
||||
uiMode, displayCutout) / density + 0.5f);
|
||||
final Point configSize =
|
||||
mDisplayPolicy.getConfigDisplaySizeWithSimulatedFrame(displayFrames);
|
||||
outConfig.screenWidthDp = (int) (configSize.x / density + 0.5f);
|
||||
outConfig.screenHeightDp = (int) (configSize.y / 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, uiMode, dw, dh);
|
||||
outConfig.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dw, dh);
|
||||
outConfig.windowConfiguration.setDisplayRotation(rotation);
|
||||
}
|
||||
|
||||
@@ -2243,7 +2236,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);
|
||||
@@ -2252,8 +2245,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
|
||||
@@ -2342,7 +2335,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;
|
||||
@@ -2353,25 +2346,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) {
|
||||
@@ -2381,7 +2369,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
|
||||
@@ -2399,37 +2387,34 @@ 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 + 0.5f);
|
||||
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;
|
||||
@@ -2440,25 +2425,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,19 @@ package com.android.server.wm;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
|
||||
import static android.view.Display.TYPE_INTERNAL;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
||||
import static android.view.InsetsState.ITYPE_CAPTION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_CLIMATE_BAR;
|
||||
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_LEFT_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_LEFT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_RIGHT_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_RIGHT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.ITYPE_TOP_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_TOP_MANDATORY_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_TOP_TAPPABLE_ELEMENT;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
||||
@@ -103,6 +107,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;
|
||||
@@ -127,6 +132,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;
|
||||
@@ -136,7 +143,6 @@ import android.view.WindowLayout;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.view.WindowManagerPolicyConstants;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.window.ClientWindowFrames;
|
||||
|
||||
@@ -160,6 +166,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;
|
||||
@@ -383,6 +390,16 @@ public class DisplayPolicy {
|
||||
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
|
||||
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
|
||||
|
||||
// TODO (b/235842600): Use public type once we can treat task bar as navigation bar.
|
||||
private static final int[] STABLE_TYPES = new int[]{
|
||||
ITYPE_TOP_DISPLAY_CUTOUT, ITYPE_RIGHT_DISPLAY_CUTOUT, ITYPE_BOTTOM_DISPLAY_CUTOUT,
|
||||
ITYPE_LEFT_DISPLAY_CUTOUT, ITYPE_NAVIGATION_BAR, ITYPE_STATUS_BAR, ITYPE_CLIMATE_BAR
|
||||
};
|
||||
private static final int[] NON_DECOR_TYPES = new int[]{
|
||||
ITYPE_TOP_DISPLAY_CUTOUT, ITYPE_RIGHT_DISPLAY_CUTOUT, ITYPE_BOTTOM_DISPLAY_CUTOUT,
|
||||
ITYPE_LEFT_DISPLAY_CUTOUT, ITYPE_NAVIGATION_BAR
|
||||
};
|
||||
|
||||
private final GestureNavigationSettingsObserver mGestureNavigationSettingsObserver;
|
||||
|
||||
private final WindowManagerInternal.AppTransitionListener mAppTransitionListener;
|
||||
@@ -2007,35 +2024,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];
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setCanSystemBarsBeShownByUser(boolean canBeShown) {
|
||||
mCanSystemBarsBeShownByUser = canBeShown;
|
||||
@@ -2057,45 +2045,24 @@ 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;
|
||||
Rect getNonDecorDisplayFrame(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout cutout) {
|
||||
final DisplayFrames displayFrames =
|
||||
getSimulatedDisplayFrames(rotation, fullWidth, fullHeight, cutout);
|
||||
return getNonDecorDisplayFrameWithSimulatedFrame(displayFrames);
|
||||
}
|
||||
|
||||
@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;
|
||||
Rect getNonDecorDisplayFrameWithSimulatedFrame(DisplayFrames displayFrames) {
|
||||
final Rect nonDecorInsets =
|
||||
getInsetsWithInternalTypes(displayFrames, NON_DECOR_TYPES).toRect();
|
||||
final Rect displayFrame = new Rect(displayFrames.mInsetsState.getDisplayFrame());
|
||||
displayFrame.inset(nonDecorInsets);
|
||||
return displayFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2117,53 +2084,23 @@ 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);
|
||||
public Point getConfigDisplaySize(int fullWidth, int fullHeight, int rotation,
|
||||
WmDisplayCutout wmDisplayCutout) {
|
||||
final DisplayFrames displayFrames = getSimulatedDisplayFrames(rotation, fullWidth,
|
||||
fullHeight, wmDisplayCutout);
|
||||
return getConfigDisplaySizeWithSimulatedFrame(displayFrames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
Point getConfigDisplaySizeWithSimulatedFrame(DisplayFrames displayFrames) {
|
||||
final Insets insets = getInsetsWithInternalTypes(displayFrames, STABLE_TYPES);
|
||||
Rect configFrame = new Rect(displayFrames.mInsetsState.getDisplayFrame());
|
||||
configFrame.inset(insets);
|
||||
return new Point(configFrame.width(), configFrame.height());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2195,48 +2132,75 @@ 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) {
|
||||
final DisplayFrames displayFrames = getSimulatedDisplayFrames(displayRotation,
|
||||
displayWidth, displayHeight, displayCutout);
|
||||
getStableInsetsWithSimulatedFrame(displayFrames, outInsets);
|
||||
}
|
||||
|
||||
// Navigation bar and status bar.
|
||||
getNonDecorInsetsLw(displayRotation, displayCutout, outInsets);
|
||||
convertNonDecorInsetsToStableInsets(outInsets, displayRotation);
|
||||
void getStableInsetsWithSimulatedFrame(DisplayFrames displayFrames, Rect outInsets) {
|
||||
// Navigation bar, status bar, and cutout.
|
||||
outInsets.set(getInsetsWithInternalTypes(displayFrames, STABLE_TYPES).toRect());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
getNonDecorInsetsWithSimulatedFrame(displayFrames, outInsets);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
void getNonDecorInsetsWithSimulatedFrame(DisplayFrames displayFrames, Rect outInsets) {
|
||||
outInsets.set(getInsetsWithInternalTypes(displayFrames, NON_DECOR_TYPES).toRect());
|
||||
}
|
||||
|
||||
if (displayCutout != null) {
|
||||
outInsets.left += displayCutout.getSafeInsetLeft();
|
||||
outInsets.top += displayCutout.getSafeInsetTop();
|
||||
outInsets.right += displayCutout.getSafeInsetRight();
|
||||
outInsets.bottom += displayCutout.getSafeInsetBottom();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Insets getInsetsWithInternalTypes(DisplayFrames displayFrames,
|
||||
@InternalInsetsType int[] types) {
|
||||
final InsetsState state = displayFrames.mInsetsState;
|
||||
final Insets insets = state.calculateInsetsWithInternalTypes(state.getDisplayFrame(), types,
|
||||
true /* ignoreVisibility */);
|
||||
return insets;
|
||||
}
|
||||
|
||||
@NavigationBarPosition
|
||||
@@ -2255,17 +2219,6 @@ public class DisplayPolicy {
|
||||
return NAV_BAR_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The side of the screen where navigation bar is positioned.
|
||||
* @see WindowManagerPolicyConstants#NAV_BAR_LEFT
|
||||
* @see WindowManagerPolicyConstants#NAV_BAR_RIGHT
|
||||
* @see WindowManagerPolicyConstants#NAV_BAR_BOTTOM
|
||||
*/
|
||||
@NavigationBarPosition
|
||||
public int getNavBarPosition() {
|
||||
return mNavigationBarPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* A new window has been focused.
|
||||
*/
|
||||
|
||||
@@ -98,6 +98,7 @@ 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;
|
||||
@@ -2208,11 +2209,13 @@ 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);
|
||||
final WmDisplayCutout cutout =
|
||||
rootTask.mDisplayContent.calculateDisplayCutoutForRotation(displayInfo.rotation);
|
||||
final DisplayFrames displayFrames = policy.getSimulatedDisplayFrames(displayInfo.rotation,
|
||||
displayInfo.logicalWidth, displayInfo.logicalHeight, cutout);
|
||||
policy.getNonDecorInsetsWithSimulatedFrame(displayFrames, mTmpInsets);
|
||||
intersectWithInsetsIfFits(outNonDecorBounds, mTmpBounds, mTmpInsets);
|
||||
|
||||
policy.convertNonDecorInsetsToStableInsets(mTmpInsets, displayInfo.rotation);
|
||||
policy.getStableInsetsWithSimulatedFrame(displayFrames, mTmpInsets);
|
||||
intersectWithInsetsIfFits(outStableBounds, mTmpBounds, mTmpInsets);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ import static android.view.WindowManager.fixScale;
|
||||
import static android.view.WindowManagerGlobal.ADD_OKAY;
|
||||
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW;
|
||||
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
|
||||
import static android.view.WindowManagerPolicyConstants.TYPE_LAYER_MULTIPLIER;
|
||||
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_MISSING_WINDOW;
|
||||
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN;
|
||||
@@ -322,6 +321,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;
|
||||
|
||||
@@ -1870,7 +1870,8 @@ 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()) {
|
||||
if ((win.isVisibleRequestedOrAdding() && displayContent.updateOrientation())
|
||||
|| win.providesNonDecorInsets()) {
|
||||
displayContent.sendNewConfiguration();
|
||||
}
|
||||
|
||||
@@ -6383,27 +6384,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by ActivityManager to determine where to position an app with aspect ratio shorter then
|
||||
* the screen is.
|
||||
* @see DisplayPolicy#getNavBarPosition()
|
||||
*/
|
||||
@Override
|
||||
@WindowManagerPolicy.NavigationBarPosition
|
||||
public int getNavBarPosition(int displayId) {
|
||||
synchronized (mGlobalLock) {
|
||||
// Perform layout if it was scheduled before to make sure that we get correct nav bar
|
||||
// position when doing rotations.
|
||||
final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
|
||||
if (displayContent == null) {
|
||||
Slog.w(TAG, "getNavBarPosition with invalid displayId=" + displayId
|
||||
+ " callers=" + Debug.getCallers(3));
|
||||
return NAV_BAR_INVALID;
|
||||
}
|
||||
return displayContent.getDisplayPolicy().getNavBarPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createInputConsumer(IBinder token, String name, int displayId,
|
||||
InputChannel inputChannel) {
|
||||
@@ -7242,7 +7222,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@ 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;
|
||||
@@ -1897,6 +1898,19 @@ 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();
|
||||
@@ -2609,14 +2623,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
removeImmediately();
|
||||
// Removing a visible window will effect the computed orientation
|
||||
// So just update orientation if needed.
|
||||
boolean sentNewConfig = false;
|
||||
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,
|
||||
|
||||
@@ -158,6 +158,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;
|
||||
@@ -551,7 +552,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);
|
||||
|
||||
@@ -592,7 +594,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@ package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_CLIMATE_BAR;
|
||||
import static android.view.InsetsState.ITYPE_LEFT_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_RIGHT_DISPLAY_CUTOUT;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.ITYPE_TOP_DISPLAY_CUTOUT;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
|
||||
@@ -26,12 +33,9 @@ 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;
|
||||
@@ -43,6 +47,7 @@ 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;
|
||||
|
||||
@@ -204,7 +209,26 @@ 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());
|
||||
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()));
|
||||
final int[] nonDecorTypes = new int[]{
|
||||
ITYPE_TOP_DISPLAY_CUTOUT, ITYPE_RIGHT_DISPLAY_CUTOUT,
|
||||
ITYPE_BOTTOM_DISPLAY_CUTOUT, ITYPE_LEFT_DISPLAY_CUTOUT, ITYPE_NAVIGATION_BAR
|
||||
};
|
||||
doReturn(Insets.of(0, 0, 0, 20)).when(displayPolicy).getInsetsWithInternalTypes(
|
||||
any(),
|
||||
eq(nonDecorTypes));
|
||||
final int[] stableTypes = new int[]{
|
||||
ITYPE_TOP_DISPLAY_CUTOUT, ITYPE_RIGHT_DISPLAY_CUTOUT,
|
||||
ITYPE_BOTTOM_DISPLAY_CUTOUT, ITYPE_LEFT_DISPLAY_CUTOUT,
|
||||
ITYPE_NAVIGATION_BAR, ITYPE_STATUS_BAR, ITYPE_CLIMATE_BAR
|
||||
};
|
||||
doReturn(Insets.of(0, 20, 0, 20)).when(displayPolicy).getInsetsWithInternalTypes(
|
||||
any(),
|
||||
eq(stableTypes));
|
||||
} else {
|
||||
doReturn(false).when(displayPolicy).hasNavigationBar();
|
||||
doReturn(false).when(displayPolicy).hasStatusBar();
|
||||
|
||||
@@ -323,6 +323,10 @@ 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);
|
||||
@@ -379,6 +383,9 @@ 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