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 | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 136 | long lastStackActiveTime = Prefs.getLong(mContext, |
| 137 | Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, 0); |
Winson | 6e6bd877 | 2016-01-25 10:41:40 -0800 | [diff] [blame] | 138 | if (RecentsDebugFlags.Static.EnableMockTasks) { |
| 139 | lastStackActiveTime = 0; |
| 140 | } |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 141 | long newLastStackActiveTime = -1; |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 142 | long prevLastActiveTime = lastStackActiveTime; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 143 | int taskCount = mRawTasks.size(); |
| 144 | for (int i = 0; i < taskCount; i++) { |
| 145 | ActivityManager.RecentTaskInfo t = mRawTasks.get(i); |
| 146 | |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 147 | /* |
| 148 | * Affiliated tasks are returned in a specific order from ActivityManager but without a |
| 149 | * lastActiveTime since it hasn't yet been started. However, we later sort the task list |
| 150 | * by lastActiveTime, which rearranges the tasks. For now, we need to workaround this |
| 151 | * by updating the lastActiveTime of this task to the lastActiveTime of the task it is |
| 152 | * affiliated with, in the same order that we encounter it in the original list (just |
| 153 | * its index in the task group for the task it is affiliated with). |
| 154 | * |
| 155 | * If the parent task is not available, then we will use the last active time of the |
| 156 | * previous task as a base point (since the task itself may not have an active time) |
| 157 | * for the entire affiliated group. |
| 158 | */ |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 159 | if (t.persistentId != t.affiliatedTaskId) { |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 160 | Task.TaskKey parentTask = affiliatedTasks.get(t.affiliatedTaskId); |
| 161 | long parentTaskLastActiveTime = parentTask != null |
| 162 | ? parentTask.lastActiveTime |
| 163 | : prevLastActiveTime; |
| 164 | t.lastActiveTime = parentTaskLastActiveTime + |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 165 | affiliatedTaskCounts.get(t.affiliatedTaskId, 0) + 1; |
| 166 | } |
| 167 | |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 168 | // Compose the task key |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 169 | Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent, |
| 170 | t.userId, t.firstActiveTime, t.lastActiveTime); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 171 | |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 172 | // This task is only shown in the stack if it statisfies the historical time or min |
| 173 | // number of tasks constraints. Freeform tasks are also always shown. |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 174 | boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 175 | boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) || |
| 176 | (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS))); |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 177 | boolean isLaunchTarget = taskKey.id == topTaskId; |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 178 | if (isStackTask && newLastStackActiveTime < 0) { |
| 179 | newLastStackActiveTime = t.lastActiveTime; |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 182 | // Load the title, icon, and color |
Winson | 59e1872 | 2016-02-16 09:28:54 -0800 | [diff] [blame] | 183 | ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 184 | String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription); |
Winson | c5ef63f | 2016-01-21 14:39:23 -0800 | [diff] [blame] | 185 | String contentDescription = loader.getAndUpdateContentDescription(taskKey, res); |
Winson | 9da1885 | 2016-03-01 11:56:30 -0800 | [diff] [blame] | 186 | String dismissDescription = String.format(dismissDescFormat, contentDescription); |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 187 | Drawable icon = isStackTask |
| 188 | ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 189 | : null; |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 190 | Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false); |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 191 | int activityColor = loader.getActivityPrimaryColor(t.taskDescription); |
Winson Chung | 1af8eda | 2016-02-05 17:55:56 +0000 | [diff] [blame] | 192 | int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription); |
Winson | 59e1872 | 2016-02-16 09:28:54 -0800 | [diff] [blame] | 193 | boolean isSystemApp = (info != null) && |
| 194 | ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 195 | |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 196 | // Add the task to the stack |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 197 | Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon, |
Winson | 5500390 | 2016-01-12 12:00:37 -0800 | [diff] [blame] | 198 | thumbnail, title, contentDescription, dismissDescription, activityColor, |
Winson | 931845f | 2016-02-24 19:38:41 -0800 | [diff] [blame] | 199 | backgroundColor, !isStackTask, isLaunchTarget, isSystemApp, t.isDockable, |
| 200 | t.bounds, t.taskDescription); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 201 | |
Winson Chung | 509d0d0 | 2015-12-16 15:43:12 -0500 | [diff] [blame] | 202 | allTasks.add(task); |
Winson | 65c851e | 2016-01-20 12:43:35 -0800 | [diff] [blame] | 203 | affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1); |
| 204 | affiliatedTasks.put(taskKey.id, taskKey); |
Winson | df1020c | 2016-02-01 10:05:10 -0800 | [diff] [blame] | 205 | |
| 206 | prevLastActiveTime = t.lastActiveTime; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 207 | } |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 208 | if (newLastStackActiveTime != -1) { |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 209 | Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, |
| 210 | newLastStackActiveTime); |
| 211 | } |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 212 | |
| 213 | // Initialize the stacks |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 214 | mStack = new TaskStack(); |
Winson Chung | 0626677 | 2015-12-11 10:24:21 -0500 | [diff] [blame] | 215 | mStack.setTasks(allTasks, false /* notifyStackChanges */); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 216 | mStack.createAffiliatedGroupings(mContext); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Called to apply the actual loading based on the specified conditions. |
| 221 | */ |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 222 | public synchronized void executePlan(Options opts, RecentsTaskLoader loader, |
Winson Chung | 96d7041 | 2014-11-12 14:17:17 -0800 | [diff] [blame] | 223 | TaskResourceLoadQueue loadQueue) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 224 | RecentsConfiguration config = Recents.getConfiguration(); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 225 | Resources res = mContext.getResources(); |
| 226 | |
| 227 | // 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] | 228 | ArrayList<Task> tasks = mStack.getStackTasks(); |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 229 | int taskCount = tasks.size(); |
| 230 | for (int i = 0; i < taskCount; i++) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 231 | Task task = tasks.get(i); |
| 232 | Task.TaskKey taskKey = task.key; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 233 | |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 234 | boolean isRunningTask = (task.key.id == opts.runningTaskId); |
| 235 | boolean isVisibleTask = i >= (taskCount - opts.numVisibleTasks); |
| 236 | boolean isVisibleThumbnail = i >= (taskCount - opts.numVisibleTaskThumbnails); |
| 237 | |
| 238 | // If requested, skip the running task |
| 239 | if (opts.onlyLoadPausedActivities && isRunningTask) { |
| 240 | continue; |
| 241 | } |
| 242 | |
| 243 | if (opts.loadIcons && (isRunningTask || isVisibleTask)) { |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 244 | if (task.icon == null) { |
| 245 | task.icon = loader.getAndUpdateActivityIcon(taskKey, task.taskDescription, |
| 246 | res, true); |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 247 | } |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 248 | } |
| 249 | if (opts.loadThumbnails && (isRunningTask || isVisibleThumbnail)) { |
| 250 | if (task.thumbnail == null || isRunningTask) { |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 251 | if (config.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) { |
Winson Chung | 296278a | 2015-12-17 12:09:02 -0500 | [diff] [blame] | 252 | task.thumbnail = loader.getAndUpdateThumbnail(taskKey, true); |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 253 | } else if (config.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 254 | loadQueue.addTask(task); |
Winson Chung | 96d7041 | 2014-11-12 14:17:17 -0800 | [diff] [blame] | 255 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 256 | } |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 257 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | /** |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 262 | * Returns the TaskStack from the preloaded list of recent tasks. |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 263 | */ |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 264 | public TaskStack getTaskStack() { |
| 265 | return mStack; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | /** Returns whether there are any tasks in any stacks. */ |
| 269 | public boolean hasTasks() { |
Winson | 147ecaf | 2015-09-16 16:49:55 -0700 | [diff] [blame] | 270 | if (mStack != null) { |
Winson | 4b057c6 | 2016-01-12 15:01:52 -0800 | [diff] [blame] | 271 | return mStack.getTaskCount() > 0; |
Winson Chung | d16c565 | 2015-01-26 16:11:07 -0800 | [diff] [blame] | 272 | } |
| 273 | return false; |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 274 | } |
Winson | 250608a | 2015-11-24 15:00:31 -0800 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * Returns whether this task is considered a task to be shown in the history. |
| 278 | */ |
| 279 | private boolean isHistoricalTask(ActivityManager.RecentTaskInfo t) { |
| 280 | return t.lastActiveTime < (System.currentTimeMillis() - SESSION_BEGIN_TIME); |
| 281 | } |
Winson Chung | a91c293 | 2014-11-07 15:02:38 -0800 | [diff] [blame] | 282 | } |