Merge "Use seamless rotation if navigation bar allows" into udc-dev

This commit is contained in:
Riddle Hsu
2023-06-12 15:40:46 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 12 deletions

View File

@@ -300,9 +300,12 @@ public class DisplayLayout {
return mAllowSeamlessRotationDespiteNavBarMoving; return mAllowSeamlessRotationDespiteNavBarMoving;
} }
/** @return whether the navigation bar will change sides during rotation. */ /**
* Returns {@code true} if the navigation bar will change sides during rotation and the display
* is not square.
*/
public boolean navigationBarCanMove() { public boolean navigationBarCanMove() {
return mNavigationBarCanMove; return mNavigationBarCanMove && mWidth != mHeight;
} }
/** @return the rotation that would make the physical display "upside down". */ /** @return the rotation that would make the physical display "upside down". */

View File

@@ -260,6 +260,12 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
// This is the only way to get display-id currently, so check display capabilities here. // This is the only way to get display-id currently, so check display capabilities here.
final DisplayLayout displayLayout = displayController.getDisplayLayout( final DisplayLayout displayLayout = displayController.getDisplayLayout(
topTaskInfo.displayId); topTaskInfo.displayId);
// This condition should be true when using gesture navigation or the screen size is large
// (>600dp) because the bar is small relative to screen.
if (displayLayout.allowSeamlessRotationDespiteNavBarMoving()) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " nav bar allows seamless.");
return ROTATION_ANIMATION_SEAMLESS;
}
// For the upside down rotation we don't rotate seamlessly as the navigation bar moves // For the upside down rotation we don't rotate seamlessly as the navigation bar moves
// position. Note most apps (using orientation:sensor or user as opposed to fullSensor) // position. Note most apps (using orientation:sensor or user as opposed to fullSensor)
// will not enter the reverse portrait orientation, so actually the orientation won't // will not enter the reverse portrait orientation, so actually the orientation won't
@@ -272,13 +278,9 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
return animationHint; return animationHint;
} }
// If the navigation bar can't change sides, then it will jump when we change orientations // If the navigation bar cannot change sides, then it will jump when changing orientation
// and we don't rotate seamlessly - unless that is allowed, e.g. with gesture navigation // so do not use seamless rotation.
// where the navbar is low-profile enough that this isn't very noticeable. if (!displayLayout.navigationBarCanMove()) {
if (!displayLayout.allowSeamlessRotationDespiteNavBarMoving()
&& (!(displayLayout.navigationBarCanMove()
&& (displayChange.getStartAbsBounds().width()
!= displayChange.getStartAbsBounds().height())))) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
" nav bar changes sides, so not seamless."); " nav bar changes sides, so not seamless.");
return animationHint; return animationHint;

View File

@@ -702,8 +702,8 @@ public class ShellTransitionTests extends ShellTestCase {
createTaskInfo(1, WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD); createTaskInfo(1, WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD);
final DisplayController displays = createTestDisplayController(); final DisplayController displays = createTestDisplayController();
final @Surface.Rotation int upsideDown = displays final DisplayLayout displayLayout = displays.getDisplayLayout(DEFAULT_DISPLAY);
.getDisplayLayout(DEFAULT_DISPLAY).getUpsideDownRotation(); final @Surface.Rotation int upsideDown = displayLayout.getUpsideDownRotation();
TransitionInfo.Change displayChange = new ChangeBuilder(TRANSIT_CHANGE) TransitionInfo.Change displayChange = new ChangeBuilder(TRANSIT_CHANGE)
.setFlags(FLAG_IS_DISPLAY).setRotate().build(); .setFlags(FLAG_IS_DISPLAY).setRotate().build();
@@ -743,7 +743,8 @@ public class ShellTransitionTests extends ShellTestCase {
assertEquals(ROTATION_ANIMATION_ROTATE, DefaultTransitionHandler.getRotationAnimationHint( assertEquals(ROTATION_ANIMATION_ROTATE, DefaultTransitionHandler.getRotationAnimationHint(
displayChange, noTask, displays)); displayChange, noTask, displays));
// Not seamless if one of rotations is upside-down // Not seamless if the nav bar cares rotation and one of rotations is upside-down.
doReturn(false).when(displayLayout).allowSeamlessRotationDespiteNavBarMoving();
displayChange = new ChangeBuilder(TRANSIT_CHANGE).setFlags(FLAG_IS_DISPLAY) displayChange = new ChangeBuilder(TRANSIT_CHANGE).setFlags(FLAG_IS_DISPLAY)
.setRotate(upsideDown, ROTATION_ANIMATION_UNSPECIFIED).build(); .setRotate(upsideDown, ROTATION_ANIMATION_UNSPECIFIED).build();
final TransitionInfo seamlessUpsideDown = new TransitionInfoBuilder(TRANSIT_CHANGE) final TransitionInfo seamlessUpsideDown = new TransitionInfoBuilder(TRANSIT_CHANGE)