OSDN Git Service

Bring task with root activity to front when launching from recents.
authorWale Ogunwale <ogunwale@google.com>
Wed, 7 Jan 2015 00:45:04 +0000 (16:45 -0800)
committerWale Ogunwale <ogunwale@google.com>
Wed, 7 Jan 2015 00:45:04 +0000 (16:45 -0800)
Change makes sure we cover all cases where a task should be brought
to front if it already has a root activity and we are launching
from recents.

Bug: 18846206
Change-Id: I2e67a4c163c5a5ed6784ed620583f85d9c6ed731

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

index 022ef44..ed16d2e 100755 (executable)
@@ -3619,6 +3619,10 @@ public final class ActivityManagerService extends ActivityManagerNative
             if (task == null) {
                 throw new IllegalArgumentException("Task " + taskId + " not found.");
             }
+            if (task.getRootActivity() != null) {
+                moveTaskToFrontLocked(task.taskId, 0, null);
+                return ActivityManager.START_TASK_TO_FRONT;
+            }
             callingUid = task.mCallingUid;
             callingPackage = task.mCallingPackage;
             intent = task.intent;
@@ -19443,20 +19447,8 @@ public final class ActivityManagerService extends ActivityManagerNative
         @Override
         public void moveToFront() {
             checkCaller();
-
-            final TaskRecord tr;
-            synchronized (ActivityManagerService.this) {
-                tr = recentTaskForIdLocked(mTaskId);
-                if (tr == null) {
-                    throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
-                }
-                if (tr.getRootActivity() != null) {
-                    moveTaskToFrontLocked(tr.taskId, 0, null);
-                    return;
-                }
-            }
-
-            startActivityFromRecentsInner(tr.taskId, null);
+            // Will bring task to front if it already has a root activity.
+            startActivityFromRecentsInner(mTaskId, null);
         }
 
         @Override