summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotation.java33
1 files changed, 25 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 eaa08fd5eb0b..185e06eecabb 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -1537,6 +1537,7 @@ public class DisplayRotation {
private int mHalfFoldSavedRotation = -1; // No saved rotation
private DeviceStateController.FoldState mFoldState =
DeviceStateController.FoldState.UNKNOWN;
+ private boolean mInHalfFoldTransition = false;
boolean overrideFrozenRotation() {
return mFoldState == DeviceStateController.FoldState.HALF_FOLDED;
@@ -1544,6 +1545,7 @@ public class DisplayRotation {
boolean shouldRevertOverriddenRotation() {
return mFoldState == DeviceStateController.FoldState.OPEN // When transitioning to open.
+ && mInHalfFoldTransition
&& mHalfFoldSavedRotation != -1 // Ignore if we've already reverted.
&& mUserRotationMode
== WindowManagerPolicy.USER_ROTATION_LOCKED; // Ignore if we're unlocked.
@@ -1552,6 +1554,7 @@ public class DisplayRotation {
int revertOverriddenRotation() {
int savedRotation = mHalfFoldSavedRotation;
mHalfFoldSavedRotation = -1;
+ mInHalfFoldTransition = false;
return savedRotation;
}
@@ -1577,16 +1580,11 @@ public class DisplayRotation {
mService.updateRotation(false /* alwaysSendConfiguration */,
false /* forceRelayout */);
} else {
- // Revert the rotation to our saved value if we transition from HALF_FOLDED.
- if (mHalfFoldSavedRotation != -1) {
- mRotation = mHalfFoldSavedRotation;
- }
- // Tell the device to update its orientation (mFoldState is still HALF_FOLDED here
- // so we will override USER_ROTATION_LOCKED and allow a rotation).
+ mInHalfFoldTransition = true;
+ mFoldState = newState;
+ // Tell the device to update its orientation.
mService.updateRotation(false /* alwaysSendConfiguration */,
false /* forceRelayout */);
- // Once we are rotated, set mFoldstate, effectively removing the lock override.
- mFoldState = newState;
}
}
}
@@ -1683,6 +1681,7 @@ public class DisplayRotation {
private static class RotationHistory {
private static final int MAX_SIZE = 8;
+ private static final int NO_FOLD_CONTROLLER = -2;
private static class Record {
final @Surface.Rotation int mFromRotation;
final @Surface.Rotation int mToRotation;
@@ -1694,6 +1693,9 @@ public class DisplayRotation {
final String mLastOrientationSource;
final @ActivityInfo.ScreenOrientation int mSourceOrientation;
final long mTimestamp = System.currentTimeMillis();
+ final int mHalfFoldSavedRotation;
+ final boolean mInHalfFoldTransition;
+ final DeviceStateController.FoldState mFoldState;
Record(DisplayRotation dr, int fromRotation, int toRotation) {
mFromRotation = fromRotation;
@@ -1719,6 +1721,15 @@ public class DisplayRotation {
mLastOrientationSource = null;
mSourceOrientation = SCREEN_ORIENTATION_UNSET;
}
+ if (dr.mFoldController != null) {
+ mHalfFoldSavedRotation = dr.mFoldController.mHalfFoldSavedRotation;
+ mInHalfFoldTransition = dr.mFoldController.mInHalfFoldTransition;
+ mFoldState = dr.mFoldController.mFoldState;
+ } else {
+ mHalfFoldSavedRotation = NO_FOLD_CONTROLLER;
+ mInHalfFoldTransition = false;
+ mFoldState = DeviceStateController.FoldState.UNKNOWN;
+ }
}
void dump(String prefix, PrintWriter pw) {
@@ -1735,6 +1746,12 @@ public class DisplayRotation {
if (mNonDefaultRequestingTaskDisplayArea != null) {
pw.println(prefix + " requestingTda=" + mNonDefaultRequestingTaskDisplayArea);
}
+ if (mHalfFoldSavedRotation != NO_FOLD_CONTROLLER) {
+ pw.println(prefix + " halfFoldSavedRotation="
+ + mHalfFoldSavedRotation
+ + " mInHalfFoldTransition=" + mInHalfFoldTransition
+ + " mFoldState=" + mFoldState);
+ }
}
}