Merge "Replace containing aspect ratio hard comparison with rounded one" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4677d90f9e
@@ -439,6 +439,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
// finished destroying itself.
|
// finished destroying itself.
|
||||||
private static final int DESTROY_TIMEOUT = 10 * 1000;
|
private static final int DESTROY_TIMEOUT = 10 * 1000;
|
||||||
|
|
||||||
|
// Rounding tolerance to be used in aspect ratio computations
|
||||||
|
private static final float ASPECT_RATIO_ROUNDING_TOLERANCE = 0.005f;
|
||||||
|
|
||||||
final ActivityTaskManagerService mAtmService;
|
final ActivityTaskManagerService mAtmService;
|
||||||
@NonNull
|
@NonNull
|
||||||
final ActivityInfo info; // activity info provided by developer in AndroidManifest
|
final ActivityInfo info; // activity info provided by developer in AndroidManifest
|
||||||
@@ -8950,7 +8953,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
int activityWidth = containingAppWidth;
|
int activityWidth = containingAppWidth;
|
||||||
int activityHeight = containingAppHeight;
|
int activityHeight = containingAppHeight;
|
||||||
|
|
||||||
if (containingRatio > desiredAspectRatio) {
|
if (containingRatio - desiredAspectRatio > ASPECT_RATIO_ROUNDING_TOLERANCE) {
|
||||||
if (containingAppWidth < containingAppHeight) {
|
if (containingAppWidth < containingAppHeight) {
|
||||||
// Width is the shorter side, so we use that to figure-out what the max. height
|
// Width is the shorter side, so we use that to figure-out what the max. height
|
||||||
// should be given the aspect ratio.
|
// should be given the aspect ratio.
|
||||||
@@ -8960,7 +8963,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
// should be given the aspect ratio.
|
// should be given the aspect ratio.
|
||||||
activityWidth = (int) ((activityHeight * desiredAspectRatio) + 0.5f);
|
activityWidth = (int) ((activityHeight * desiredAspectRatio) + 0.5f);
|
||||||
}
|
}
|
||||||
} else if (containingRatio < desiredAspectRatio) {
|
} else if (desiredAspectRatio - containingRatio > ASPECT_RATIO_ROUNDING_TOLERANCE) {
|
||||||
boolean adjustWidth;
|
boolean adjustWidth;
|
||||||
switch (getRequestedConfigurationOrientation()) {
|
switch (getRequestedConfigurationOrientation()) {
|
||||||
case ORIENTATION_LANDSCAPE:
|
case ORIENTATION_LANDSCAPE:
|
||||||
|
|||||||
@@ -3054,6 +3054,20 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
assertEquals(mActivity.getBounds(), display.getBounds());
|
assertEquals(mActivity.getBounds(), display.getBounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testApplyAspectRatio_containingRatioAlmostEqualToMaxRatio_boundsUnchanged() {
|
||||||
|
setUpDisplaySizeWithApp(1981, 2576);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
mWm.mLetterboxConfiguration.setLetterboxVerticalPositionMultiplier(0.5f);
|
||||||
|
|
||||||
|
final Rect originalBounds = new Rect(mActivity.getBounds());
|
||||||
|
prepareUnresizable(mActivity, 1.3f, SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
|
|
||||||
|
// The containing aspect ratio is now 1.3003534, while the desired aspect ratio is 1.3. The
|
||||||
|
// bounds of the activity should not be changed as the difference is too small
|
||||||
|
assertEquals(mActivity.getBounds(), originalBounds);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateResolvedBoundsHorizontalPosition_activityFillParentWidth() {
|
public void testUpdateResolvedBoundsHorizontalPosition_activityFillParentWidth() {
|
||||||
// When activity width equals parent width, multiplier shouldn't have any effect.
|
// When activity width equals parent width, multiplier shouldn't have any effect.
|
||||||
|
|||||||
Reference in New Issue
Block a user