summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Graciela Putri <gracielawputri@google.com> 2024-06-14 08:44:45 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-06-14 08:44:45 +0000
commit7e8de9ceedf10ff720a273a02fa1592bf2f75b12 (patch)
tree37b60badd45901f89b73c60049578c22c2fac610
parenta98575f86cea3dc32d285cc21729f0622dda7c73 (diff)
parent08f79506ae1a19ffa60ff69a868d6c3ee5aac846 (diff)
Merge "Don't return half folded state when display in transition" into main
-rw-r--r--services/core/java/com/android/server/wm/LetterboxUiController.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java29
2 files changed, 32 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java
index 5e93e8930bab..864ac6582ece 100644
--- a/services/core/java/com/android/server/wm/LetterboxUiController.java
+++ b/services/core/java/com/android/server/wm/LetterboxUiController.java
@@ -871,12 +871,14 @@ final class LetterboxUiController {
// Check if we are in the given pose and in fullscreen mode.
// Note that we check the task rather than the parent as with ActivityEmbedding the parent might
// be a TaskFragment, and its windowing mode is always MULTI_WINDOW, even if the task is
- // actually fullscreen.
+ // actually fullscreen. If display is still in transition e.g. unfolding, don't return true
+ // for HALF_FOLDED state or app will flicker.
private boolean isDisplayFullScreenAndInPosture(boolean isTabletop) {
Task task = mActivityRecord.getTask();
return mActivityRecord.mDisplayContent != null && task != null
&& mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(
DeviceStateController.DeviceState.HALF_FOLDED, isTabletop)
+ && !mActivityRecord.mDisplayContent.inTransition()
&& task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 1a366b3e3a4f..ac1aa20b322f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -4121,6 +4121,35 @@ public class SizeCompatTests extends WindowTestsBase {
}
@Test
+ public void testUpdateResolvedBoundsVerticalPosition_unfoldDisplay_notTabletop() {
+ // Set up a display in portrait with a fixed-orientation LANDSCAPE app.
+ setUpDisplaySizeWithApp(1000, 2000);
+ mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ mActivity.mWmService.mLetterboxConfiguration.setLetterboxVerticalPositionMultiplier(
+ 1.0f /*letterboxVerticalPositionMultiplier*/);
+ prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
+
+ // Make the activity full-screen.
+ mTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
+
+ // Simulate display unfolding.
+ setFoldablePosture(true /* isHalfFolded */, true /* isTabletop */);
+ doReturn(true).when(mActivity.mDisplayContent).inTransition();
+ resizeDisplay(mTask.mDisplayContent, 1400, 2800);
+
+ // Make sure app doesn't jump to top (default tabletop position) when unfolding.
+ assertEquals(1.0f, mActivity.mLetterboxUiController.getVerticalPositionMultiplier(
+ mActivity.getParent().getConfiguration()), 0);
+
+ // Simulate display fully open after unfolding.
+ setFoldablePosture(false /* isHalfFolded */, false /* isTabletop */);
+ doReturn(false).when(mActivity.mDisplayContent).inTransition();
+
+ assertEquals(1.0f, mActivity.mLetterboxUiController.getVerticalPositionMultiplier(
+ mActivity.getParent().getConfiguration()), 0);
+ }
+
+ @Test
public void testGetFixedOrientationLetterboxAspectRatio_tabletop_centered() {
// Set up a display in portrait with a fixed-orientation LANDSCAPE app
setUpDisplaySizeWithApp(1400, 2800);