OSDN Git Service

Exit split-screen when primary stack moved behind a fullscreen stack.
authorBryce Lee <brycelee@google.com>
Fri, 5 Jan 2018 17:00:49 +0000 (09:00 -0800)
committerBryce Lee <brycelee@google.com>
Mon, 8 Jan 2018 18:14:00 +0000 (10:14 -0800)
Activities can request their task be moved to the back of the stack,
which subsequently causes the stack to move as well. When the stack
is a split screen primary stack, this causes an ordering issue where
the secondary will not move back while a fullscreen stack has moved
in front of the primary. This leads to further ordering issues once
the front secondary is dismissed as other stacks are also in the
secondary windowing mode.

To address this issue, we exit split-screen mode when the primary
split-screen stack is moved back.

Test: atest ActivityStackTests#testPrimarySplitScreenToFullscreenWhenMovedToBack
Change-Id: Ic0597831e046a254b3cba216e1cb2fb11191f2c6
Fixes: 69662547

services/core/java/com/android/server/am/ActivityStack.java
services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java

index 10c801d..e9fa20c 100644 (file)
@@ -1013,6 +1013,14 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
             return;
         }
 
+        /**
+         * The intent behind moving a primary split screen stack to the back is usually to hide
+         * behind the home stack. Exit split screen in this case.
+         */
+        if (getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
+            setWindowingMode(WINDOWING_MODE_FULLSCREEN);
+        }
+
         getDisplay().positionChildAtBottom(this);
         mStackSupervisor.setFocusStackUnchecked(reason, getDisplay().getTopStack());
         if (task != null) {
index 6b09363..bcbf40e 100644 (file)
@@ -47,7 +47,7 @@ import org.junit.Test;
  * Tests for the {@link ActivityStack} class.
  *
  * Build/Install/Run:
- *  bit FrameworksServicesTests:com.android.server.am.ActivityStackTests
+ *  atest ActivityStackTests
  */
 @SmallTest
 @Presubmit
@@ -104,6 +104,29 @@ public class ActivityStackTests extends ActivityTestsBase {
     }
 
     @Test
+    public void testPrimarySplitScreenToFullscreenWhenMovedToBack() throws Exception {
+        // Create primary splitscreen stack. This will create secondary stacks and places the
+        // existing fullscreen stack on the bottom.
+        final ActivityStack primarySplitScreen = mService.mStackSupervisor.getDefaultDisplay()
+                .createStack(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_STANDARD,
+                        true /* onTop */);
+
+        // Assert windowing mode.
+        assertEquals(primarySplitScreen.getWindowingMode(), WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+
+        // Move primary to back.
+        primarySplitScreen.moveToBack("testPrimarySplitScreenToFullscreenWhenMovedToBack",
+                null /* task */);
+
+        // Assert that stack is at the bottom.
+        assertEquals(mService.mStackSupervisor.getDefaultDisplay().getIndexOf(primarySplitScreen),
+                0);
+
+        // Ensure no longer in splitscreen.
+        assertEquals(primarySplitScreen.getWindowingMode(), WINDOWING_MODE_FULLSCREEN);
+    }
+
+    @Test
     public void testStopActivityWhenActivityDestroyed() throws Exception {
         final ActivityRecord r = new ActivityBuilder(mService).setTask(mTask).build();
         r.info.flags |= ActivityInfo.FLAG_NO_HISTORY;