Merge "Add delay when updating configuration for half-fold letterboxing" into tm-qpr-dev am: 2e18872e36 am: 1b64a8fbd4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21988882

Change-Id: I3dbc25806eafed8bd3a0fdd90c2926fabc7a44c0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Will Osborn
2023-03-22 12:57:01 +00:00
committed by Automerger Merge Worker

View File

@@ -88,6 +88,10 @@ import java.util.Set;
public class DisplayRotation {
private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayRotation" : TAG_WM;
// Delay in milliseconds when updating config due to folding events. This prevents
// config changes and unexpected jumps while folding the device to closed state.
private static final int FOLDING_RECOMPUTE_CONFIG_DELAY_MS = 800;
private static class RotationAnimationPair {
@AnimRes
int mEnter;
@@ -1662,6 +1666,7 @@ public class DisplayRotation {
private boolean mInHalfFoldTransition = false;
private final boolean mIsDisplayAlwaysSeparatingHinge;
private final Set<Integer> mTabletopRotations;
private final Runnable mActivityBoundsUpdateCallback;
FoldController() {
mTabletopRotations = new ArraySet<>();
@@ -1696,6 +1701,26 @@ public class DisplayRotation {
}
mIsDisplayAlwaysSeparatingHinge = mContext.getResources().getBoolean(
R.bool.config_isDisplayHingeAlwaysSeparating);
mActivityBoundsUpdateCallback = new Runnable() {
public void run() {
if (mDeviceState == DeviceStateController.DeviceState.OPEN
|| mDeviceState == DeviceStateController.DeviceState.HALF_FOLDED) {
synchronized (mLock) {
final Task topFullscreenTask =
mDisplayContent.getTask(
t -> t.getWindowingMode() == WINDOWING_MODE_FULLSCREEN);
if (topFullscreenTask != null) {
final ActivityRecord top =
topFullscreenTask.topRunningActivity();
if (top != null) {
top.recomputeConfiguration();
}
}
}
}
}
};
}
boolean isDeviceInPosture(DeviceStateController.DeviceState state, boolean isTabletop) {
@@ -1767,14 +1792,9 @@ public class DisplayRotation {
false /* forceRelayout */);
}
// Alert the activity of possible new bounds.
final Task topFullscreenTask =
mDisplayContent.getTask(t -> t.getWindowingMode() == WINDOWING_MODE_FULLSCREEN);
if (topFullscreenTask != null) {
final ActivityRecord top = topFullscreenTask.topRunningActivity();
if (top != null) {
top.recomputeConfiguration();
}
}
UiThread.getHandler().removeCallbacks(mActivityBoundsUpdateCallback);
UiThread.getHandler().postDelayed(mActivityBoundsUpdateCallback,
FOLDING_RECOMPUTE_CONFIG_DELAY_MS);
}
}