OSDN Git Service

Fix minor issues discovered with Multi-Display tests
authorAndrii Kulian <akulian@google.com>
Fri, 11 Nov 2016 19:14:12 +0000 (11:14 -0800)
committerAndrii Kulian <akulian@google.com>
Tue, 15 Nov 2016 18:29:25 +0000 (18:29 +0000)
- NPE when launching activity on secondary display
and there is a docked stack on primary.
- Activities not finished correctly on secondary display
when it is removed.

Change-Id: If527211e8192088790d32b9673b960535e27033f
Test: See ActivityManagerDisplayTests.

services/core/java/com/android/server/am/ActivityStackSupervisor.java
services/core/java/com/android/server/am/ActivityStarter.java
services/core/java/com/android/server/wm/DisplayContent.java

index 1cbb52f..539ac16 100644 (file)
@@ -3564,7 +3564,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer
             if (activityDisplay != null) {
                 ArrayList<ActivityStack> stacks = activityDisplay.mStacks;
                 for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
-                    stacks.get(stackNdx).mActivityContainer.removeLocked();
+                    final ActivityStack stack = stacks.get(stackNdx);
+                    // TODO: Implement proper stack removal and ability to choose the behavior -
+                    // remove stack completely or move it to other display.
+                    moveStackToDisplayLocked(stack.mStackId, DEFAULT_DISPLAY);
                 }
                 mActivityDisplays.remove(displayId);
             }
@@ -4215,7 +4218,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer
             }
         }
 
-        /** Remove the stack completely. */
+        /**
+         * Remove the stack completely. Must be called only when there are no tasks left in it,
+         * as this method does not finish running activities.
+         */
         void removeLocked() {
             if (DEBUG_STACK) Slog.d(TAG_STACK, "removeLocked: " + this + " from display="
                     + mActivityDisplay + " Callers=" + Debug.getCallers(2));
index c96e74f..709c3d0 100644 (file)
@@ -257,11 +257,7 @@ class ActivityStarter {
 
         if (err == ActivityManager.START_SUCCESS) {
             Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false)
-                    + "} from uid " + callingUid
-                    + " on display " + (container == null ? (mSupervisor.mFocusedStack == null ?
-                    Display.DEFAULT_DISPLAY : mSupervisor.mFocusedStack.mDisplayId) :
-                    (container.mActivityDisplay == null ? Display.DEFAULT_DISPLAY :
-                            container.mActivityDisplay.mDisplayId)));
+                    + "} from uid " + callingUid);
         }
 
         ActivityRecord sourceRecord = null;
index c8e35eb..e73acde 100644 (file)
@@ -727,7 +727,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
             win.getTouchableRegion(mTmpRegion);
             mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION);
         }
-        if (getDockedStackLocked() != null) {
+        // TODO(multi-display): Support docked stacks on secondary displays.
+        if (mDisplayId == DEFAULT_DISPLAY && getDockedStackLocked() != null) {
             mDividerControllerLocked.getTouchRegion(mTmpRect);
             mTmpRegion.set(mTmpRect);
             mTouchExcludeRegion.op(mTmpRegion, Op.UNION);