summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityManager.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsService.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java112
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java (renamed from packages/SystemUI/src/com/android/systemui/recents/RecentsPackageMonitor.java)3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java (renamed from packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java)106
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java4
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java1
-rw-r--r--services/core/java/com/android/server/am/TaskRecord.java16
14 files changed, 258 insertions, 85 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 788ac56a0d10..88746bf47bdc 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -652,6 +652,12 @@ public class ActivityManager {
public int userId;
/**
+ * The last time this task was active.
+ * @hide
+ */
+ public long lastActiveTime;
+
+ /**
* The recent activity values for the highest activity in the stack to have set the values.
* {@link Activity#setTaskDescription(android.app.ActivityManager.TaskDescription)}.
*
@@ -688,6 +694,7 @@ public class ActivityManager {
}
dest.writeInt(stackId);
dest.writeInt(userId);
+ dest.writeLong(lastActiveTime);
}
public void readFromParcel(Parcel source) {
@@ -700,6 +707,7 @@ public class ActivityManager {
TaskDescription.CREATOR.createFromParcel(source) : null;
stackId = source.readInt();
userId = source.readInt();
+ lastActiveTime = source.readLong();
}
public static final Creator<RecentTaskInfo> CREATOR
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 52a17df3b5df..dfc075014c10 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -32,6 +32,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.ViewStub;
import com.android.systemui.R;
+import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.SpaceNode;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.FullscreenTransitionOverlayView;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java
index d55eba7b2c8c..375434025606 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsAppWidgetHost.java
@@ -19,6 +19,7 @@ package com.android.systemui.recents;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
+import com.android.systemui.recents.model.RecentsTaskLoader;
/** Our special app widget host for the Search widget */
public class RecentsAppWidgetHost extends AppWidgetHost {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
index e554af7cf187..e40d73232c83 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
@@ -26,6 +26,7 @@ import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
+import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.TaskStackView;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java
new file mode 100644
index 000000000000..1344729001c2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.model;
+
+import android.graphics.Bitmap;
+
+/**
+ * The Bitmap LRU cache.
+ */
+class BitmapLruCache extends KeyStoreLruCache<Bitmap> {
+ public BitmapLruCache(int cacheSize) {
+ super(cacheSize);
+ }
+
+ @Override
+ protected int computeSize(Bitmap b) {
+ // The cache size will be measured in kilobytes rather than number of items
+ return b.getAllocationByteCount() / 1024;
+ }
+} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java
new file mode 100644
index 000000000000..61d19da86d26
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.model;
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * The Drawable LRU cache.
+ */
+class DrawableLruCache extends KeyStoreLruCache<Drawable> {
+ public DrawableLruCache(int cacheSize) {
+ super(cacheSize);
+ }
+
+ @Override
+ protected int computeSize(Drawable d) {
+ // The cache size will be measured in kilobytes rather than number of items
+ // NOTE: this isn't actually correct, as the icon may be smaller
+ int maxBytes = (d.getIntrinsicWidth() * d.getIntrinsicHeight() * 4);
+ return maxBytes / 1024;
+ }
+} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
new file mode 100644
index 000000000000..3ccca9a2e944
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.model;
+
+import android.util.LruCache;
+
+import java.util.HashMap;
+
+/**
+ * An LRU cache that support querying the keys as well as values. By using the Task's key, we can
+ * prevent holding onto a reference to the Task resource data, while keeping the cache data in
+ * memory where necessary.
+ */
+public class KeyStoreLruCache<V> {
+ // We keep a set of keys that are associated with the LRU cache, so that we can find out
+ // information about the Task that was previously in the cache.
+ HashMap<Task.TaskKey, Task.TaskKey> mKeys = new HashMap<Task.TaskKey, Task.TaskKey>();
+ // The cache implementation
+ LruCache<Task.TaskKey, V> mCache;
+
+ public KeyStoreLruCache(int cacheSize) {
+ mCache = new LruCache<Task.TaskKey, V>(cacheSize) {
+ @Override
+ protected int sizeOf(Task.TaskKey t, V v) {
+ return computeSize(v);
+ }
+
+ @Override
+ protected void entryRemoved(boolean evicted, Task.TaskKey key, V oldV, V newV) {
+ mKeys.remove(key);
+ }
+ };
+ }
+
+ /** Computes the size of a value. */
+ protected int computeSize(V value) {
+ return 0;
+ }
+
+ /** Gets a specific entry in the cache. */
+ final V get(Task.TaskKey key) {
+ return mCache.get(key);
+ }
+
+ /**
+ * Returns the value only if the last active time of the key currently in the lru cache is
+ * greater than or equal to the last active time of the key specified.
+ */
+ final V getCheckLastActiveTime(Task.TaskKey key) {
+ Task.TaskKey lruKey = mKeys.get(key);
+ if (lruKey != null && (lruKey.lastActiveTime < key.lastActiveTime)) {
+ // The task has changed (been made active since the last time it was put into the
+ // LRU cache) so invalidate that item in the cache
+ remove(lruKey);
+ return null;
+ }
+ // Either the task does not exist in the cache, or the last active time is the same as
+ // the key specified
+ return mCache.get(key);
+ }
+
+ /** Gets the previous task key that matches the specified key. */
+ final Task.TaskKey getKey(Task.TaskKey key) {
+ return mKeys.get(key);
+ }
+
+ /** Puts an entry in the cache for a specific key. */
+ final void put(Task.TaskKey key, V value) {
+ mCache.put(key, value);
+ if (mKeys.containsKey(key)) {
+ mKeys.get(key).updateLastActiveTime(key.lastActiveTime);
+ } else {
+ mKeys.put(key, key);
+ }
+ }
+
+ /** Removes a cache entry for a specific key. */
+ final void remove(Task.TaskKey key) {
+ mCache.remove(key);
+ mKeys.remove(key);
+ }
+
+ /** Removes all the entries in the cache. */
+ final void evictAll() {
+ mCache.evictAll();
+ mKeys.clear();
+ }
+
+ /** Returns the size of the cache. */
+ final int size() {
+ return mCache.size();
+ }
+
+ /** Trims the cache to a specific size */
+ final void trimToSize(int cacheSize) {
+ mCache.resize(cacheSize);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsPackageMonitor.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java
index 04d1f1f151ee..cbe39e3609aa 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsPackageMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsPackageMonitor.java
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-package com.android.systemui.recents;
+package com.android.systemui.recents.model;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.Looper;
import com.android.internal.content.PackageMonitor;
+import com.android.systemui.recents.SystemServicesProxy;
import java.util.HashSet;
import java.util.List;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
index 07a6a562100b..a07670b54443 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.recents;
+package com.android.systemui.recents.model;
import android.app.ActivityManager;
import android.content.ComponentCallbacks2;
@@ -27,11 +27,10 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.UserHandle;
-import android.util.LruCache;
import android.util.Pair;
-import com.android.systemui.recents.model.SpaceNode;
-import com.android.systemui.recents.model.Task;
-import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.recents.Console;
+import com.android.systemui.recents.Constants;
+import com.android.systemui.recents.SystemServicesProxy;
import java.util.ArrayList;
import java.util.Collections;
@@ -204,8 +203,8 @@ class TaskResourceLoader implements Runnable {
final Task t = nextTaskData.first;
final boolean forceLoadTask = nextTaskData.second;
if (t != null) {
- Drawable loadIcon = mApplicationIconCache.get(t.key);
- Bitmap loadThumbnail = mThumbnailCache.get(t.key);
+ Drawable loadIcon = mApplicationIconCache.getCheckLastActiveTime(t.key);
+ Bitmap loadThumbnail = mThumbnailCache.getCheckLastActiveTime(t.key);
if (Console.Enabled) {
Console.log(Constants.Log.App.TaskDataLoader,
" [TaskResourceLoader|load]",
@@ -282,40 +281,6 @@ class TaskResourceLoader implements Runnable {
}
}
-/**
- * The drawable cache. By using the Task's key, we can prevent holding onto a reference to the Task
- * resource data, while keeping the cache data in memory where necessary.
- */
-class DrawableLruCache extends LruCache<Task.TaskKey, Drawable> {
- public DrawableLruCache(int cacheSize) {
- super(cacheSize);
- }
-
- @Override
- protected int sizeOf(Task.TaskKey t, Drawable d) {
- // The cache size will be measured in kilobytes rather than number of items
- // NOTE: this isn't actually correct, as the icon may be smaller
- int maxBytes = (d.getIntrinsicWidth() * d.getIntrinsicHeight() * 4);
- return maxBytes / 1024;
- }
-}
-
-/**
- * The bitmap cache. By using the Task's key, we can prevent holding onto a reference to the Task
- * resource data, while keeping the cache data in memory where necessary.
- */
-class BitmapLruCache extends LruCache<Task.TaskKey, Bitmap> {
- public BitmapLruCache(int cacheSize) {
- super(cacheSize);
- }
-
- @Override
- protected int sizeOf(Task.TaskKey t, Bitmap bitmap) {
- // The cache size will be measured in kilobytes rather than number of items
- return bitmap.getAllocationByteCount() / 1024;
- }
-}
-
/* Recents task loader
* NOTE: We should not hold any references to a Context from a static instance */
public class RecentsTaskLoader {
@@ -417,7 +382,7 @@ public class RecentsTaskLoader {
}
/** Reload the set of recent tasks */
- SpaceNode reload(Context context, int preloadCount) {
+ public SpaceNode reload(Context context, int preloadCount) {
long t1 = System.currentTimeMillis();
if (Console.Enabled) {
@@ -456,7 +421,7 @@ public class RecentsTaskLoader {
// Create a new task
Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, activityLabel,
- activityIcon, activityColor, t.userId);
+ activityIcon, activityColor, t.userId, t.lastActiveTime);
// Preload the specified number of apps
if (i >= (taskCount - preloadCount)) {
@@ -466,45 +431,44 @@ public class RecentsTaskLoader {
"i: " + i + " task: " + t.baseIntent.getComponent().getPackageName());
}
- // Load the icon (if possible and not the foremost task, from the cache)
- if (!isForemostTask) {
- task.applicationIcon = mApplicationIconCache.get(task.key);
- if (task.applicationIcon != null) {
- // Even though we get things from the cache, we should update them
- // if they've changed in the bg
- tasksToForceLoad.add(task);
- }
- }
+ // Load the icon from the cache if possible
+ task.applicationIcon = mApplicationIconCache.getCheckLastActiveTime(task.key);
if (task.applicationIcon == null) {
- task.applicationIcon = ssp.getActivityIcon(info, task.userId);
- if (task.applicationIcon != null) {
- mApplicationIconCache.put(task.key, task.applicationIcon);
+ if (isForemostTask) {
+ // We force loading the application icon for the foremost task
+ task.applicationIcon = ssp.getActivityIcon(info, task.userId);
+ if (task.applicationIcon != null) {
+ mApplicationIconCache.put(task.key, task.applicationIcon);
+ } else {
+ task.applicationIcon = mDefaultApplicationIcon;
+ }
} else {
- task.applicationIcon = mDefaultApplicationIcon;
+ // Either the task has updated, or we haven't cached any information for the
+ // task, so reload it
+ tasksToForceLoad.add(task);
}
}
// Load the thumbnail (if possible and not the foremost task, from the cache)
- if (!isForemostTask) {
- task.thumbnail = mThumbnailCache.get(task.key);
- if (task.thumbnail != null && !tasksToForceLoad.contains(task)) {
- // Even though we get things from the cache, we should update them if
- // they've changed in the bg
- tasksToForceLoad.add(task);
- }
- }
+ task.thumbnail = mThumbnailCache.getCheckLastActiveTime(task.key);
if (task.thumbnail == null) {
if (Console.Enabled) {
Console.log(Constants.Log.App.TaskDataLoader,
"[RecentsTaskLoader|loadingTaskThumbnail]");
}
-
- task.thumbnail = ssp.getTaskThumbnail(task.key.id);
- if (task.thumbnail != null) {
- task.thumbnail.setHasAlpha(false);
- mThumbnailCache.put(task.key, task.thumbnail);
+ if (isForemostTask) {
+ // We force loading the thumbnail icon for the foremost task
+ task.thumbnail = ssp.getTaskThumbnail(task.key.id);
+ if (task.thumbnail != null) {
+ task.thumbnail.setHasAlpha(false);
+ mThumbnailCache.put(task.key, task.thumbnail);
+ } else {
+ task.thumbnail = mDefaultThumbnail;
+ }
} else {
- task.thumbnail = mDefaultThumbnail;
+ // Either the task has updated, or we haven't cached any information for the
+ // task, so reload it
+ tasksToForceLoad.add(task);
}
}
}
@@ -613,7 +577,7 @@ public class RecentsTaskLoader {
* Handles signals from the system, trimming memory when requested to prevent us from running
* out of memory.
*/
- void onTrimMemory(int level) {
+ public void onTrimMemory(int level) {
if (Console.Enabled) {
Console.log(Constants.Log.App.Memory, "[RecentsTaskLoader|onTrimMemory]",
Console.trimMemoryLevelToString(level));
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index f366ef0b114d..cba9e5ab5675 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -16,7 +16,6 @@
package com.android.systemui.recents.model;
-import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
@@ -40,11 +39,17 @@ public class Task {
public final int id;
public final Intent baseIntent;
public final int userId;
+ public long lastActiveTime;
- public TaskKey(int id, Intent intent, int userId) {
+ public TaskKey(int id, Intent intent, int userId, long lastActiveTime) {
this.id = id;
this.baseIntent = intent;
this.userId = userId;
+ this.lastActiveTime = lastActiveTime;
+ }
+
+ public void updateLastActiveTime(long lastActiveTime) {
+ this.lastActiveTime = lastActiveTime;
}
@Override
@@ -64,7 +69,8 @@ public class Task {
@Override
public String toString() {
return "Task.Key: " + id + ", "
- + "u" + userId + ", "
+ + "u: " + userId + ", "
+ + "lat: " + lastActiveTime + ", "
+ baseIntent.getComponent().getPackageName();
}
}
@@ -85,8 +91,8 @@ public class Task {
}
public Task(int id, boolean isActive, Intent intent, String activityTitle,
- BitmapDrawable activityIcon, int colorPrimary, int userId) {
- this.key = new TaskKey(id, intent, userId);
+ BitmapDrawable activityIcon, int colorPrimary, int userId, long lastActiveTime) {
+ this.key = new TaskKey(id, intent, userId, lastActiveTime);
this.activityLabel = activityTitle;
this.activityIcon = activityIcon;
this.colorPrimary = colorPrimary;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 8afc5b9f8bbe..43706533d049 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -36,8 +36,8 @@ import android.widget.FrameLayout;
import com.android.systemui.recents.Console;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.RecentsConfiguration;
-import com.android.systemui.recents.RecentsPackageMonitor;
-import com.android.systemui.recents.RecentsTaskLoader;
+import com.android.systemui.recents.model.RecentsPackageMonitor;
+import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.SpaceNode;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 1cf28b998d6c..861c1804832c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -36,10 +36,10 @@ import com.android.systemui.recents.Console;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.DozeTrigger;
import com.android.systemui.recents.RecentsConfiguration;
-import com.android.systemui.recents.RecentsPackageMonitor;
-import com.android.systemui.recents.RecentsTaskLoader;
import com.android.systemui.recents.ReferenceCountedTrigger;
import com.android.systemui.recents.Utilities;
+import com.android.systemui.recents.model.RecentsPackageMonitor;
+import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1b92e3f301e5..9cd5091fbca8 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -7236,6 +7236,7 @@ public final class ActivityManagerService extends ActivityManagerNative
rti.stackId = tr.stack != null ? tr.stack.mStackId : -1;
rti.userId = tr.userId;
rti.taskDescription = new ActivityManager.TaskDescription(tr.lastTaskDescription);
+ rti.lastActiveTime = tr.lastActiveTime;
return rti;
}
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index a301c4be2ffa..57dee2e667af 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -56,6 +56,7 @@ final class TaskRecord extends ThumbnailHolder {
private static final String ATTR_ASKEDCOMPATMODE = "asked_compat_mode";
private static final String ATTR_USERID = "user_id";
private static final String ATTR_TASKTYPE = "task_type";
+ private static final String ATTR_LASTACTIVETIME = "last_active_time";
private static final String ATTR_LASTDESCRIPTION = "last_description";
private static final String ATTR_LASTTIMEMOVED = "last_time_moved";
private static final String ATTR_NEVERRELINQUISH = "never_relinquish_identity";
@@ -136,8 +137,8 @@ final class TaskRecord extends ThumbnailHolder {
TaskRecord(ActivityManagerService service, int _taskId, Intent _intent, Intent _affinityIntent,
String _affinity, ComponentName _realActivity, ComponentName _origActivity,
boolean _rootWasReset, boolean _askedCompatMode, int _taskType, int _userId,
- String _lastDescription, ArrayList<ActivityRecord> activities, long lastTimeMoved,
- boolean neverRelinquishIdentity) {
+ String _lastDescription, ArrayList<ActivityRecord> activities, long _lastActiveTime,
+ long lastTimeMoved, boolean neverRelinquishIdentity) {
mService = service;
taskId = _taskId;
intent = _intent;
@@ -152,10 +153,13 @@ final class TaskRecord extends ThumbnailHolder {
taskType = _taskType;
mTaskToReturnTo = HOME_ACTIVITY_TYPE;
userId = _userId;
+ lastActiveTime = _lastActiveTime;
lastDescription = _lastDescription;
mActivities = activities;
mLastTimeMoved = lastTimeMoved;
mNeverRelinquishIdentity = neverRelinquishIdentity;
+ // Recompute the task description for this task
+ updateTaskDescription();
}
void touchActiveTime() {
@@ -703,6 +707,7 @@ final class TaskRecord extends ThumbnailHolder {
out.attribute(null, ATTR_ASKEDCOMPATMODE, String.valueOf(askedCompatMode));
out.attribute(null, ATTR_USERID, String.valueOf(userId));
out.attribute(null, ATTR_TASKTYPE, String.valueOf(taskType));
+ out.attribute(null, ATTR_LASTACTIVETIME, String.valueOf(lastActiveTime));
out.attribute(null, ATTR_LASTTIMEMOVED, String.valueOf(mLastTimeMoved));
out.attribute(null, ATTR_NEVERRELINQUISH, String.valueOf(mNeverRelinquishIdentity));
if (lastDescription != null) {
@@ -753,6 +758,7 @@ final class TaskRecord extends ThumbnailHolder {
int taskType = ActivityRecord.APPLICATION_ACTIVITY_TYPE;
int userId = 0;
String lastDescription = null;
+ long lastActiveTime = 0;
long lastTimeOnTop = 0;
boolean neverRelinquishIdentity = true;
int taskId = -1;
@@ -779,6 +785,8 @@ final class TaskRecord extends ThumbnailHolder {
userId = Integer.valueOf(attrValue);
} else if (ATTR_TASKTYPE.equals(attrName)) {
taskType = Integer.valueOf(attrValue);
+ } else if (ATTR_LASTACTIVETIME.equals(attrName)) {
+ lastActiveTime = Long.valueOf(attrValue);
} else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
lastDescription = attrValue;
} else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
@@ -818,8 +826,8 @@ final class TaskRecord extends ThumbnailHolder {
final TaskRecord task = new TaskRecord(stackSupervisor.mService, taskId, intent,
affinityIntent, affinity, realActivity, origActivity, rootHasReset,
- askedCompatMode, taskType, userId, lastDescription, activities, lastTimeOnTop,
- neverRelinquishIdentity);
+ askedCompatMode, taskType, userId, lastDescription, activities, lastActiveTime,
+ lastTimeOnTop, neverRelinquishIdentity);
for (int activityNdx = activities.size() - 1; activityNdx >=0; --activityNdx) {
final ActivityRecord r = activities.get(activityNdx);