Merge "Add a delay to rotation updates to help avoid fold state race" into tm-qpr-dev am: d094fe2516
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22122422 Change-Id: Ice00437ee103a84c8cb70e0acc0b08b0078baf6e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -87,6 +87,8 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class DisplayRotation {
|
public class DisplayRotation {
|
||||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayRotation" : TAG_WM;
|
private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayRotation" : TAG_WM;
|
||||||
|
// Delay to avoid race between fold update and orientation update.
|
||||||
|
private static final int ORIENTATION_UPDATE_DELAY_MS = 800;
|
||||||
|
|
||||||
// Delay in milliseconds when updating config due to folding events. This prevents
|
// Delay in milliseconds when updating config due to folding events. This prevents
|
||||||
// config changes and unexpected jumps while folding the device to closed state.
|
// config changes and unexpected jumps while folding the device to closed state.
|
||||||
@@ -1743,15 +1745,15 @@ public class DisplayRotation {
|
|||||||
mDeviceState = newState;
|
mDeviceState = newState;
|
||||||
// Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will
|
// Now mFoldState is set to HALF_FOLDED, the overrideFrozenRotation function will
|
||||||
// return true, so rotation is unlocked.
|
// return true, so rotation is unlocked.
|
||||||
mService.updateRotation(false /* alwaysSendConfiguration */,
|
|
||||||
false /* forceRelayout */);
|
|
||||||
} else {
|
} else {
|
||||||
mInHalfFoldTransition = true;
|
mInHalfFoldTransition = true;
|
||||||
mDeviceState = newState;
|
mDeviceState = newState;
|
||||||
// Tell the device to update its orientation.
|
|
||||||
mService.updateRotation(false /* alwaysSendConfiguration */,
|
|
||||||
false /* forceRelayout */);
|
|
||||||
}
|
}
|
||||||
|
UiThread.getHandler().postDelayed(
|
||||||
|
() -> {
|
||||||
|
mService.updateRotation(false /* alwaysSendConfiguration */,
|
||||||
|
false /* forceRelayout */);
|
||||||
|
}, ORIENTATION_UPDATE_DELAY_MS);
|
||||||
// Alert the activity of possible new bounds.
|
// Alert the activity of possible new bounds.
|
||||||
UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback);
|
UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback);
|
||||||
UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback,
|
UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback,
|
||||||
|
|||||||
@@ -750,7 +750,7 @@ public class DisplayRotationTests {
|
|||||||
// ... until half-fold
|
// ... until half-fold
|
||||||
mTarget.foldStateChanged(DeviceStateController.DeviceState.HALF_FOLDED);
|
mTarget.foldStateChanged(DeviceStateController.DeviceState.HALF_FOLDED);
|
||||||
assertTrue(waitForUiHandler());
|
assertTrue(waitForUiHandler());
|
||||||
verify(sMockWm).updateRotation(false, false);
|
verify(sMockWm).updateRotation(anyBoolean(), anyBoolean());
|
||||||
assertTrue(waitForUiHandler());
|
assertTrue(waitForUiHandler());
|
||||||
assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation(
|
assertEquals(Surface.ROTATION_0, mTarget.rotationForOrientation(
|
||||||
SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));
|
SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));
|
||||||
@@ -758,7 +758,7 @@ public class DisplayRotationTests {
|
|||||||
// ... then transition back to flat
|
// ... then transition back to flat
|
||||||
mTarget.foldStateChanged(DeviceStateController.DeviceState.OPEN);
|
mTarget.foldStateChanged(DeviceStateController.DeviceState.OPEN);
|
||||||
assertTrue(waitForUiHandler());
|
assertTrue(waitForUiHandler());
|
||||||
verify(sMockWm, atLeast(1)).updateRotation(false, false);
|
verify(sMockWm, atLeast(1)).updateRotation(anyBoolean(), anyBoolean());
|
||||||
assertTrue(waitForUiHandler());
|
assertTrue(waitForUiHandler());
|
||||||
assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation(
|
assertEquals(Surface.ROTATION_270, mTarget.rotationForOrientation(
|
||||||
SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));
|
SCREEN_ORIENTATION_UNSPECIFIED, Surface.ROTATION_0));
|
||||||
|
|||||||
Reference in New Issue
Block a user