OSDN Git Service

Prevent cleaning up and resuming null activity when task is reparented.
authorWinson Chung <winsonc@google.com>
Fri, 24 Mar 2017 16:20:17 +0000 (09:20 -0700)
committerWinson Chung <winsonc@google.com>
Fri, 24 Mar 2017 16:20:17 +0000 (09:20 -0700)
- If reparenting a task with no running activities, ensure that we don't
  try to clean up the null activity record from the stack.  In addition,
  once the task is reparented, skip the attempt to front if the activity
  is null.

Bug: 36508639
Test: android.server.cts.ActivityManagerPinnedStackTests
Change-Id: I58d4d600523ac263d0be1ee8d09cfc4d94bef664

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

index a668fea..bd32df3 100644 (file)
@@ -617,15 +617,15 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta
         boolean kept = true;
         try {
             final ActivityRecord r = topRunningActivityLocked();
-            final boolean wasFocused = supervisor.isFocusedStack(sourceStack)
+            final boolean wasFocused = r != null && supervisor.isFocusedStack(sourceStack)
                     && (topRunningActivityLocked() == r);
-            final boolean wasResumed = sourceStack.mResumedActivity == r;
-            final boolean wasPaused = sourceStack.mPausingActivity == r;
+            final boolean wasResumed = r != null && sourceStack.mResumedActivity == r;
+            final boolean wasPaused = r != null && sourceStack.mPausingActivity == r;
 
             // In some cases the focused stack isn't the front stack. E.g. pinned stack.
             // Whenever we are moving the top activity from the front stack we want to make sure to
             // move the stack to the front.
-            final boolean wasFront = supervisor.isFrontStackOnDisplay(sourceStack)
+            final boolean wasFront = r != null && supervisor.isFrontStackOnDisplay(sourceStack)
                     && (sourceStack.topRunningActivityLocked() == r);
 
             // Adjust the position for the new parent stack as needed.
@@ -667,8 +667,10 @@ final class TaskRecord extends ConfigurationContainer implements TaskWindowConta
             // new stack by moving the stack to the front.
             final boolean moveStackToFront = moveStackMode == REPARENT_MOVE_STACK_TO_FRONT
                     || (moveStackMode == REPARENT_KEEP_STACK_AT_FRONT && (wasFocused || wasFront));
-            toStack.moveToFrontAndResumeStateIfNeeded(r, moveStackToFront, wasResumed, wasPaused,
-                    reason);
+            if (r != null) {
+                toStack.moveToFrontAndResumeStateIfNeeded(r, moveStackToFront, wasResumed,
+                        wasPaused, reason);
+            }
             if (!animate) {
                 toStack.mNoAnimActivities.add(topActivity);
             }