Loading core/java/android/view/IWindowManager.aidl +0 −5 Original line number Diff line number Diff line Loading @@ -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). */ Loading core/java/android/view/InsetsState.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading core/java/android/view/WindowLayout.java +9 −9 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading services/core/java/com/android/server/wm/ActivityRecord.java +3 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading services/core/java/com/android/server/wm/DisplayContent.java +62 −82 Original line number Diff line number Diff line Loading @@ -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(); /** Loading Loading @@ -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. Loading Loading @@ -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); Loading @@ -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); Loading @@ -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, Loading Loading @@ -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; Loading @@ -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); } Loading @@ -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); Loading @@ -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 Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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 Loading @@ -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; Loading @@ -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; } } Loading Loading
core/java/android/view/IWindowManager.aidl +0 −5 Original line number Diff line number Diff line Loading @@ -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). */ Loading
core/java/android/view/InsetsState.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
core/java/android/view/WindowLayout.java +9 −9 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading
services/core/java/com/android/server/wm/ActivityRecord.java +3 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading
services/core/java/com/android/server/wm/DisplayContent.java +62 −82 Original line number Diff line number Diff line Loading @@ -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(); /** Loading Loading @@ -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. Loading Loading @@ -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); Loading @@ -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); Loading @@ -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, Loading Loading @@ -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; Loading @@ -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); } Loading @@ -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); Loading @@ -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 Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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 Loading @@ -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; Loading @@ -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; } } Loading