Loading core/res/res/values/config.xml +25 −7 Original line number Diff line number Diff line Loading @@ -5133,16 +5133,24 @@ --> <color name="config_letterboxBackgroundColor">@android:color/system_neutral2_900</color> <!-- Horizonal position of a center of the letterboxed app window. <!-- Horizontal position of a center of the letterboxed app window. 0 corresponds to the left side of the screen and 1 to the right side. If given value < 0 or > 1, it is ignored and central position is used (0.5). --> <item name="config_letterboxHorizontalPositionMultiplier" format="float" type="dimen">0.5</item> <!-- Whether reachability repositioning is allowed for letterboxed fullscreen apps in landscape device orientation. --> <bool name="config_letterboxIsReachabilityEnabled">false</bool> <!-- Vertical position of a center of the letterboxed app window. 0 corresponds to the upper side of the screen and 1 to the lower side. If given value < 0 or > 1, it is ignored and central position is used (0.5). --> <item name="config_letterboxVerticalPositionMultiplier" format="float" type="dimen">0.5</item> <!-- Whether horizontal reachability repositioning is allowed for letterboxed fullscreen apps. --> <bool name="config_letterboxIsHorizontalReachabilityEnabled">false</bool> <!-- Whether vertical reachability repositioning is allowed for letterboxed fullscreen apps. --> <bool name="config_letterboxIsVerticalReachabilityEnabled">false</bool> <!-- Default horizonal position of the letterboxed app window when reachability is <!-- Default horizontal position of the letterboxed app window when reachability is enabled and an app is fullscreen in landscape device orientation. When reachability is enabled, the position can change between left, center and right. This config defines the default one: Loading @@ -5150,7 +5158,17 @@ - Option 1 - Center. - Option 2 - Right. If given value is outside of this range, the option 1 (center) is assummed. --> <integer name="config_letterboxDefaultPositionForReachability">1</integer> <integer name="config_letterboxDefaultPositionForHorizontalReachability">1</integer> <!-- Default vertical position of the letterboxed app window when reachability is enabled and an app is fullscreen in portrait device orientation. When reachability is enabled, the position can change between top, center and bottom. This config defines the default one: - Option 0 - Top. - Option 1 - Center. - Option 2 - Bottom. If given value is outside of this range, the option 1 (center) is assummed. --> <integer name="config_letterboxDefaultPositionForVerticalReachability">1</integer> <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <bool name="config_letterboxIsEducationEnabled">false</bool> Loading core/res/res/values/symbols.xml +5 −2 Original line number Diff line number Diff line Loading @@ -4384,8 +4384,11 @@ <java-symbol type="integer" name="config_letterboxBackgroundType" /> <java-symbol type="color" name="config_letterboxBackgroundColor" /> <java-symbol type="dimen" name="config_letterboxHorizontalPositionMultiplier" /> <java-symbol type="bool" name="config_letterboxIsReachabilityEnabled" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForReachability" /> <java-symbol type="dimen" name="config_letterboxVerticalPositionMultiplier" /> <java-symbol type="bool" name="config_letterboxIsHorizontalReachabilityEnabled" /> <java-symbol type="bool" name="config_letterboxIsVerticalReachabilityEnabled" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForHorizontalReachability" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" /> <java-symbol type="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> Loading services/core/java/com/android/server/wm/ActivityRecord.java +50 −48 Original line number Diff line number Diff line Loading @@ -7728,7 +7728,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (isFixedOrientationLetterboxAllowed || mCompatDisplayInsets != null // In fullscreen, can be letterboxed for aspect ratio. || !inMultiWindowMode()) { updateResolvedBoundsHorizontalPosition(newParentConfiguration); updateResolvedBoundsPosition(newParentConfiguration); } if (mVisibleRequested) { Loading Loading @@ -7831,39 +7831,61 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } /** * Adjusts horizontal position of resolved bounds if they doesn't fill the parent using gravity * Adjusts position of resolved bounds if they doesn't fill the parent using gravity * requested in the config or via an ADB command. For more context see {@link * LetterboxUiController#getHorizontalPositionMultiplier(Configuration)}. * LetterboxUiController#getHorizontalPositionMultiplier(Configuration)} and * {@link LetterboxUiController#getVerticalPositionMultiplier(Configuration)} */ private void updateResolvedBoundsHorizontalPosition(Configuration newParentConfiguration) { private void updateResolvedBoundsPosition(Configuration newParentConfiguration) { final Configuration resolvedConfig = getResolvedOverrideConfiguration(); final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds(); final Rect screenResolvedBounds = mSizeCompatBounds != null ? mSizeCompatBounds : resolvedBounds; final Rect parentAppBounds = newParentConfiguration.windowConfiguration.getAppBounds(); final Rect parentBounds = newParentConfiguration.windowConfiguration.getBounds(); if (resolvedBounds.isEmpty() || parentBounds.width() == screenResolvedBounds.width()) { if (resolvedBounds.isEmpty()) { return; } // Horizontal position int offsetX = 0; if (parentBounds.width() != screenResolvedBounds.width()) { if (screenResolvedBounds.width() >= parentAppBounds.width()) { // If resolved bounds overlap with insets, center within app bounds. offsetX = getHorizontalCenterOffset( offsetX = getCenterOffset( parentAppBounds.width(), screenResolvedBounds.width()); } else { float positionMultiplier = mLetterboxUiController.getHorizontalPositionMultiplier(newParentConfiguration); mLetterboxUiController.getHorizontalPositionMultiplier( newParentConfiguration); offsetX = (int) Math.ceil((parentAppBounds.width() - screenResolvedBounds.width()) * positionMultiplier); } } // Vertical position int offsetY = 0; if (parentBounds.height() != screenResolvedBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { // If resolved bounds overlap with insets, center within app bounds. offsetY = getCenterOffset( parentAppBounds.height(), screenResolvedBounds.height()); } else { float positionMultiplier = mLetterboxUiController.getVerticalPositionMultiplier( newParentConfiguration); offsetY = (int) Math.ceil((parentAppBounds.height() - screenResolvedBounds.height()) * positionMultiplier); } } if (mSizeCompatBounds != null) { mSizeCompatBounds.offset(offsetX, 0 /* offsetY */); mSizeCompatBounds.offset(offsetX , offsetY); final int dy = mSizeCompatBounds.top - resolvedBounds.top; final int dx = mSizeCompatBounds.left - resolvedBounds.left; offsetBounds(resolvedConfig, dx, 0 /* offsetY */); offsetBounds(resolvedConfig, dx, dy); } else { offsetBounds(resolvedConfig, offsetX, 0 /* offsetY */); offsetBounds(resolvedConfig, offsetX, offsetY); } // Since bounds has changed, the configuration needs to be computed accordingly. Loading Loading @@ -8078,14 +8100,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mIsAspectRatioApplied = applyAspectRatio(resolvedBounds, containingBoundsWithInsets, containingBounds, desiredAspectRatio, true); // Vertically center if orientation is landscape. Center within parent bounds with insets // to ensure that insets do not trim height. Bounds will later be horizontally centered in // {@link updateResolvedBoundsHorizontalPosition()} regardless of orientation. if (forcedOrientation == ORIENTATION_LANDSCAPE) { final int offsetY = parentBoundsWithInsets.centerY() - resolvedBounds.centerY(); resolvedBounds.offset(0, offsetY); } if (mCompatDisplayInsets != null) { mCompatDisplayInsets.getBoundsByRotation( mTmpBounds, newParentConfig.windowConfiguration.getRotation()); Loading @@ -8108,10 +8122,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** * Resolves aspect ratio restrictions for an activity. If the bounds are restricted by * aspect ratio, the position will be adjusted later in {@link * updateResolvedBoundsHorizontalPosition} within parent's app bounds to balance the visual * appearance. The policy of aspect ratio has higher priority than the requested override * bounds. * aspect ratio, the position will be adjusted later in {@link #updateResolvedBoundsPosition * within parent's app bounds to balance the visual appearance. The policy of aspect ratio has * higher priority than the requested override bounds. */ private void resolveAspectRatioRestriction(Configuration newParentConfiguration) { final Configuration resolvedConfig = getResolvedOverrideConfiguration(); Loading @@ -8123,7 +8136,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mTmpBounds.setEmpty(); mIsAspectRatioApplied = applyAspectRatio(mTmpBounds, parentAppBounds, parentBounds); // If the out bounds is not empty, it means the activity cannot fill parent's app bounds, // then they should be aligned later in #updateResolvedBoundsHorizontalPosition(). // then they should be aligned later in #updateResolvedBoundsPosition() if (!mTmpBounds.isEmpty()) { resolvedBounds.set(mTmpBounds); } Loading Loading @@ -8257,22 +8270,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Vertically center within parent (bounds) - this is a UX choice and exclude the horizontal // decor if needed. Horizontal position is adjusted in // updateResolvedBoundsHorizontalPosition. // The position will be later adjusted in updateResolvedBoundsPosition. // Above coordinates are in "@" space, now place "*" and "#" to screen space. final boolean fillContainer = resolvedBounds.equals(containingBounds); final int screenPosX = fillContainer ? containerBounds.left : containerAppBounds.left; // If the activity is not in size compat mode, calculate vertical centering // from the container and resolved bounds. // If the activity is in size compat mode, calculate vertical centering // from the container and size compat bounds. // The container bounds contain the parent bounds offset in the display, for // example when an activity is in the lower split of split screen. final int screenPosY = (mSizeCompatBounds == null ? (containerBounds.height() - resolvedBounds.height()) / 2 : (containerBounds.height() - mSizeCompatBounds.height()) / 2) + containerBounds.top; final int screenPosY = fillContainer ? containerBounds.top : containerAppBounds.top; if (screenPosX != 0 || screenPosY != 0) { if (mSizeCompatBounds != null) { Loading Loading @@ -8332,9 +8334,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return true; } /** @return The horizontal offset of putting the content in the center of viewport. */ private static int getHorizontalCenterOffset(int viewportW, int contentW) { return (int) ((viewportW - contentW + 1) * 0.5f); /** @return The horizontal / vertical offset of putting the content in the center of viewport.*/ private static int getCenterOffset(int viewportDim, int contentDim) { return (int) ((viewportDim - contentDim + 1) * 0.5f); } private static void offsetBounds(Configuration inOutConfig, int offsetX, int offsetY) { Loading Loading @@ -9597,7 +9599,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A outBounds.bottom = dH; outBounds.right = (int) ((float) dH * dH / dW); } outBounds.offset(getHorizontalCenterOffset(mWidth, outBounds.width()), 0 /* dy */); outBounds.offset(getCenterOffset(mWidth, outBounds.width()), 0 /* dy */); } outAppBounds.set(outBounds); Loading services/core/java/com/android/server/wm/Letterbox.java +8 −4 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ public class Letterbox { private final LetterboxSurface mFullWindowSurface = new LetterboxSurface("fullWindow"); private final LetterboxSurface[] mSurfaces = { mLeft, mTop, mRight, mBottom }; // Reachability gestures. private final IntConsumer mDoubleTapCallback; private final IntConsumer mDoubleTapCallbackX; private final IntConsumer mDoubleTapCallbackY; /** * Constructs a Letterbox. Loading @@ -86,7 +87,8 @@ public class Letterbox { Supplier<Boolean> hasWallpaperBackgroundSupplier, Supplier<Integer> blurRadiusSupplier, Supplier<Float> darkScrimAlphaSupplier, IntConsumer doubleTapCallback) { IntConsumer doubleTapCallbackX, IntConsumer doubleTapCallbackY) { mSurfaceControlFactory = surfaceControlFactory; mTransactionFactory = transactionFactory; mAreCornersRounded = areCornersRounded; Loading @@ -94,7 +96,8 @@ public class Letterbox { mHasWallpaperBackgroundSupplier = hasWallpaperBackgroundSupplier; mBlurRadiusSupplier = blurRadiusSupplier; mDarkScrimAlphaSupplier = darkScrimAlphaSupplier; mDoubleTapCallback = doubleTapCallback; mDoubleTapCallbackX = doubleTapCallbackX; mDoubleTapCallbackY = doubleTapCallbackY; } /** Loading Loading @@ -264,7 +267,8 @@ public class Letterbox { @Override public boolean onDoubleTapEvent(MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_UP) { mDoubleTapCallback.accept((int) e.getX()); mDoubleTapCallbackX.accept((int) e.getX()); mDoubleTapCallbackY.accept((int) e.getY()); return true; } return false; Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +294 −77 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/res/res/values/config.xml +25 −7 Original line number Diff line number Diff line Loading @@ -5133,16 +5133,24 @@ --> <color name="config_letterboxBackgroundColor">@android:color/system_neutral2_900</color> <!-- Horizonal position of a center of the letterboxed app window. <!-- Horizontal position of a center of the letterboxed app window. 0 corresponds to the left side of the screen and 1 to the right side. If given value < 0 or > 1, it is ignored and central position is used (0.5). --> <item name="config_letterboxHorizontalPositionMultiplier" format="float" type="dimen">0.5</item> <!-- Whether reachability repositioning is allowed for letterboxed fullscreen apps in landscape device orientation. --> <bool name="config_letterboxIsReachabilityEnabled">false</bool> <!-- Vertical position of a center of the letterboxed app window. 0 corresponds to the upper side of the screen and 1 to the lower side. If given value < 0 or > 1, it is ignored and central position is used (0.5). --> <item name="config_letterboxVerticalPositionMultiplier" format="float" type="dimen">0.5</item> <!-- Whether horizontal reachability repositioning is allowed for letterboxed fullscreen apps. --> <bool name="config_letterboxIsHorizontalReachabilityEnabled">false</bool> <!-- Whether vertical reachability repositioning is allowed for letterboxed fullscreen apps. --> <bool name="config_letterboxIsVerticalReachabilityEnabled">false</bool> <!-- Default horizonal position of the letterboxed app window when reachability is <!-- Default horizontal position of the letterboxed app window when reachability is enabled and an app is fullscreen in landscape device orientation. When reachability is enabled, the position can change between left, center and right. This config defines the default one: Loading @@ -5150,7 +5158,17 @@ - Option 1 - Center. - Option 2 - Right. If given value is outside of this range, the option 1 (center) is assummed. --> <integer name="config_letterboxDefaultPositionForReachability">1</integer> <integer name="config_letterboxDefaultPositionForHorizontalReachability">1</integer> <!-- Default vertical position of the letterboxed app window when reachability is enabled and an app is fullscreen in portrait device orientation. When reachability is enabled, the position can change between top, center and bottom. This config defines the default one: - Option 0 - Top. - Option 1 - Center. - Option 2 - Bottom. If given value is outside of this range, the option 1 (center) is assummed. --> <integer name="config_letterboxDefaultPositionForVerticalReachability">1</integer> <!-- Whether displaying letterbox education is enabled for letterboxed fullscreen apps. --> <bool name="config_letterboxIsEducationEnabled">false</bool> Loading
core/res/res/values/symbols.xml +5 −2 Original line number Diff line number Diff line Loading @@ -4384,8 +4384,11 @@ <java-symbol type="integer" name="config_letterboxBackgroundType" /> <java-symbol type="color" name="config_letterboxBackgroundColor" /> <java-symbol type="dimen" name="config_letterboxHorizontalPositionMultiplier" /> <java-symbol type="bool" name="config_letterboxIsReachabilityEnabled" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForReachability" /> <java-symbol type="dimen" name="config_letterboxVerticalPositionMultiplier" /> <java-symbol type="bool" name="config_letterboxIsHorizontalReachabilityEnabled" /> <java-symbol type="bool" name="config_letterboxIsVerticalReachabilityEnabled" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForHorizontalReachability" /> <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" /> <java-symbol type="bool" name="config_letterboxIsEducationEnabled" /> <java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" /> Loading
services/core/java/com/android/server/wm/ActivityRecord.java +50 −48 Original line number Diff line number Diff line Loading @@ -7728,7 +7728,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (isFixedOrientationLetterboxAllowed || mCompatDisplayInsets != null // In fullscreen, can be letterboxed for aspect ratio. || !inMultiWindowMode()) { updateResolvedBoundsHorizontalPosition(newParentConfiguration); updateResolvedBoundsPosition(newParentConfiguration); } if (mVisibleRequested) { Loading Loading @@ -7831,39 +7831,61 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } /** * Adjusts horizontal position of resolved bounds if they doesn't fill the parent using gravity * Adjusts position of resolved bounds if they doesn't fill the parent using gravity * requested in the config or via an ADB command. For more context see {@link * LetterboxUiController#getHorizontalPositionMultiplier(Configuration)}. * LetterboxUiController#getHorizontalPositionMultiplier(Configuration)} and * {@link LetterboxUiController#getVerticalPositionMultiplier(Configuration)} */ private void updateResolvedBoundsHorizontalPosition(Configuration newParentConfiguration) { private void updateResolvedBoundsPosition(Configuration newParentConfiguration) { final Configuration resolvedConfig = getResolvedOverrideConfiguration(); final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds(); final Rect screenResolvedBounds = mSizeCompatBounds != null ? mSizeCompatBounds : resolvedBounds; final Rect parentAppBounds = newParentConfiguration.windowConfiguration.getAppBounds(); final Rect parentBounds = newParentConfiguration.windowConfiguration.getBounds(); if (resolvedBounds.isEmpty() || parentBounds.width() == screenResolvedBounds.width()) { if (resolvedBounds.isEmpty()) { return; } // Horizontal position int offsetX = 0; if (parentBounds.width() != screenResolvedBounds.width()) { if (screenResolvedBounds.width() >= parentAppBounds.width()) { // If resolved bounds overlap with insets, center within app bounds. offsetX = getHorizontalCenterOffset( offsetX = getCenterOffset( parentAppBounds.width(), screenResolvedBounds.width()); } else { float positionMultiplier = mLetterboxUiController.getHorizontalPositionMultiplier(newParentConfiguration); mLetterboxUiController.getHorizontalPositionMultiplier( newParentConfiguration); offsetX = (int) Math.ceil((parentAppBounds.width() - screenResolvedBounds.width()) * positionMultiplier); } } // Vertical position int offsetY = 0; if (parentBounds.height() != screenResolvedBounds.height()) { if (screenResolvedBounds.height() >= parentAppBounds.height()) { // If resolved bounds overlap with insets, center within app bounds. offsetY = getCenterOffset( parentAppBounds.height(), screenResolvedBounds.height()); } else { float positionMultiplier = mLetterboxUiController.getVerticalPositionMultiplier( newParentConfiguration); offsetY = (int) Math.ceil((parentAppBounds.height() - screenResolvedBounds.height()) * positionMultiplier); } } if (mSizeCompatBounds != null) { mSizeCompatBounds.offset(offsetX, 0 /* offsetY */); mSizeCompatBounds.offset(offsetX , offsetY); final int dy = mSizeCompatBounds.top - resolvedBounds.top; final int dx = mSizeCompatBounds.left - resolvedBounds.left; offsetBounds(resolvedConfig, dx, 0 /* offsetY */); offsetBounds(resolvedConfig, dx, dy); } else { offsetBounds(resolvedConfig, offsetX, 0 /* offsetY */); offsetBounds(resolvedConfig, offsetX, offsetY); } // Since bounds has changed, the configuration needs to be computed accordingly. Loading Loading @@ -8078,14 +8100,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mIsAspectRatioApplied = applyAspectRatio(resolvedBounds, containingBoundsWithInsets, containingBounds, desiredAspectRatio, true); // Vertically center if orientation is landscape. Center within parent bounds with insets // to ensure that insets do not trim height. Bounds will later be horizontally centered in // {@link updateResolvedBoundsHorizontalPosition()} regardless of orientation. if (forcedOrientation == ORIENTATION_LANDSCAPE) { final int offsetY = parentBoundsWithInsets.centerY() - resolvedBounds.centerY(); resolvedBounds.offset(0, offsetY); } if (mCompatDisplayInsets != null) { mCompatDisplayInsets.getBoundsByRotation( mTmpBounds, newParentConfig.windowConfiguration.getRotation()); Loading @@ -8108,10 +8122,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** * Resolves aspect ratio restrictions for an activity. If the bounds are restricted by * aspect ratio, the position will be adjusted later in {@link * updateResolvedBoundsHorizontalPosition} within parent's app bounds to balance the visual * appearance. The policy of aspect ratio has higher priority than the requested override * bounds. * aspect ratio, the position will be adjusted later in {@link #updateResolvedBoundsPosition * within parent's app bounds to balance the visual appearance. The policy of aspect ratio has * higher priority than the requested override bounds. */ private void resolveAspectRatioRestriction(Configuration newParentConfiguration) { final Configuration resolvedConfig = getResolvedOverrideConfiguration(); Loading @@ -8123,7 +8136,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mTmpBounds.setEmpty(); mIsAspectRatioApplied = applyAspectRatio(mTmpBounds, parentAppBounds, parentBounds); // If the out bounds is not empty, it means the activity cannot fill parent's app bounds, // then they should be aligned later in #updateResolvedBoundsHorizontalPosition(). // then they should be aligned later in #updateResolvedBoundsPosition() if (!mTmpBounds.isEmpty()) { resolvedBounds.set(mTmpBounds); } Loading Loading @@ -8257,22 +8270,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Vertically center within parent (bounds) - this is a UX choice and exclude the horizontal // decor if needed. Horizontal position is adjusted in // updateResolvedBoundsHorizontalPosition. // The position will be later adjusted in updateResolvedBoundsPosition. // Above coordinates are in "@" space, now place "*" and "#" to screen space. final boolean fillContainer = resolvedBounds.equals(containingBounds); final int screenPosX = fillContainer ? containerBounds.left : containerAppBounds.left; // If the activity is not in size compat mode, calculate vertical centering // from the container and resolved bounds. // If the activity is in size compat mode, calculate vertical centering // from the container and size compat bounds. // The container bounds contain the parent bounds offset in the display, for // example when an activity is in the lower split of split screen. final int screenPosY = (mSizeCompatBounds == null ? (containerBounds.height() - resolvedBounds.height()) / 2 : (containerBounds.height() - mSizeCompatBounds.height()) / 2) + containerBounds.top; final int screenPosY = fillContainer ? containerBounds.top : containerAppBounds.top; if (screenPosX != 0 || screenPosY != 0) { if (mSizeCompatBounds != null) { Loading Loading @@ -8332,9 +8334,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return true; } /** @return The horizontal offset of putting the content in the center of viewport. */ private static int getHorizontalCenterOffset(int viewportW, int contentW) { return (int) ((viewportW - contentW + 1) * 0.5f); /** @return The horizontal / vertical offset of putting the content in the center of viewport.*/ private static int getCenterOffset(int viewportDim, int contentDim) { return (int) ((viewportDim - contentDim + 1) * 0.5f); } private static void offsetBounds(Configuration inOutConfig, int offsetX, int offsetY) { Loading Loading @@ -9597,7 +9599,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A outBounds.bottom = dH; outBounds.right = (int) ((float) dH * dH / dW); } outBounds.offset(getHorizontalCenterOffset(mWidth, outBounds.width()), 0 /* dy */); outBounds.offset(getCenterOffset(mWidth, outBounds.width()), 0 /* dy */); } outAppBounds.set(outBounds); Loading
services/core/java/com/android/server/wm/Letterbox.java +8 −4 Original line number Diff line number Diff line Loading @@ -72,7 +72,8 @@ public class Letterbox { private final LetterboxSurface mFullWindowSurface = new LetterboxSurface("fullWindow"); private final LetterboxSurface[] mSurfaces = { mLeft, mTop, mRight, mBottom }; // Reachability gestures. private final IntConsumer mDoubleTapCallback; private final IntConsumer mDoubleTapCallbackX; private final IntConsumer mDoubleTapCallbackY; /** * Constructs a Letterbox. Loading @@ -86,7 +87,8 @@ public class Letterbox { Supplier<Boolean> hasWallpaperBackgroundSupplier, Supplier<Integer> blurRadiusSupplier, Supplier<Float> darkScrimAlphaSupplier, IntConsumer doubleTapCallback) { IntConsumer doubleTapCallbackX, IntConsumer doubleTapCallbackY) { mSurfaceControlFactory = surfaceControlFactory; mTransactionFactory = transactionFactory; mAreCornersRounded = areCornersRounded; Loading @@ -94,7 +96,8 @@ public class Letterbox { mHasWallpaperBackgroundSupplier = hasWallpaperBackgroundSupplier; mBlurRadiusSupplier = blurRadiusSupplier; mDarkScrimAlphaSupplier = darkScrimAlphaSupplier; mDoubleTapCallback = doubleTapCallback; mDoubleTapCallbackX = doubleTapCallbackX; mDoubleTapCallbackY = doubleTapCallbackY; } /** Loading Loading @@ -264,7 +267,8 @@ public class Letterbox { @Override public boolean onDoubleTapEvent(MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_UP) { mDoubleTapCallback.accept((int) e.getX()); mDoubleTapCallbackX.accept((int) e.getX()); mDoubleTapCallbackY.accept((int) e.getY()); return true; } return false; Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +294 −77 File changed.Preview size limit exceeded, changes collapsed. Show changes