summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java36
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java5
2 files changed, 27 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 5bbabfceda47..4cf92cba10fe 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2730,30 +2730,40 @@ final class ActivityRecord extends ConfigurationContainer {
final int appHeight = resolvedAppBounds.height();
final int parentAppWidth = parentAppBounds.width();
final int parentAppHeight = parentAppBounds.height();
+ if (parentAppWidth == appWidth && parentAppHeight == appHeight) {
+ // Matched the parent bounds.
+ return false;
+ }
+ if (parentAppWidth > appWidth && parentAppHeight > appHeight) {
+ // Both sides are smaller than the parent.
+ return true;
+ }
if (parentAppWidth < appWidth || parentAppHeight < appHeight) {
// One side is larger than the parent.
return true;
}
- if (info.hasFixedAspectRatio()) {
+ // The rest of the condition is that only one side is smaller than the parent, but it still
+ // needs to exclude the cases where the size is limited by the fixed aspect ratio.
+ if (info.maxAspectRatio > 0) {
final float aspectRatio = (0.5f + Math.max(appWidth, appHeight))
/ Math.min(appWidth, appHeight);
+ if (aspectRatio >= info.maxAspectRatio) {
+ // The current size has reached the max aspect ratio.
+ return false;
+ }
+ }
+ if (info.minAspectRatio > 0) {
+ // The activity should have at least the min aspect ratio, so this checks if the parent
+ // still has available space to provide larger aspect ratio.
final float parentAspectRatio = (0.5f + Math.max(parentAppWidth, parentAppHeight))
/ Math.min(parentAppWidth, parentAppHeight);
- // Check if the parent still has available space in long side.
- if (aspectRatio < parentAspectRatio
- && (aspectRatio < info.maxAspectRatio || info.minAspectRatio > 0)) {
- return true;
+ if (parentAspectRatio <= info.minAspectRatio) {
+ // The long side has reached the parent.
+ return false;
}
}
-
- final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds();
- // If the width or height is the same as parent, it is already the best fit of the override
- // bounds, therefore this condition is considered as not size compatibility mode. Here uses
- // right and bottom as width and height of parent because the bounds may contain decor
- // insets which has been accounted in override bounds. See {@link #computeBounds}.
- return parentAppBounds.right != resolvedBounds.width()
- && parentAppBounds.bottom != resolvedBounds.height();
+ return true;
}
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index d580557638cf..32e96a592207 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -438,8 +438,11 @@ public class ActivityRecordTests extends ActivityTestsBase {
doReturn(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.when(mActivity.mAppWindowToken).getOrientationIgnoreVisibility();
mActivity.info.resizeMode = ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
- mActivity.info.maxAspectRatio = 1;
+ mActivity.info.minAspectRatio = mActivity.info.maxAspectRatio = 1;
ensureActivityConfiguration();
+ // The parent configuration doesn't change since the first resolved configuration, so the
+ // activity shouldn't be in the size compatibility mode.
+ assertFalse(mActivity.inSizeCompatMode());
final Rect appBounds = mActivity.getWindowConfiguration().getAppBounds();
// Ensure the app bounds keep the declared aspect ratio.