OSDN Git Service

Consider stack invisible if it got no running apps.
authorChong Zhang <chz@google.com>
Fri, 13 Nov 2015 01:22:40 +0000 (17:22 -0800)
committerChong Zhang <chz@google.com>
Fri, 13 Nov 2015 01:30:04 +0000 (17:30 -0800)
When we close an freeform app by X button while an app is docked on
the other side, ActivityStack.ensureActivitiesVisibleLocked() failed
to make home stack visible, because it's under the freeform stack
which only contains one finishing activity.

We usually will not do another round of ensureActivitiesVisibleLocked
when the activity is destroyed. Need to make sure visibility is adjusted
to the stack below when we start finishing the last app in a stack.

bug: 25668050
Change-Id: Id2a23cb9480221a4e55ba3be9eab51f6efd8a700

services/core/java/com/android/server/am/ActivityStack.java

index ba6e9b1..64699c9 100644 (file)
@@ -1338,7 +1338,12 @@ final class ActivityStack {
             return topHomeActivity == null || !topHomeActivity.isHomeActivity();
         }
 
-        final int belowFocusedIndex = mStacks.indexOf(focusedStack) - 1;
+        // Find the first stack below focused stack that actually got something visible.
+        int belowFocusedIndex = mStacks.indexOf(focusedStack) - 1;
+        while (belowFocusedIndex >= 0 &&
+                mStacks.get(belowFocusedIndex).topRunningActivityLocked() == null) {
+            belowFocusedIndex--;
+        }
         if ((focusedStackId == DOCKED_STACK_ID || focusedStackId == PINNED_STACK_ID)
                 && stackIndex == belowFocusedIndex) {
             // Stacks directly behind the docked or pinned stack are always visible.