summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2022-04-26 23:46:19 +0800
committer Riddle Hsu <riddlehsu@google.com> 2022-04-26 23:50:46 +0800
commit6f828594219850624d71e258fac2ec43c8ae40f1 (patch)
tree7e5b206a179c4c62bfbf7ba61cf2e400e5f3102e
parent0b91be7283d9221e5f548c3b6ae2c07135d2ee2b (diff)
Check physical upside down for seamless rotation
The "UpsideDown" field of DisplayRotation stands for reverse portrait. So the general up side down rotation should be ROTATION_180. Also move up the condition of movable navigation bar, which should have higher priority to allow seamless rotation. Because it also means that upside down is supported. Fixes: 229671538 Test: atest DisplayRotationTests#testShouldRotateSeamlessly Change-Id: I9165f44b42fd058cb52753ecdf3cb98789c675d2
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotation.java14
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java8
2 files changed, 14 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index 43ff58083657..d73eff1c1c11 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -702,17 +702,17 @@ public class DisplayRotation {
}
boolean canRotateSeamlessly(int oldRotation, int newRotation) {
+ // If the navigation bar can't change sides, then it will jump when we change orientations
+ // and we don't rotate seamlessly - unless that is allowed, eg. with gesture navigation
+ // where the navbar is low-profile enough that this isn't very noticeable.
+ if (mAllowSeamlessRotationDespiteNavBarMoving || mDisplayPolicy.navigationBarCanMove()) {
+ return true;
+ }
// 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)
// will not enter the reverse portrait orientation, so actually the orientation won't change
// at all.
- if (oldRotation == mUpsideDownRotation || newRotation == mUpsideDownRotation) {
- return false;
- }
- // If the navigation bar can't change sides, then it will jump when we change orientations
- // and we don't rotate seamlessly - unless that is allowed, eg. with gesture navigation
- // where the navbar is low-profile enough that this isn't very noticeable.
- return mAllowSeamlessRotationDespiteNavBarMoving || mDisplayPolicy.navigationBarCanMove();
+ return oldRotation != Surface.ROTATION_180 && newRotation != Surface.ROTATION_180;
}
void markForSeamlessRotation(WindowState w, boolean seamlesslyRotated) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
index 25cff61c3b78..e8d0acba5e52 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
@@ -721,14 +721,20 @@ public class DisplayRotationTests {
doReturn(true).when(mMockDisplayPolicy).navigationBarCanMove();
doReturn(win).when(mMockDisplayPolicy).getTopFullscreenOpaqueWindow();
mMockDisplayContent.mCurrentFocus = win;
- mTarget.mUpsideDownRotation = Surface.ROTATION_180;
+ // This should not affect the condition of shouldRotateSeamlessly.
+ mTarget.mUpsideDownRotation = Surface.ROTATION_90;
doReturn(true).when(win.mActivityRecord).matchParentBounds();
// The focused fullscreen opaque window without override bounds should be able to be
// rotated seamlessly.
assertTrue(mTarget.shouldRotateSeamlessly(
Surface.ROTATION_0, Surface.ROTATION_90, false /* forceUpdate */));
+ // Reject any 180 degree because non-movable navbar will be placed in a different position.
+ doReturn(false).when(mMockDisplayPolicy).navigationBarCanMove();
+ assertFalse(mTarget.shouldRotateSeamlessly(
+ Surface.ROTATION_90, Surface.ROTATION_180, false /* forceUpdate */));
+ doReturn(true).when(mMockDisplayPolicy).navigationBarCanMove();
doReturn(false).when(win.mActivityRecord).matchParentBounds();
// No seamless rotation if the window may be positioned with offset after rotation.
assertFalse(mTarget.shouldRotateSeamlessly(