Fix seamless condition of fixed rotation transform
The top window from display policy relies on layout to
be updated. It is more accurate to check the active
transformed record.
Fix: 149793692
Test: atest DisplayContentTests#testApplyTopFixedRotationTransform
Change-Id: I8694190faab343e6c524a4399fec0a9b16bfa561
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 1a8f2a6..b3c6b22 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -27,6 +27,7 @@
import static android.view.DisplayCutout.BOUNDS_POSITION_LEFT;
import static android.view.DisplayCutout.BOUNDS_POSITION_TOP;
import static android.view.DisplayCutout.fromBoundingRect;
+import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_90;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
@@ -998,12 +999,10 @@
public void testApplyTopFixedRotationTransform() {
mWm.mIsFixedRotationTransformEnabled = true;
final Configuration config90 = new Configuration();
- mDisplayContent.getDisplayRotation().setRotation(ROTATION_90);
- mDisplayContent.computeScreenConfiguration(config90);
- mDisplayContent.onRequestedOverrideConfigurationChanged(config90);
+ mDisplayContent.computeScreenConfiguration(config90, ROTATION_90);
final Configuration config = new Configuration();
- mDisplayContent.getDisplayRotation().setRotation(Surface.ROTATION_0);
+ mDisplayContent.getDisplayRotation().setRotation(ROTATION_0);
mDisplayContent.computeScreenConfiguration(config);
mDisplayContent.onRequestedOverrideConfigurationChanged(config);
@@ -1014,11 +1013,18 @@
app.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
assertTrue(app.isFixedRotationTransforming());
+ assertTrue(mDisplayContent.getDisplayRotation().shouldRotateSeamlessly(
+ ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */,
+ false /* forceUpdate */));
+ // The display should keep current orientation and the rotated configuration should apply
+ // to the activity.
assertEquals(config.orientation, mDisplayContent.getConfiguration().orientation);
assertEquals(config90.orientation, app.getConfiguration().orientation);
+ assertEquals(config90.windowConfiguration.getBounds(), app.getBounds());
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token);
+ // The display should be rotated after the launch is finished.
assertFalse(app.hasFixedRotationTransform());
assertEquals(config90.orientation, mDisplayContent.getConfiguration().orientation);
}