Loading services/core/java/com/android/server/wm/LaunchParamsUtil.java +43 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.annotation.NonNull; import android.content.pm.ActivityInfo; import android.graphics.Rect; import android.util.Size; import android.view.View; /** * The static class that defines some utility constants and functions that are shared among launch Loading @@ -43,6 +44,8 @@ class LaunchParamsUtil { private static final int DEFAULT_LANDSCAPE_FREEFORM_WIDTH_DP = 1064; private static final int DEFAULT_LANDSCAPE_FREEFORM_HEIGHT_DP = 600; private static final int DISPLAY_EDGE_OFFSET_DP = 27; private LaunchParamsUtil() {} /** Loading Loading @@ -126,4 +129,44 @@ class LaunchParamsUtil { return new Size(adjWidth, adjHeight); } static void adjustBoundsToFitInDisplayArea(@NonNull Rect stableBounds, int layoutDirection, @NonNull ActivityInfo.WindowLayout layout, @NonNull Rect inOutBounds) { if (stableBounds.width() < inOutBounds.width() || stableBounds.height() < inOutBounds.height()) { // There is no way for us to fit the bounds in the displayArea without changing width // or height. Just move the start to align with the displayArea. final int left = layoutDirection == View.LAYOUT_DIRECTION_RTL ? stableBounds.right - inOutBounds.right + inOutBounds.left : stableBounds.left; inOutBounds.offsetTo(left, stableBounds.top); return; } final int dx; if (inOutBounds.right > stableBounds.right) { // Right edge is out of displayArea. dx = stableBounds.right - inOutBounds.right; } else if (inOutBounds.left < stableBounds.left) { // Left edge is out of displayArea. dx = stableBounds.left - inOutBounds.left; } else { // Vertical edges are all in displayArea. dx = 0; } final int dy; if (inOutBounds.top < stableBounds.top) { // Top edge is out of displayArea. dy = stableBounds.top - inOutBounds.top; } else if (inOutBounds.bottom > stableBounds.bottom) { // Bottom edge is out of displayArea. dy = stableBounds.bottom - inOutBounds.bottom; } else { // Horizontal edges are all in displayArea. dy = 0; } inOutBounds.offset(dx, dy); } } services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +9 −44 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import android.graphics.Rect; import android.util.Size; import android.util.Slog; import android.view.Gravity; import android.view.View; import android.window.WindowContainerToken; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -370,7 +369,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { if (resolvedMode == WINDOWING_MODE_FREEFORM) { // Make sure bounds are in the displayArea. if (currentParams.mPreferredTaskDisplayArea != taskDisplayArea) { adjustBoundsToFitInDisplayArea(taskDisplayArea, outParams.mBounds); adjustBoundsToFitInDisplayArea(taskDisplayArea, layout, outParams.mBounds); } // Even though we want to keep original bounds, we still don't want it to stomp on // an existing task. Loading Loading @@ -771,7 +770,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // we may need to move it back to the displayArea. LaunchParamsUtil.centerBounds(displayArea, mTmpBounds.width(), mTmpBounds.height(), inOutBounds); adjustBoundsToFitInDisplayArea(displayArea, inOutBounds); adjustBoundsToFitInDisplayArea(displayArea, layout, inOutBounds); if (DEBUG) appendLog("freeform-size-mismatch=" + inOutBounds); } Loading Loading @@ -818,47 +817,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } private void adjustBoundsToFitInDisplayArea(@NonNull TaskDisplayArea displayArea, @NonNull ActivityInfo.WindowLayout layout, @NonNull Rect inOutBounds) { final Rect stableBounds = mTmpStableBounds; displayArea.getStableRect(stableBounds); if (stableBounds.width() < inOutBounds.width() || stableBounds.height() < inOutBounds.height()) { // There is no way for us to fit the bounds in the displayArea without changing width // or height. Just move the start to align with the displayArea. final int layoutDirection = mSupervisor.mRootWindowContainer.getConfiguration().getLayoutDirection(); final int left = layoutDirection == View.LAYOUT_DIRECTION_RTL ? stableBounds.right - inOutBounds.right + inOutBounds.left : stableBounds.left; inOutBounds.offsetTo(left, stableBounds.top); return; } final int dx; if (inOutBounds.right > stableBounds.right) { // Right edge is out of displayArea. dx = stableBounds.right - inOutBounds.right; } else if (inOutBounds.left < stableBounds.left) { // Left edge is out of displayArea. dx = stableBounds.left - inOutBounds.left; } else { // Vertical edges are all in displayArea. dx = 0; } final int dy; if (inOutBounds.top < stableBounds.top) { // Top edge is out of displayArea. dy = stableBounds.top - inOutBounds.top; } else if (inOutBounds.bottom > stableBounds.bottom) { // Bottom edge is out of displayArea. dy = stableBounds.bottom - inOutBounds.bottom; } else { // Horizontal edges are all in displayArea. dy = 0; } inOutBounds.offset(dx, dy); final int layoutDirection = mSupervisor.mRootWindowContainer.getConfiguration() .getLayoutDirection(); displayArea.getStableRect(mTmpStableBounds); LaunchParamsUtil.adjustBoundsToFitInDisplayArea(mTmpStableBounds, layoutDirection, layout, inOutBounds); } /** Loading Loading
services/core/java/com/android/server/wm/LaunchParamsUtil.java +43 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.annotation.NonNull; import android.content.pm.ActivityInfo; import android.graphics.Rect; import android.util.Size; import android.view.View; /** * The static class that defines some utility constants and functions that are shared among launch Loading @@ -43,6 +44,8 @@ class LaunchParamsUtil { private static final int DEFAULT_LANDSCAPE_FREEFORM_WIDTH_DP = 1064; private static final int DEFAULT_LANDSCAPE_FREEFORM_HEIGHT_DP = 600; private static final int DISPLAY_EDGE_OFFSET_DP = 27; private LaunchParamsUtil() {} /** Loading Loading @@ -126,4 +129,44 @@ class LaunchParamsUtil { return new Size(adjWidth, adjHeight); } static void adjustBoundsToFitInDisplayArea(@NonNull Rect stableBounds, int layoutDirection, @NonNull ActivityInfo.WindowLayout layout, @NonNull Rect inOutBounds) { if (stableBounds.width() < inOutBounds.width() || stableBounds.height() < inOutBounds.height()) { // There is no way for us to fit the bounds in the displayArea without changing width // or height. Just move the start to align with the displayArea. final int left = layoutDirection == View.LAYOUT_DIRECTION_RTL ? stableBounds.right - inOutBounds.right + inOutBounds.left : stableBounds.left; inOutBounds.offsetTo(left, stableBounds.top); return; } final int dx; if (inOutBounds.right > stableBounds.right) { // Right edge is out of displayArea. dx = stableBounds.right - inOutBounds.right; } else if (inOutBounds.left < stableBounds.left) { // Left edge is out of displayArea. dx = stableBounds.left - inOutBounds.left; } else { // Vertical edges are all in displayArea. dx = 0; } final int dy; if (inOutBounds.top < stableBounds.top) { // Top edge is out of displayArea. dy = stableBounds.top - inOutBounds.top; } else if (inOutBounds.bottom > stableBounds.bottom) { // Bottom edge is out of displayArea. dy = stableBounds.bottom - inOutBounds.bottom; } else { // Horizontal edges are all in displayArea. dy = 0; } inOutBounds.offset(dx, dy); } }
services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +9 −44 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import android.graphics.Rect; import android.util.Size; import android.util.Slog; import android.view.Gravity; import android.view.View; import android.window.WindowContainerToken; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -370,7 +369,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { if (resolvedMode == WINDOWING_MODE_FREEFORM) { // Make sure bounds are in the displayArea. if (currentParams.mPreferredTaskDisplayArea != taskDisplayArea) { adjustBoundsToFitInDisplayArea(taskDisplayArea, outParams.mBounds); adjustBoundsToFitInDisplayArea(taskDisplayArea, layout, outParams.mBounds); } // Even though we want to keep original bounds, we still don't want it to stomp on // an existing task. Loading Loading @@ -771,7 +770,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // we may need to move it back to the displayArea. LaunchParamsUtil.centerBounds(displayArea, mTmpBounds.width(), mTmpBounds.height(), inOutBounds); adjustBoundsToFitInDisplayArea(displayArea, inOutBounds); adjustBoundsToFitInDisplayArea(displayArea, layout, inOutBounds); if (DEBUG) appendLog("freeform-size-mismatch=" + inOutBounds); } Loading Loading @@ -818,47 +817,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } private void adjustBoundsToFitInDisplayArea(@NonNull TaskDisplayArea displayArea, @NonNull ActivityInfo.WindowLayout layout, @NonNull Rect inOutBounds) { final Rect stableBounds = mTmpStableBounds; displayArea.getStableRect(stableBounds); if (stableBounds.width() < inOutBounds.width() || stableBounds.height() < inOutBounds.height()) { // There is no way for us to fit the bounds in the displayArea without changing width // or height. Just move the start to align with the displayArea. final int layoutDirection = mSupervisor.mRootWindowContainer.getConfiguration().getLayoutDirection(); final int left = layoutDirection == View.LAYOUT_DIRECTION_RTL ? stableBounds.right - inOutBounds.right + inOutBounds.left : stableBounds.left; inOutBounds.offsetTo(left, stableBounds.top); return; } final int dx; if (inOutBounds.right > stableBounds.right) { // Right edge is out of displayArea. dx = stableBounds.right - inOutBounds.right; } else if (inOutBounds.left < stableBounds.left) { // Left edge is out of displayArea. dx = stableBounds.left - inOutBounds.left; } else { // Vertical edges are all in displayArea. dx = 0; } final int dy; if (inOutBounds.top < stableBounds.top) { // Top edge is out of displayArea. dy = stableBounds.top - inOutBounds.top; } else if (inOutBounds.bottom > stableBounds.bottom) { // Bottom edge is out of displayArea. dy = stableBounds.bottom - inOutBounds.bottom; } else { // Horizontal edges are all in displayArea. dy = 0; } inOutBounds.offset(dx, dy); final int layoutDirection = mSupervisor.mRootWindowContainer.getConfiguration() .getLayoutDirection(); displayArea.getStableRect(mTmpStableBounds); LaunchParamsUtil.adjustBoundsToFitInDisplayArea(mTmpStableBounds, layoutDirection, layout, inOutBounds); } /** Loading