OSDN Git Service

Fixing issue where affiliated task last-active-times were inconsistent.
authorWinson <winsonc@google.com>
Fri, 1 Apr 2016 01:04:56 +0000 (18:04 -0700)
committerWinson Chung <winsonc@google.com>
Fri, 1 Apr 2016 18:29:05 +0000 (18:29 +0000)
- We rely on the last-active-times of the task records to order tasks
  in Recents, but for affiliated tasks, their last-active-time was never
  set until the task was launched.  This change just ensures that all
  tasks have a valid last-active-time, and for affiliated tasks, ensures
  that the task that they were launched behind always has a later
  last-active-time.

Bug: 27597746
Change-Id: I9692c2b48ac6d12266de90bdf423f689402a94c2

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

index 0d70e99..811b48f 100644 (file)
@@ -2738,12 +2738,21 @@ public final class ActivityStackSupervisor implements DisplayListener {
 
     // Called when WindowManager has finished animating the launchingBehind activity to the back.
     void handleLaunchTaskBehindCompleteLocked(ActivityRecord r) {
-        r.mLaunchTaskBehind = false;
         final TaskRecord task = r.task;
-        task.setLastThumbnailLocked(task.stack.screenshotActivitiesLocked(r));
+        final ActivityStack stack = task.stack;
+
+        r.mLaunchTaskBehind = false;
+        task.setLastThumbnailLocked(stack.screenshotActivitiesLocked(r));
         mRecentTasks.addLocked(task);
         mService.notifyTaskStackChangedLocked();
         mWindowManager.setAppVisibility(r.appToken, false);
+
+        // When launching tasks behind, update the last active time of the top task after the new
+        // task has been shown briefly
+        final ActivityRecord top = stack.topActivity();
+        if (top != null) {
+            top.task.touchActiveTime();
+        }
     }
 
     void scheduleLaunchTaskBehindComplete(IBinder token) {
index b157070..e32d1d1 100644 (file)
@@ -285,6 +285,7 @@ final class TaskRecord {
         mCallingPackage = info.packageName;
         setIntent(_intent, info);
         setMinDimensions(info);
+        touchActiveTime();
     }
 
     TaskRecord(ActivityManagerService service, int _taskId, ActivityInfo info, Intent _intent,
@@ -315,6 +316,7 @@ final class TaskRecord {
         taskType = APPLICATION_ACTIVITY_TYPE;
         mTaskToReturnTo = HOME_ACTIVITY_TYPE;
         lastTaskDescription = _taskDescription;
+        touchActiveTime();
     }
 
     private TaskRecord(ActivityManagerService service, int _taskId, Intent _intent,