Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.recents.model; |
| 18 | |
| 19 | import android.app.ActivityManager; |
| 20 | import android.content.Context; |
Winson | 59e1872 | 2016-02-16 09:28:54 -0800 | [diff] [blame] | 21 | import android.content.pm.ActivityInfo; |
Winson | 8be1634 | 2016-02-09 11:53:27 -0800 | [diff] [blame] | 22 | import android.content.pm.ApplicationInfo; |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 23 | import android.content.pm.UserInfo; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 24 | import android.content.res.Resources; |
| 25 | import android.graphics.Bitmap; |
| 26 | import android.graphics.drawable.Drawable; |
| 27 | import android.os.UserHandle; |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 28 | import android.os.UserManager; |
| 29 | import android.util.ArraySet; |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 30 | import android.util.SparseArray; |
| 31 | import android.util.SparseIntArray; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 32 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 33 | import com.android.systemui.Prefs; |
Winson | 5500390 | 2016-01-12 12:00:37 -0800 | [diff] [blame] | 34 | import com.android.systemui.R; |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 35 | import com.android.systemui.recents.Recents; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 36 | import com.android.systemui.recents.RecentsConfiguration; |
Winson | 6e6bd877 | 2016-01-25 10:41:40 -0800 | [diff] [blame] | 37 | import com.android.systemui.recents.RecentsDebugFlags; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 38 | import com.android.systemui.recents.misc.SystemServicesProxy; |
| 39 | |
| 40 | import java.util.ArrayList; |
| 41 | import java.util.Collections; |
Winson | 49df420 | 2016-01-25 17:33:34 -0800 | [diff] [blame] | 42 | import java.util.Formatter; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 43 | import java.util.List; |
| 44 | |
| 45 | |
| 46 | /** |
| 47 | * This class stores the loading state as it goes through multiple stages of loading: |
Winson Chung | 6ac8bd6 | 2015-01-07 16:38:35 -0800 | [diff] [blame] | 48 | * 1) preloadRawTasks() will load the raw set of recents tasks from the system |
| 49 | * 2) preloadPlan() will construct a new task stack with all metadata and only icons and |
| 50 | * thumbnails that are currently in the cache |
| 51 | * 3) executePlan() will actually load and fill in the icons and thumbnails according to the load |
| 52 | * options specified, such that we can transition into the Recents activity seamlessly |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 53 | */ |
| 54 | public class RecentsTaskLoadPlan { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 55 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 56 | private static int MIN_NUM_TASKS = 5; |
Winson | 0c1a9b8 | 2015-12-03 10:59:07 -0800 | [diff] [blame] | 57 | private static int SESSION_BEGIN_TIME = 1000 /* ms/s */ * 60 /* s/min */ * 60 /* min/hr */ * |
| 58 | 6 /* hrs */; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 59 | |
| 60 | /** The set of conditions to load tasks. */ |
| 61 | public static class Options { |
| 62 | public int runningTaskId = -1; |
| 63 | public boolean loadIcons = true; |
| 64 | public boolean loadThumbnails = true; |
Winson Chung | 90d5136 | 2014-11-13 14:30:26 -0800 | [diff] [blame] | 65 | public boolean onlyLoadForCache = false; |
Winson Chung | 0eae557 | 2014-12-11 11:04:19 -0800 | [diff] [blame] | 66 | public boolean onlyLoadPausedActivities = false; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 67 | public int numVisibleTasks = 0; |
| 68 | public int numVisibleTaskThumbnails = 0; |
| 69 | } |
| 70 | |
| 71 | Context mContext; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 72 | |
| 73 | List<ActivityManager.RecentTaskInfo> mRawTasks; |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 74 | TaskStack mStack; |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 75 | ArraySet<Integer> mCurrentQuietProfiles = new ArraySet<Integer>(); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 76 | |
| 77 | /** Package level ctor */ |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 78 | RecentsTaskLoadPlan(Context context) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 79 | mContext = context; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 82 | private void updateCurrentQuietProfilesCache(int currentUserId) { |
| 83 | mCurrentQuietProfiles.clear(); |
| 84 | |
| 85 | if (currentUserId == UserHandle.USER_CURRENT) { |
| 86 | currentUserId = ActivityManager.getCurrentUser(); |
| 87 | } |
| 88 | UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
| 89 | List<UserInfo> profiles = userManager.getProfiles(currentUserId); |
| 90 | if (profiles != null) { |
| 91 | for (int i = 0; i < profiles.size(); i++) { |
| 92 | UserInfo user = profiles.get(i); |
| 93 | if (user.isManagedProfile() && user.isQuietModeEnabled()) { |
| 94 | mCurrentQuietProfiles.add(user.id); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 100 | /** |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 101 | * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 102 | * to most-recent order. |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 103 | */ |
| 104 | public synchronized void preloadRawTasks(boolean isTopTaskHome) { |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 105 | int currentUserId = UserHandle.USER_CURRENT; |
| 106 | updateCurrentQuietProfilesCache(currentUserId); |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 107 | SystemServicesProxy ssp = Recents.getSystemServices(); |
| 108 | mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), |
Rubin Xu | efb844d | 2015-12-08 20:57:24 +0000 | [diff] [blame] | 109 | currentUserId, isTopTaskHome, mCurrentQuietProfiles); |
| 110 | |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 111 | // Since the raw tasks are given in most-recent to least-recent order, we need to reverse it |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 112 | Collections.reverse(mRawTasks); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /** |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 116 | * Preloads the list of recent tasks from the system. After this call, the TaskStack will |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 117 | * have a list of all the recent tasks with their metadata, not including icons or |
| 118 | * thumbnails which were not cached and have to be loaded. |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 119 | * |
| 120 | * The tasks will be ordered by: |
| 121 | * - least-recent to most-recent stack tasks |
| 122 | * - least-recent to most-recent freeform tasks |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 123 | */ |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 124 | public synchronized void preloadPlan(RecentsTaskLoader loader, int topTaskId, |
| 125 | boolean isTopTaskHome) { |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 126 | Resources res = mContext.getResources(); |
Winson Chung | 509d0d0 | 2015-12-16 15:43:12 -0500 | [diff] [blame] | 127 | ArrayList<Task> allTasks = new ArrayList<>(); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 128 | if (mRawTasks == null) { |
| 129 | preloadRawTasks(isTopTaskHome); |
| 130 | } |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 131 | |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 132 | SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>(); |
| 133 | SparseIntArray affiliatedTaskCounts = new SparseIntArray(); |
Winson | 5500390 | 2016-01-12 12:00:37 -0800 | [diff] [blame] | 134 | String dismissDescFormat = mContext.getString( |
| 135 | R.string.accessibility_recents_item_will_be_dismissed); |
Winson | 49df420 | 2016-01-25 17:33:34 -0800 | [diff] [blame] | 136 | Formatter dismissDescFormatter = new Formatter(); |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 137 | long lastStackActiveTime = Prefs.getLong(mContext, |
| 138 | Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); |
Winson | 6e6bd877 | 2016-01-25 10:41:40 -0800 | [diff] [blame] | 139 | if (RecentsDebugFlags.Static.EnableMockTasks) { |
| 140 | lastStackActiveTime = 0; |
| 141 | } |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 142 | long newLastStackActiveTime = -1; |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 143 | long prevLastActiveTime = lastStackActiveTime; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 144 | int taskCount = mRawTasks.size(); |
| 145 | for (int i = 0; i < taskCount; i++) { |
| 146 | ActivityManager.RecentTaskInfo t = mRawTasks.get(i); |
| 147 | |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 148 | /* |
| 149 | * Affiliated tasks are returned in a specific order from ActivityManager but without a |
| 150 | * lastActiveTime since it hasn't yet been started. However, we later sort the task list |
| 151 | * by lastActiveTime, which rearranges the tasks. For now, we need to workaround this |
| 152 | * by updating the lastActiveTime of this task to the lastActiveTime of the task it is |
| 153 | * affiliated with, in the same order that we encounter it in the original list (just |
| 154 | * its index in the task group for the task it is affiliated with). |
| 155 | * |
| 156 | * If the parent task is not available, then we will use the last active time of the |
| 157 | * previous task as a base point (since the task itself may not have an active time) |
| 158 | * for the entire affiliated group. |
| 159 | */ |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 160 | if (t.persistentId != t.affiliatedTaskId) { |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 161 | Task.TaskKey parentTask = affiliatedTasks.get(t.affiliatedTaskId); |
| 162 | long parentTaskLastActiveTime = parentTask != null |
| 163 | ? parentTask.lastActiveTime |
| 164 | : prevLastActiveTime; |
| 165 | t.lastActiveTime = parentTaskLastActiveTime + |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 166 | affiliatedTaskCounts.get(t.affiliatedTaskId, 0) + 1; |
| 167 | } |
| 168 | |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 169 | // Compose the task key |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 170 | Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent, |
| 171 | t.userId, t.firstActiveTime, t.lastActiveTime); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 172 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 173 | // This task is only shown in the stack if it statisfies the historical time or min |
| 174 | // number of tasks constraints. Freeform tasks are also always shown. |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 175 | boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 176 | boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) || |
| 177 | (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS))); |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 178 | boolean isLaunchTarget = taskKey.id == topTaskId; |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 179 | if (isStackTask && newLastStackActiveTime < 0) { |
| 180 | newLastStackActiveTime = t.lastActiveTime; |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 181 | } |
| 182 | |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 183 | // Load the title, icon, and color |
Winson | 59e1872 | 2016-02-16 09:28:54 -0800 | [diff] [blame] | 184 | ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 185 | String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription); |
Winson | c5ef63f | 2016-01-21 14:39:23 -0800 | [diff] [blame] | 186 | String contentDescription = loader.getAndUpdateContentDescription(taskKey, res); |
Winson | 49df420 | 2016-01-25 17:33:34 -0800 | [diff] [blame] | 187 | String dismissDescription = dismissDescFormatter.format(dismissDescFormat, |
| 188 | contentDescription).toString(); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 189 | Drawable icon = isStackTask |
| 190 | ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 191 | : null; |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 192 | Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false); |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 193 | int activityColor = loader.getActivityPrimaryColor(t.taskDescription); |
Winson Chung | 1af8eda | 2016-02-05 17:55:56 +0000 | [diff] [blame] | 194 | int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription); |
Winson | 59e1872 | 2016-02-16 09:28:54 -0800 | [diff] [blame] | 195 | boolean isSystemApp = (info != null) && |
| 196 | ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 197 | |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 198 | // Add the task to the stack |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 199 | Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, |
Winson | 5500390 | 2016-01-12 12:00:37 -0800 | [diff] [blame] | 200 | thumbnail, title, contentDescription, dismissDescription, activityColor, |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 201 | backgroundColor, !isStackTask, isLaunchTarget, isSystemApp, t.isDockable, |
| 202 | t.bounds, t.taskDescription); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 203 | |
Winson Chung | 509d0d0 | 2015-12-16 15:43:12 -0500 | [diff] [blame] | 204 | allTasks.add(task); |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 205 | affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1); |
| 206 | affiliatedTasks.put(taskKey.id, taskKey); |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 207 | |
| 208 | prevLastActiveTime = t.lastActiveTime; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 209 | } |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 210 | if (newLastStackActiveTime != -1) { |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 211 | Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, |
| 212 | newLastStackActiveTime); |
| 213 | } |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 214 | |
| 215 | // Initialize the stacks |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 216 | mStack = new TaskStack(); |
Winson Chung | 0626677 | 2015-12-11 10:24:21 -0500 | [diff] [blame] | 217 | mStack.setTasks(allTasks, false /* notifyStackChanges */); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 218 | mStack.createAffiliatedGroupings(mContext); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Called to apply the actual loading based on the specified conditions. |
| 223 | */ |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 224 | public synchronized void executePlan(Options opts, RecentsTaskLoader loader, |
Winson Chung | 96d7041 | 2014-11-12 14:17:17 -0800 | [diff] [blame] | 225 | TaskResourceLoadQueue loadQueue) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 226 | RecentsConfiguration config = Recents.getConfiguration(); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 227 | Resources res = mContext.getResources(); |
| 228 | |
| 229 | // Iterate through each of the tasks and load them according to the load conditions. |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 230 | ArrayList<Task> tasks = mStack.getStackTasks(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 231 | int taskCount = tasks.size(); |
| 232 | for (int i = 0; i < taskCount; i++) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 233 | Task task = tasks.get(i); |
| 234 | Task.TaskKey taskKey = task.key; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 235 | |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 236 | boolean isRunningTask = (task.key.id == opts.runningTaskId); |
| 237 | boolean isVisibleTask = i >= (taskCount - opts.numVisibleTasks); |
| 238 | boolean isVisibleThumbnail = i >= (taskCount - opts.numVisibleTaskThumbnails); |
| 239 | |
| 240 | // If requested, skip the running task |
| 241 | if (opts.onlyLoadPausedActivities && isRunningTask) { |
| 242 | continue; |
| 243 | } |
| 244 | |
| 245 | if (opts.loadIcons && (isRunningTask || isVisibleTask)) { |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 246 | if (task.icon == null) { |
| 247 | task.icon = loader.getAndUpdateActivityIcon(taskKey, task.taskDescription, |
| 248 | res, true); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 249 | } |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 250 | } |
| 251 | if (opts.loadThumbnails && (isRunningTask || isVisibleThumbnail)) { |
| 252 | if (task.thumbnail == null || isRunningTask) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 253 | if (config.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) { |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 254 | task.thumbnail = loader.getAndUpdateThumbnail(taskKey, true); |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 255 | } else if (config.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 256 | loadQueue.addTask(task); |
Winson Chung | 96d7041 | 2014-11-12 14:17:17 -0800 | [diff] [blame] | 257 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 258 | } |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 259 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
| 263 | /** |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 264 | * Returns the TaskStack from the preloaded list of recent tasks. |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 265 | */ |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 266 | public TaskStack getTaskStack() { |
| 267 | return mStack; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /** Returns whether there are any tasks in any stacks. */ |
| 271 | public boolean hasTasks() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 272 | if (mStack != null) { |
Winson | 4b057c6 | 2016-01-12 15:01:52 -0800 | [diff] [blame] | 273 | return mStack.getTaskCount() > 0; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 274 | } |
| 275 | return false; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 276 | } |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 277 | |
| 278 | /** |
| 279 | * Returns whether this task is considered a task to be shown in the history. |
| 280 | */ |
| 281 | private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) { |
| 282 | return t.lastActiveTime < (System.currentTimeMillis() - SESSION_BEGIN_TIME); |
| 283 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 284 | } |