Remove opposite position of nav bar for short aspect ratio app
To be consistent as non-resizable activity shown in different display size that is horizontal centered, the case of fixed aspect ratio also follows the same letterboxing. Without removing the opposite position calculation, it will produce an intermediate bounds that makes seamless rotation flicker. Supplement: - The letterboxing test was done in AppWindowTokenTests#testSizeCompatBounds - Reference of the discussion of original position: b/62893418 Bug: 112288258 Fixes: 124453651 Test: atest ActivityRecordTests Change-Id: Ie8d492910c48c8425f45f9c61a798854d3908591
This commit is contained in:
@@ -87,8 +87,6 @@ import static android.os.Build.VERSION_CODES.HONEYCOMB;
|
||||
import static android.os.Build.VERSION_CODES.O;
|
||||
import static android.os.Process.SYSTEM_UID;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_RIGHT;
|
||||
|
||||
import static com.android.server.am.ActivityRecordProto.CONFIGURATION_CONTAINER;
|
||||
import static com.android.server.am.ActivityRecordProto.FRONT_OF_TASK;
|
||||
@@ -2828,28 +2826,6 @@ final class ActivityRecord extends ConfigurationContainer {
|
||||
outAppBounds.setEmpty();
|
||||
}
|
||||
|
||||
// TODO(b/112288258): Remove below calculation because the position information in bounds
|
||||
// will be replaced by the offset of surface.
|
||||
final Rect appBounds = parentConfig.windowConfiguration.getAppBounds();
|
||||
if (appBounds != null) {
|
||||
final Rect outBounds = inOutConfig.windowConfiguration.getBounds();
|
||||
final int activityWidth = outBounds.width();
|
||||
final int navBarPosition = mAtmService.mWindowManager.getNavBarPosition(getDisplayId());
|
||||
if (navBarPosition == NAV_BAR_LEFT) {
|
||||
// Position the activity frame on the opposite side of the nav bar.
|
||||
outBounds.left = appBounds.right - activityWidth;
|
||||
outBounds.right = appBounds.right;
|
||||
} else if (navBarPosition == NAV_BAR_RIGHT) {
|
||||
// Position the activity frame on the opposite side of the nav bar.
|
||||
outBounds.left = 0;
|
||||
outBounds.right = activityWidth + appBounds.left;
|
||||
} else if (appBounds.width() > activityWidth) {
|
||||
// Horizontally center the frame.
|
||||
outBounds.left = appBounds.left + (appBounds.width() - activityWidth) / 2;
|
||||
outBounds.right = outBounds.left + activityWidth;
|
||||
}
|
||||
}
|
||||
|
||||
task.computeConfigResourceOverrides(inOutConfig, parentConfig, insideParentBounds);
|
||||
}
|
||||
|
||||
|
||||
@@ -2164,9 +2164,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
// A modal window uses the whole compatibility bounds.
|
||||
flags |= FLAG_NOT_TOUCH_MODAL;
|
||||
mTmpRect.set(mAppToken.getResolvedOverrideBounds());
|
||||
// TODO(b/112288258): Remove the forced offset when the override bounds always
|
||||
// starts from zero (See {@link ActivityRecord#resolveOverrideConfiguration}).
|
||||
mTmpRect.offsetTo(0, 0);
|
||||
} else {
|
||||
// Non-modal uses the application based frame.
|
||||
mTmpRect.set(mWindowFrames.mCompatFrame);
|
||||
|
||||
@@ -27,9 +27,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
|
||||
import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_BOTTOM;
|
||||
import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_LEFT;
|
||||
import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_RIGHT;
|
||||
import static com.android.server.wm.ActivityStack.ActivityState.INITIALIZING;
|
||||
import static com.android.server.wm.ActivityStack.ActivityState.PAUSING;
|
||||
import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
|
||||
@@ -158,35 +155,6 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
assertTrue(mActivity.isState(STOPPED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionLimitedAspectRatioNavBarBottom() {
|
||||
verifyPositionWithLimitedAspectRatio(NAV_BAR_BOTTOM, new Rect(0, 0, 1000, 2000), 1.5f,
|
||||
new Rect(0, 0, 1000, 1500));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionLimitedAspectRatioNavBarLeft() {
|
||||
verifyPositionWithLimitedAspectRatio(NAV_BAR_LEFT, new Rect(0, 0, 2000, 1000), 1.5f,
|
||||
new Rect(500, 0, 2000, 1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionLimitedAspectRatioNavBarRight() {
|
||||
verifyPositionWithLimitedAspectRatio(NAV_BAR_RIGHT, new Rect(0, 0, 2000, 1000), 1.5f,
|
||||
new Rect(0, 0, 1500, 1000));
|
||||
}
|
||||
|
||||
private void verifyPositionWithLimitedAspectRatio(int navBarPosition, Rect taskBounds,
|
||||
float aspectRatio, Rect expectedActivityBounds) {
|
||||
// Verify with nav bar on the right.
|
||||
when(mService.mWindowManager.getNavBarPosition(mActivity.getDisplayId()))
|
||||
.thenReturn(navBarPosition);
|
||||
mTask.getConfiguration().windowConfiguration.setAppBounds(taskBounds);
|
||||
mActivity.info.maxAspectRatio = aspectRatio;
|
||||
ensureActivityConfiguration();
|
||||
assertEquals(expectedActivityBounds, mActivity.getBounds());
|
||||
}
|
||||
|
||||
private void ensureActivityConfiguration() {
|
||||
mActivity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user