Loading services/core/java/com/android/server/wm/AppWindowToken.java +6 −1 Original line number Diff line number Diff line Loading @@ -1172,7 +1172,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree */ @Override int getOrientation() { if (fillsParent() && (isVisible() || mService.mOpeningApps.contains(this))) { // The {@link AppWindowToken} should only specify an orientation when it is not closing or // going to the bottom. Allowing closing {@link AppWindowToken} to participate can lead to // an Activity in another task being started in the wrong orientation during the transition. if (fillsParent() && !(sendingToBottom || mService.mClosingApps.contains(this)) && (isVisible() || mService.mOpeningApps.contains(this))) { return mOrientation; } Loading services/core/java/com/android/server/wm/Task.java +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static com.android.server.EventLogTags.WM_TASK_REMOVED; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT; Loading Loading @@ -107,6 +108,9 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU setController(controller); setBounds(bounds, overrideConfig); mTaskDescription = taskDescription; // Tasks have no set orientation value (including SCREEN_ORIENTATION_UNSPECIFIED). setOrientation(SCREEN_ORIENTATION_UNSET); } DisplayContent getDisplayContent() { Loading services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java +42 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.wm; import android.content.pm.ActivityInfo; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -23,6 +26,9 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading Loading @@ -57,6 +63,42 @@ public class TaskStackTests extends WindowTestsBase { assertEquals(stack.mChildren.get(1), task1); } @Test public void testClosingAppDifferentStackOrientation() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); final Task task1 = createTaskInStack(stack, 0 /* userId */); TestAppWindowToken appWindowToken1 = new TestAppWindowToken(sDisplayContent); task1.addChild(appWindowToken1, 0); appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); final Task task2 = createTaskInStack(stack, 1 /* userId */); TestAppWindowToken appWindowToken2 = new TestAppWindowToken(sDisplayContent); task2.addChild(appWindowToken2, 0); appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_PORTRAIT); sWm.mClosingApps.add(appWindowToken2); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testMoveTaskToBackDifferentStackOrientation() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); final Task task1 = createTaskInStack(stack, 0 /* userId */); TestAppWindowToken appWindowToken1 = new TestAppWindowToken(sDisplayContent); task1.addChild(appWindowToken1, 0); appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); final Task task2 = createTaskInStack(stack, 1 /* userId */); TestAppWindowToken appWindowToken2 = new TestAppWindowToken(sDisplayContent); task2.addChild(appWindowToken2, 0); appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_PORTRAIT); task2.setSendingToBottom(true); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testStackRemoveImmediately() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); Loading Loading
services/core/java/com/android/server/wm/AppWindowToken.java +6 −1 Original line number Diff line number Diff line Loading @@ -1172,7 +1172,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree */ @Override int getOrientation() { if (fillsParent() && (isVisible() || mService.mOpeningApps.contains(this))) { // The {@link AppWindowToken} should only specify an orientation when it is not closing or // going to the bottom. Allowing closing {@link AppWindowToken} to participate can lead to // an Activity in another task being started in the wrong orientation during the transition. if (fillsParent() && !(sendingToBottom || mService.mClosingApps.contains(this)) && (isVisible() || mService.mOpeningApps.contains(this))) { return mOrientation; } Loading
services/core/java/com/android/server/wm/Task.java +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static com.android.server.EventLogTags.WM_TASK_REMOVED; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT; Loading Loading @@ -107,6 +108,9 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU setController(controller); setBounds(bounds, overrideConfig); mTaskDescription = taskDescription; // Tasks have no set orientation value (including SCREEN_ORIENTATION_UNSPECIFIED). setOrientation(SCREEN_ORIENTATION_UNSET); } DisplayContent getDisplayContent() { Loading
services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java +42 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.wm; import android.content.pm.ActivityInfo; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -23,6 +26,9 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; Loading Loading @@ -57,6 +63,42 @@ public class TaskStackTests extends WindowTestsBase { assertEquals(stack.mChildren.get(1), task1); } @Test public void testClosingAppDifferentStackOrientation() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); final Task task1 = createTaskInStack(stack, 0 /* userId */); TestAppWindowToken appWindowToken1 = new TestAppWindowToken(sDisplayContent); task1.addChild(appWindowToken1, 0); appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); final Task task2 = createTaskInStack(stack, 1 /* userId */); TestAppWindowToken appWindowToken2 = new TestAppWindowToken(sDisplayContent); task2.addChild(appWindowToken2, 0); appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_PORTRAIT); sWm.mClosingApps.add(appWindowToken2); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testMoveTaskToBackDifferentStackOrientation() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); final Task task1 = createTaskInStack(stack, 0 /* userId */); TestAppWindowToken appWindowToken1 = new TestAppWindowToken(sDisplayContent); task1.addChild(appWindowToken1, 0); appWindowToken1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); final Task task2 = createTaskInStack(stack, 1 /* userId */); TestAppWindowToken appWindowToken2 = new TestAppWindowToken(sDisplayContent); task2.addChild(appWindowToken2, 0); appWindowToken2.setOrientation(SCREEN_ORIENTATION_PORTRAIT); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_PORTRAIT); task2.setSendingToBottom(true); assertEquals(stack.getOrientation(), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testStackRemoveImmediately() throws Exception { final TaskStack stack = createTaskStackOnDisplay(sDisplayContent); Loading