Loading services/core/java/com/android/server/wm/WindowToken.java +18 −3 Original line number Diff line number Diff line Loading @@ -554,13 +554,12 @@ class WindowToken extends WindowContainer<WindowState> { // cleared and the configuration is restored from parent. if (!changed) { clearFixedRotationTransform(null /* applyDisplayRotation */); onConfigurationChanged(getParent().getConfiguration()); } } /** * Clears the transform and apply display rotation if the action is given. The caller needs to * refresh the configuration of this container after this method call. * Clears the transform and apply display rotation if the action is given. If the display will * not rotate, the transformed containers are restored to their original states. */ void clearFixedRotationTransform(Runnable applyDisplayRotation) { final FixedRotationTransformState state = mFixedRotationTransformState; Loading @@ -574,6 +573,12 @@ class WindowToken extends WindowContainer<WindowState> { state.mIsTransforming = false; if (applyDisplayRotation != null) { applyDisplayRotation.run(); } else { // The display will not rotate to the rotation of this container, let's cancel them. for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) { state.mAssociatedTokens.get(i).cancelFixedRotationTransform(); } cancelFixedRotationTransform(); } // The state is cleared at the end, because it is used to indicate that other windows can // use seamless rotation when applying rotation to display. Loading @@ -583,6 +588,16 @@ class WindowToken extends WindowContainer<WindowState> { mFixedRotationTransformState = null; } /** Restores the changes that applies to this container. */ private void cancelFixedRotationTransform() { final WindowContainer<?> parent = getParent(); if (parent == null) { // The window may be detached or detaching. return; } onConfigurationChanged(parent.getConfiguration()); } @Override void resolveOverrideConfiguration(Configuration newParentConfig) { super.resolveOverrideConfiguration(newParentConfig); Loading services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import android.content.res.Configuration; import android.os.IBinder; import android.platform.test.annotations.Presubmit; Loading Loading @@ -134,6 +135,30 @@ public class WindowTokenTests extends WindowTestsBase { assertEquals(0, token.getWindowsCount()); } @Test public void testClearFixedRotationTransform() { final WindowToken appToken = mAppWindow.mToken; final WindowToken wallpaperToken = mWallpaperWindow.mToken; final Configuration config = new Configuration(mDisplayContent.getConfiguration()); final int originalRotation = config.windowConfiguration.getRotation(); final int targetRotation = (originalRotation + 1) % 4; config.windowConfiguration.setRotation(targetRotation); appToken.applyFixedRotationTransform(mDisplayInfo, mDisplayContent.mDisplayFrames, config); wallpaperToken.linkFixedRotationTransform(appToken); // The window tokens should apply the rotation by the transformation. assertEquals(targetRotation, appToken.getWindowConfiguration().getRotation()); assertEquals(targetRotation, wallpaperToken.getWindowConfiguration().getRotation()); // The display doesn't rotate, the transformation will be canceled. mAppWindow.mToken.clearFixedRotationTransform(null /* applyDisplayRotation */); // The window tokens should restore to the original rotation. assertEquals(originalRotation, appToken.getWindowConfiguration().getRotation()); assertEquals(originalRotation, wallpaperToken.getWindowConfiguration().getRotation()); } /** * Test that {@link WindowToken} constructor parameters is set with expectation. */ Loading Loading
services/core/java/com/android/server/wm/WindowToken.java +18 −3 Original line number Diff line number Diff line Loading @@ -554,13 +554,12 @@ class WindowToken extends WindowContainer<WindowState> { // cleared and the configuration is restored from parent. if (!changed) { clearFixedRotationTransform(null /* applyDisplayRotation */); onConfigurationChanged(getParent().getConfiguration()); } } /** * Clears the transform and apply display rotation if the action is given. The caller needs to * refresh the configuration of this container after this method call. * Clears the transform and apply display rotation if the action is given. If the display will * not rotate, the transformed containers are restored to their original states. */ void clearFixedRotationTransform(Runnable applyDisplayRotation) { final FixedRotationTransformState state = mFixedRotationTransformState; Loading @@ -574,6 +573,12 @@ class WindowToken extends WindowContainer<WindowState> { state.mIsTransforming = false; if (applyDisplayRotation != null) { applyDisplayRotation.run(); } else { // The display will not rotate to the rotation of this container, let's cancel them. for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) { state.mAssociatedTokens.get(i).cancelFixedRotationTransform(); } cancelFixedRotationTransform(); } // The state is cleared at the end, because it is used to indicate that other windows can // use seamless rotation when applying rotation to display. Loading @@ -583,6 +588,16 @@ class WindowToken extends WindowContainer<WindowState> { mFixedRotationTransformState = null; } /** Restores the changes that applies to this container. */ private void cancelFixedRotationTransform() { final WindowContainer<?> parent = getParent(); if (parent == null) { // The window may be detached or detaching. return; } onConfigurationChanged(parent.getConfiguration()); } @Override void resolveOverrideConfiguration(Configuration newParentConfig) { super.resolveOverrideConfiguration(newParentConfig); Loading
services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import android.content.res.Configuration; import android.os.IBinder; import android.platform.test.annotations.Presubmit; Loading Loading @@ -134,6 +135,30 @@ public class WindowTokenTests extends WindowTestsBase { assertEquals(0, token.getWindowsCount()); } @Test public void testClearFixedRotationTransform() { final WindowToken appToken = mAppWindow.mToken; final WindowToken wallpaperToken = mWallpaperWindow.mToken; final Configuration config = new Configuration(mDisplayContent.getConfiguration()); final int originalRotation = config.windowConfiguration.getRotation(); final int targetRotation = (originalRotation + 1) % 4; config.windowConfiguration.setRotation(targetRotation); appToken.applyFixedRotationTransform(mDisplayInfo, mDisplayContent.mDisplayFrames, config); wallpaperToken.linkFixedRotationTransform(appToken); // The window tokens should apply the rotation by the transformation. assertEquals(targetRotation, appToken.getWindowConfiguration().getRotation()); assertEquals(targetRotation, wallpaperToken.getWindowConfiguration().getRotation()); // The display doesn't rotate, the transformation will be canceled. mAppWindow.mToken.clearFixedRotationTransform(null /* applyDisplayRotation */); // The window tokens should restore to the original rotation. assertEquals(originalRotation, appToken.getWindowConfiguration().getRotation()); assertEquals(originalRotation, wallpaperToken.getWindowConfiguration().getRotation()); } /** * Test that {@link WindowToken} constructor parameters is set with expectation. */ Loading