Merge "Fix tabletop autorotate freezing the device in portrait" into tm-qpr-dev am: 1616dafaf9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20608831 Change-Id: Ica67ee40b962170cccecbaa2d4d4a815a3d81b0f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1537,6 +1537,7 @@ public class DisplayRotation {
|
|||||||
private int mHalfFoldSavedRotation = -1; // No saved rotation
|
private int mHalfFoldSavedRotation = -1; // No saved rotation
|
||||||
private DeviceStateController.FoldState mFoldState =
|
private DeviceStateController.FoldState mFoldState =
|
||||||
DeviceStateController.FoldState.UNKNOWN;
|
DeviceStateController.FoldState.UNKNOWN;
|
||||||
|
private boolean mInHalfFoldTransition = false;
|
||||||
|
|
||||||
boolean overrideFrozenRotation() {
|
boolean overrideFrozenRotation() {
|
||||||
return mFoldState == DeviceStateController.FoldState.HALF_FOLDED;
|
return mFoldState == DeviceStateController.FoldState.HALF_FOLDED;
|
||||||
@@ -1544,6 +1545,7 @@ public class DisplayRotation {
|
|||||||
|
|
||||||
boolean shouldRevertOverriddenRotation() {
|
boolean shouldRevertOverriddenRotation() {
|
||||||
return mFoldState == DeviceStateController.FoldState.OPEN // When transitioning to open.
|
return mFoldState == DeviceStateController.FoldState.OPEN // When transitioning to open.
|
||||||
|
&& mInHalfFoldTransition
|
||||||
&& mHalfFoldSavedRotation != -1 // Ignore if we've already reverted.
|
&& mHalfFoldSavedRotation != -1 // Ignore if we've already reverted.
|
||||||
&& mUserRotationMode
|
&& mUserRotationMode
|
||||||
== WindowManagerPolicy.USER_ROTATION_LOCKED; // Ignore if we're unlocked.
|
== WindowManagerPolicy.USER_ROTATION_LOCKED; // Ignore if we're unlocked.
|
||||||
@@ -1552,6 +1554,7 @@ public class DisplayRotation {
|
|||||||
int revertOverriddenRotation() {
|
int revertOverriddenRotation() {
|
||||||
int savedRotation = mHalfFoldSavedRotation;
|
int savedRotation = mHalfFoldSavedRotation;
|
||||||
mHalfFoldSavedRotation = -1;
|
mHalfFoldSavedRotation = -1;
|
||||||
|
mInHalfFoldTransition = false;
|
||||||
return savedRotation;
|
return savedRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1577,16 +1580,11 @@ public class DisplayRotation {
|
|||||||
mService.updateRotation(false /* alwaysSendConfiguration */,
|
mService.updateRotation(false /* alwaysSendConfiguration */,
|
||||||
false /* forceRelayout */);
|
false /* forceRelayout */);
|
||||||
} else {
|
} else {
|
||||||
// Revert the rotation to our saved value if we transition from HALF_FOLDED.
|
mInHalfFoldTransition = true;
|
||||||
if (mHalfFoldSavedRotation != -1) {
|
mFoldState = newState;
|
||||||
mRotation = mHalfFoldSavedRotation;
|
// Tell the device to update its orientation.
|
||||||
}
|
|
||||||
// Tell the device to update its orientation (mFoldState is still HALF_FOLDED here
|
|
||||||
// so we will override USER_ROTATION_LOCKED and allow a rotation).
|
|
||||||
mService.updateRotation(false /* alwaysSendConfiguration */,
|
mService.updateRotation(false /* alwaysSendConfiguration */,
|
||||||
false /* forceRelayout */);
|
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 class RotationHistory {
|
||||||
private static final int MAX_SIZE = 8;
|
private static final int MAX_SIZE = 8;
|
||||||
|
private static final int NO_FOLD_CONTROLLER = -2;
|
||||||
private static class Record {
|
private static class Record {
|
||||||
final @Surface.Rotation int mFromRotation;
|
final @Surface.Rotation int mFromRotation;
|
||||||
final @Surface.Rotation int mToRotation;
|
final @Surface.Rotation int mToRotation;
|
||||||
@@ -1694,6 +1693,9 @@ public class DisplayRotation {
|
|||||||
final String mLastOrientationSource;
|
final String mLastOrientationSource;
|
||||||
final @ActivityInfo.ScreenOrientation int mSourceOrientation;
|
final @ActivityInfo.ScreenOrientation int mSourceOrientation;
|
||||||
final long mTimestamp = System.currentTimeMillis();
|
final long mTimestamp = System.currentTimeMillis();
|
||||||
|
final int mHalfFoldSavedRotation;
|
||||||
|
final boolean mInHalfFoldTransition;
|
||||||
|
final DeviceStateController.FoldState mFoldState;
|
||||||
|
|
||||||
Record(DisplayRotation dr, int fromRotation, int toRotation) {
|
Record(DisplayRotation dr, int fromRotation, int toRotation) {
|
||||||
mFromRotation = fromRotation;
|
mFromRotation = fromRotation;
|
||||||
@@ -1719,6 +1721,15 @@ public class DisplayRotation {
|
|||||||
mLastOrientationSource = null;
|
mLastOrientationSource = null;
|
||||||
mSourceOrientation = SCREEN_ORIENTATION_UNSET;
|
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) {
|
void dump(String prefix, PrintWriter pw) {
|
||||||
@@ -1735,6 +1746,12 @@ public class DisplayRotation {
|
|||||||
if (mNonDefaultRequestingTaskDisplayArea != null) {
|
if (mNonDefaultRequestingTaskDisplayArea != null) {
|
||||||
pw.println(prefix + " requestingTda=" + mNonDefaultRequestingTaskDisplayArea);
|
pw.println(prefix + " requestingTda=" + mNonDefaultRequestingTaskDisplayArea);
|
||||||
}
|
}
|
||||||
|
if (mHalfFoldSavedRotation != NO_FOLD_CONTROLLER) {
|
||||||
|
pw.println(prefix + " halfFoldSavedRotation="
|
||||||
|
+ mHalfFoldSavedRotation
|
||||||
|
+ " mInHalfFoldTransition=" + mInHalfFoldTransition
|
||||||
|
+ " mFoldState=" + mFoldState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user