Loading services/core/java/com/android/server/wm/WindowContainer.java +3 −0 Original line number Diff line number Diff line Loading @@ -3594,8 +3594,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< && !mTransitionController.useShellTransitionsRotation()) { if (deltaRotation != Surface.ROTATION_0) { updateSurfaceRotation(t, deltaRotation, null /* positionLeash */); t.setFixedTransformHint(mSurfaceControl, getWindowConfiguration().getDisplayRotation()); } else if (deltaRotation != mLastDeltaRotation) { t.setMatrix(mSurfaceControl, 1, 0, 0, 1); t.unsetFixedTransformHint(mSurfaceControl); } } mLastDeltaRotation = deltaRotation; Loading services/core/java/com/android/server/wm/WindowToken.java +1 −0 Original line number Diff line number Diff line Loading @@ -596,6 +596,7 @@ class WindowToken extends WindowContainer<WindowState> { .build(); t.setPosition(leash, mLastSurfacePosition.x, mLastSurfacePosition.y); t.reparent(getSurfaceControl(), leash); t.setFixedTransformHint(leash, getWindowConfiguration().getDisplayRotation()); mFixedRotationTransformLeash = leash; updateSurfaceRotation(t, rotation, mFixedRotationTransformLeash); return mFixedRotationTransformLeash; Loading services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java +19 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,10 @@ public class SurfaceControlTests { public void testSurfaceChangedOnRotation() { final Instrumentation instrumentation = getInstrumentation(); final Context context = instrumentation.getContext(); final Activity activity = instrumentation.startActivitySync(new Intent().setComponent( final Intent intent = new Intent().setComponent( new ComponentName(context, ActivityOptionsTest.MainActivity.class)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); final Activity activity = instrumentation.startActivitySync(intent); final SurfaceView sv = new SurfaceView(activity); final AtomicInteger surfaceChangedCount = new AtomicInteger(); instrumentation.runOnMainSync(() -> activity.setContentView(sv)); Loading Loading @@ -157,12 +158,27 @@ public class SurfaceControlTests { instrumentation.waitForIdleSync(); final int newRotation = activity.getResources().getConfiguration() .windowConfiguration.getRotation(); if (rotation == newRotation) { // The device might not support requested orientation. activity.finishAndRemoveTask(); return; } final int count = surfaceChangedCount.get(); activity.moveTaskToBack(true /* nonRoot */); instrumentation.getUiAutomation().syncInputTransactions(); context.startActivity(intent); instrumentation.getUiAutomation().syncInputTransactions(); final int countAfterToFront = count - surfaceChangedCount.get(); activity.finishAndRemoveTask(); // The first count is triggered from creation, so the target number is 2. if (rotation != newRotation && count > 2) { if (count > 2) { fail("More than once surfaceChanged for rotation change: " + count); } if (countAfterToFront > 1) { fail("More than once surfaceChanged for app transition with rotation change: " + countAfterToFront); } } private SurfaceControl buildTestSurface() { Loading Loading
services/core/java/com/android/server/wm/WindowContainer.java +3 −0 Original line number Diff line number Diff line Loading @@ -3594,8 +3594,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< && !mTransitionController.useShellTransitionsRotation()) { if (deltaRotation != Surface.ROTATION_0) { updateSurfaceRotation(t, deltaRotation, null /* positionLeash */); t.setFixedTransformHint(mSurfaceControl, getWindowConfiguration().getDisplayRotation()); } else if (deltaRotation != mLastDeltaRotation) { t.setMatrix(mSurfaceControl, 1, 0, 0, 1); t.unsetFixedTransformHint(mSurfaceControl); } } mLastDeltaRotation = deltaRotation; Loading
services/core/java/com/android/server/wm/WindowToken.java +1 −0 Original line number Diff line number Diff line Loading @@ -596,6 +596,7 @@ class WindowToken extends WindowContainer<WindowState> { .build(); t.setPosition(leash, mLastSurfacePosition.x, mLastSurfacePosition.y); t.reparent(getSurfaceControl(), leash); t.setFixedTransformHint(leash, getWindowConfiguration().getDisplayRotation()); mFixedRotationTransformLeash = leash; updateSurfaceRotation(t, rotation, mFixedRotationTransformLeash); return mFixedRotationTransformLeash; Loading
services/tests/wmtests/src/com/android/server/wm/SurfaceControlTests.java +19 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,10 @@ public class SurfaceControlTests { public void testSurfaceChangedOnRotation() { final Instrumentation instrumentation = getInstrumentation(); final Context context = instrumentation.getContext(); final Activity activity = instrumentation.startActivitySync(new Intent().setComponent( final Intent intent = new Intent().setComponent( new ComponentName(context, ActivityOptionsTest.MainActivity.class)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); final Activity activity = instrumentation.startActivitySync(intent); final SurfaceView sv = new SurfaceView(activity); final AtomicInteger surfaceChangedCount = new AtomicInteger(); instrumentation.runOnMainSync(() -> activity.setContentView(sv)); Loading Loading @@ -157,12 +158,27 @@ public class SurfaceControlTests { instrumentation.waitForIdleSync(); final int newRotation = activity.getResources().getConfiguration() .windowConfiguration.getRotation(); if (rotation == newRotation) { // The device might not support requested orientation. activity.finishAndRemoveTask(); return; } final int count = surfaceChangedCount.get(); activity.moveTaskToBack(true /* nonRoot */); instrumentation.getUiAutomation().syncInputTransactions(); context.startActivity(intent); instrumentation.getUiAutomation().syncInputTransactions(); final int countAfterToFront = count - surfaceChangedCount.get(); activity.finishAndRemoveTask(); // The first count is triggered from creation, so the target number is 2. if (rotation != newRotation && count > 2) { if (count > 2) { fail("More than once surfaceChanged for rotation change: " + count); } if (countAfterToFront > 1) { fail("More than once surfaceChanged for app transition with rotation change: " + countAfterToFront); } } private SurfaceControl buildTestSurface() { Loading