Do not allow Tasks to influence orientation under some conditions.
When all AppWindowTokens belonging to a Task are closing, it should
not be considered for orientation. Likewise, if a task is moving to
the bottom, it should also not be considered.
Change-Id: Ie387457c413d5360afbb0ac8edb112f81feab81b
Fixes: 35699615
Test: bit FrameworksServicesTests:com.android.server.wm.TaskStackTests#testClosingAppDifferentStackOrientation
Test: bit FrameworksServicesTests:com.android.server.wm.TaskStackTests#testMoveTaskToBackDifferentStackOrientation
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerAppConfigurationTests#testTaskCloseRestoreOrientation
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.ActivityManagerAppConfigurationTests#testTaskMoveToBackOrientation
diff --git a/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java
index 1c69033..3ce3df1 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java
@@ -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;
@@ -23,6 +26,9 @@
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;
@@ -58,6 +64,42 @@
}
@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);
final Task task = createTaskInStack(stack, 0 /* userId */);