The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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.server.am; |
| 18 | |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 19 | import static com.android.server.am.ActivityManagerService.TAG; |
| 20 | import static com.android.server.am.ActivityStack.DEBUG_ADD_REMOVE; |
| 21 | |
Craig Mautner | b0f7dc7 | 2013-04-01 16:34:45 -0700 | [diff] [blame] | 22 | import android.app.Activity; |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 23 | import android.app.ActivityManager; |
Craig Mautner | b0f7dc7 | 2013-04-01 16:34:45 -0700 | [diff] [blame] | 24 | import android.app.ActivityOptions; |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 25 | import android.app.IThumbnailRetriever; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.ComponentName; |
| 27 | import android.content.Intent; |
| 28 | import android.content.pm.ActivityInfo; |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 29 | import android.graphics.Bitmap; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 30 | import android.os.UserHandle; |
Dianne Hackborn | 7f96b79 | 2012-05-29 18:46:45 -0700 | [diff] [blame] | 31 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
| 33 | import java.io.PrintWriter; |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 34 | import java.util.ArrayList; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
Dianne Hackborn | f26fd99 | 2011-04-08 18:14:09 -0700 | [diff] [blame] | 36 | class TaskRecord extends ThumbnailHolder { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | final int taskId; // Unique identifier for this task. |
| 38 | final String affinity; // The affinity name for this task, or null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | Intent intent; // The original intent that started the task. |
| 40 | Intent affinityIntent; // Intent of affinity-moved activity that started this task. |
| 41 | ComponentName origActivity; // The non-alias activity component of the intent. |
| 42 | ComponentName realActivity; // The actual activity component that started the task. |
| 43 | int numActivities; // Current number of activities in this task. |
| 44 | long lastActiveTime; // Last time this task was active, including sleep. |
| 45 | boolean rootWasReset; // True if the intent at the root of the task had |
| 46 | // the FLAG_ACTIVITY_RESET_TASK_IF_NEEDED flag. |
Dianne Hackborn | 36cd41f | 2011-05-25 21:00:46 -0700 | [diff] [blame] | 47 | boolean askedCompatMode;// Have asked the user about compat mode for this task. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 49 | String stringName; // caching of toString() result. |
Dianne Hackborn | 9da2d40 | 2012-03-15 13:43:08 -0700 | [diff] [blame] | 50 | int userId; // user for which this task was created |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 51 | |
| 52 | int numFullscreen; // Number of fullscreen activities. |
| 53 | |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 54 | /** List of all activities in the task arranged in history order */ |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 55 | final ArrayList<ActivityRecord> mActivities = new ArrayList<ActivityRecord>(); |
| 56 | |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 57 | /** Current stack */ |
| 58 | ActivityStack stack; |
| 59 | |
| 60 | TaskRecord(int _taskId, ActivityInfo info, Intent _intent, ActivityStack _stack) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | taskId = _taskId; |
| 62 | affinity = info.taskAffinity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | setIntent(_intent, info); |
Craig Mautner | d232895 | 2013-03-05 12:46:26 -0800 | [diff] [blame] | 64 | stack = _stack; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void touchActiveTime() { |
| 68 | lastActiveTime = android.os.SystemClock.elapsedRealtime(); |
| 69 | } |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 70 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | long getInactiveDuration() { |
| 72 | return android.os.SystemClock.elapsedRealtime() - lastActiveTime; |
| 73 | } |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 74 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | void setIntent(Intent _intent, ActivityInfo info) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 76 | stringName = null; |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 77 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | if (info.targetActivity == null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 79 | if (_intent != null) { |
| 80 | // If this Intent has a selector, we want to clear it for the |
| 81 | // recent task since it is not relevant if the user later wants |
| 82 | // to re-launch the app. |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 83 | if (_intent.getSelector() != null || _intent.getSourceBounds() != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 84 | _intent = new Intent(_intent); |
| 85 | _intent.setSelector(null); |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 86 | _intent.setSourceBounds(null); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 87 | } |
| 88 | } |
Dianne Hackborn | 7f96b79 | 2012-05-29 18:46:45 -0700 | [diff] [blame] | 89 | if (ActivityManagerService.DEBUG_TASKS) Slog.v(ActivityManagerService.TAG, |
| 90 | "Setting Intent of " + this + " to " + _intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | intent = _intent; |
| 92 | realActivity = _intent != null ? _intent.getComponent() : null; |
| 93 | origActivity = null; |
| 94 | } else { |
| 95 | ComponentName targetComponent = new ComponentName( |
| 96 | info.packageName, info.targetActivity); |
| 97 | if (_intent != null) { |
| 98 | Intent targetIntent = new Intent(_intent); |
| 99 | targetIntent.setComponent(targetComponent); |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 100 | targetIntent.setSelector(null); |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 101 | targetIntent.setSourceBounds(null); |
Dianne Hackborn | 7f96b79 | 2012-05-29 18:46:45 -0700 | [diff] [blame] | 102 | if (ActivityManagerService.DEBUG_TASKS) Slog.v(ActivityManagerService.TAG, |
| 103 | "Setting Intent of " + this + " to target " + targetIntent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | intent = targetIntent; |
| 105 | realActivity = targetComponent; |
| 106 | origActivity = _intent.getComponent(); |
| 107 | } else { |
| 108 | intent = null; |
| 109 | realActivity = targetComponent; |
| 110 | origActivity = new ComponentName(info.packageName, info.name); |
| 111 | } |
| 112 | } |
Amith Yamasani | 742a671 | 2011-05-04 14:49:28 -0700 | [diff] [blame] | 113 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | if (intent != null && |
| 115 | (intent.getFlags()&Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) { |
| 116 | // Once we are set to an Intent with this flag, we count this |
| 117 | // task as having a true root activity. |
| 118 | rootWasReset = true; |
| 119 | } |
Amith Yamasani | 742a671 | 2011-05-04 14:49:28 -0700 | [diff] [blame] | 120 | |
| 121 | if (info.applicationInfo != null) { |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 122 | userId = UserHandle.getUserId(info.applicationInfo.uid); |
Amith Yamasani | 742a671 | 2011-05-04 14:49:28 -0700 | [diff] [blame] | 123 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 124 | } |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 125 | |
| 126 | ActivityRecord getTopActivity() { |
| 127 | for (int i = mActivities.size() - 1; i >= 0; --i) { |
| 128 | final ActivityRecord r = mActivities.get(i); |
| 129 | if (r.finishing) { |
| 130 | continue; |
| 131 | } |
| 132 | return r; |
| 133 | } |
| 134 | return null; |
| 135 | } |
| 136 | |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 137 | /** |
| 138 | * Reorder the history stack so that the activity at the given index is |
| 139 | * brought to the front. |
| 140 | */ |
| 141 | final void moveActivityToFrontLocked(ActivityRecord newTop) { |
| 142 | if (DEBUG_ADD_REMOVE) Slog.i(TAG, "Removing and adding activity " + newTop |
| 143 | + " to stack at top", new RuntimeException("here").fillInStackTrace()); |
| 144 | |
| 145 | getTopActivity().frontOfTask = false; |
| 146 | mActivities.remove(newTop); |
| 147 | mActivities.add(newTop); |
| 148 | newTop.frontOfTask = true; |
| 149 | } |
| 150 | |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 151 | void addActivityAtBottom(ActivityRecord r) { |
Craig Mautner | 7787877 | 2013-03-04 19:46:24 -0800 | [diff] [blame] | 152 | addActivityAtIndex(0, r); |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | void addActivityToTop(ActivityRecord r) { |
Craig Mautner | 6170f73 | 2013-04-02 13:05:23 -0700 | [diff] [blame] | 156 | // Remove r first, and if it wasn't already in the list and it's fullscreen, count it. |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 157 | if (!mActivities.remove(r) && r.fullscreen) { |
| 158 | // Was not previously in list. |
| 159 | numFullscreen++; |
| 160 | } |
Craig Mautner | 9658b31 | 2013-02-28 10:55:59 -0800 | [diff] [blame] | 161 | mActivities.add(r); |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 162 | } |
| 163 | |
Craig Mautner | 7787877 | 2013-03-04 19:46:24 -0800 | [diff] [blame] | 164 | void addActivityAtIndex(int index, ActivityRecord r) { |
| 165 | if (!mActivities.remove(r) && r.fullscreen) { |
| 166 | // Was not previously in list. |
| 167 | numFullscreen++; |
| 168 | } |
| 169 | mActivities.add(index, r); |
| 170 | } |
| 171 | |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 172 | /** @return true if this was the last activity in the task */ |
| 173 | boolean removeActivity(ActivityRecord r) { |
| 174 | if (mActivities.remove(r) && r.fullscreen) { |
| 175 | // Was previously in list. |
| 176 | numFullscreen--; |
| 177 | } |
| 178 | return mActivities.size() == 0; |
| 179 | } |
| 180 | |
Craig Mautner | b0f7dc7 | 2013-04-01 16:34:45 -0700 | [diff] [blame] | 181 | /** |
| 182 | * Completely remove all activities associated with an existing |
| 183 | * task starting at a specified index. |
| 184 | */ |
| 185 | final void performClearTaskAtIndexLocked(int activityNdx) { |
| 186 | final ArrayList<ActivityRecord> activities = mActivities; |
| 187 | int numActivities = activities.size(); |
| 188 | for ( ; activityNdx < numActivities; ++activityNdx) { |
| 189 | final ActivityRecord r = activities.get(activityNdx); |
| 190 | if (r.finishing) { |
| 191 | continue; |
| 192 | } |
| 193 | if (stack.finishActivityLocked(r, Activity.RESULT_CANCELED, null, "clear", false)) { |
| 194 | --activityNdx; |
| 195 | --numActivities; |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Completely remove all activities associated with an existing task. |
| 202 | */ |
| 203 | final void performClearTaskLocked() { |
| 204 | performClearTaskAtIndexLocked(0); |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Perform clear operation as requested by |
| 209 | * {@link Intent#FLAG_ACTIVITY_CLEAR_TOP}: search from the top of the |
| 210 | * stack to the given task, then look for |
| 211 | * an instance of that activity in the stack and, if found, finish all |
| 212 | * activities on top of it and return the instance. |
| 213 | * |
| 214 | * @param newR Description of the new activity being started. |
| 215 | * @return Returns the old activity that should be continued to be used, |
| 216 | * or null if none was found. |
| 217 | */ |
| 218 | final ActivityRecord performClearTaskLocked(ActivityRecord newR, int launchFlags) { |
| 219 | final ArrayList<ActivityRecord> activities = mActivities; |
| 220 | int numActivities = activities.size(); |
| 221 | for (int activityNdx = numActivities - 1; activityNdx >= 0; --activityNdx) { |
| 222 | ActivityRecord r = activities.get(activityNdx); |
| 223 | if (r.finishing) { |
| 224 | continue; |
| 225 | } |
| 226 | if (r.realActivity.equals(newR.realActivity)) { |
| 227 | // Here it is! Now finish everything in front... |
| 228 | ActivityRecord ret = r; |
| 229 | |
| 230 | for (++activityNdx; activityNdx < numActivities; ++activityNdx) { |
| 231 | r = activities.get(activityNdx); |
| 232 | if (r.finishing) { |
| 233 | continue; |
| 234 | } |
| 235 | ActivityOptions opts = r.takeOptionsLocked(); |
| 236 | if (opts != null) { |
| 237 | ret.updateOptionsLocked(opts); |
| 238 | } |
| 239 | if (stack.finishActivityLocked(r, Activity.RESULT_CANCELED, null, "clear", |
| 240 | false)) { |
| 241 | --activityNdx; |
| 242 | --numActivities; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // Finally, if this is a normal launch mode (that is, not |
| 247 | // expecting onNewIntent()), then we will finish the current |
| 248 | // instance of the activity so a new fresh one can be started. |
| 249 | if (ret.launchMode == ActivityInfo.LAUNCH_MULTIPLE |
| 250 | && (launchFlags & Intent.FLAG_ACTIVITY_SINGLE_TOP) == 0) { |
| 251 | if (!ret.finishing) { |
| 252 | if (activities.contains(ret)) { |
| 253 | stack.finishActivityLocked(ret, Activity.RESULT_CANCELED, null, |
| 254 | "clear", false); |
| 255 | } |
| 256 | return null; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return ret; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return null; |
| 265 | } |
| 266 | |
Craig Mautner | 9db9a0b | 2013-04-29 17:05:56 -0700 | [diff] [blame^] | 267 | public ActivityManager.TaskThumbnails getTaskThumbnailsLocked() { |
| 268 | TaskAccessInfo info = getTaskAccessInfoLocked(true); |
| 269 | final ActivityRecord resumedActivity = stack.mResumedActivity; |
| 270 | if (resumedActivity != null && resumedActivity.thumbHolder == this) { |
| 271 | info.mainThumbnail = stack.screenshotActivities(resumedActivity); |
| 272 | } |
| 273 | if (info.mainThumbnail == null) { |
| 274 | info.mainThumbnail = lastThumbnail; |
| 275 | } |
| 276 | return info; |
| 277 | } |
| 278 | |
| 279 | public Bitmap getTaskTopThumbnailLocked() { |
| 280 | final ActivityRecord resumedActivity = stack.mResumedActivity; |
| 281 | if (resumedActivity != null && resumedActivity.task == this) { |
| 282 | // This task is the current resumed task, we just need to take |
| 283 | // a screenshot of it and return that. |
| 284 | return stack.screenshotActivities(resumedActivity); |
| 285 | } |
| 286 | // Return the information about the task, to figure out the top |
| 287 | // thumbnail to return. |
| 288 | TaskAccessInfo info = getTaskAccessInfoLocked(true); |
| 289 | if (info.numSubThumbbails <= 0) { |
| 290 | return info.mainThumbnail != null ? info.mainThumbnail : lastThumbnail; |
| 291 | } |
| 292 | return info.subtasks.get(info.numSubThumbbails-1).holder.lastThumbnail; |
| 293 | } |
| 294 | |
| 295 | public ActivityRecord removeTaskActivitiesLocked(int subTaskIndex, |
| 296 | boolean taskRequired) { |
| 297 | TaskAccessInfo info = getTaskAccessInfoLocked(false); |
| 298 | if (info.root == null) { |
| 299 | if (taskRequired) { |
| 300 | Slog.w(TAG, "removeTaskLocked: unknown taskId " + taskId); |
| 301 | } |
| 302 | return null; |
| 303 | } |
| 304 | |
| 305 | if (subTaskIndex < 0) { |
| 306 | // Just remove the entire task. |
| 307 | performClearTaskAtIndexLocked(info.rootIndex); |
| 308 | return info.root; |
| 309 | } |
| 310 | |
| 311 | if (subTaskIndex >= info.subtasks.size()) { |
| 312 | if (taskRequired) { |
| 313 | Slog.w(TAG, "removeTaskLocked: unknown subTaskIndex " + subTaskIndex); |
| 314 | } |
| 315 | return null; |
| 316 | } |
| 317 | |
| 318 | // Remove all of this task's activities starting at the sub task. |
| 319 | TaskAccessInfo.SubTask subtask = info.subtasks.get(subTaskIndex); |
| 320 | performClearTaskAtIndexLocked(subtask.index); |
| 321 | return subtask.activity; |
| 322 | } |
| 323 | |
| 324 | public TaskAccessInfo getTaskAccessInfoLocked(boolean inclThumbs) { |
| 325 | final TaskAccessInfo thumbs = new TaskAccessInfo(); |
| 326 | // How many different sub-thumbnails? |
| 327 | final int NA = mActivities.size(); |
| 328 | int j = 0; |
| 329 | ThumbnailHolder holder = null; |
| 330 | while (j < NA) { |
| 331 | ActivityRecord ar = mActivities.get(j); |
| 332 | if (!ar.finishing) { |
| 333 | thumbs.root = ar; |
| 334 | thumbs.rootIndex = j; |
| 335 | holder = ar.thumbHolder; |
| 336 | if (holder != null) { |
| 337 | thumbs.mainThumbnail = holder.lastThumbnail; |
| 338 | } |
| 339 | j++; |
| 340 | break; |
| 341 | } |
| 342 | j++; |
| 343 | } |
| 344 | |
| 345 | if (j >= NA) { |
| 346 | return thumbs; |
| 347 | } |
| 348 | |
| 349 | ArrayList<TaskAccessInfo.SubTask> subtasks = new ArrayList<TaskAccessInfo.SubTask>(); |
| 350 | thumbs.subtasks = subtasks; |
| 351 | while (j < NA) { |
| 352 | ActivityRecord ar = mActivities.get(j); |
| 353 | j++; |
| 354 | if (ar.finishing) { |
| 355 | continue; |
| 356 | } |
| 357 | if (ar.thumbHolder != holder && holder != null) { |
| 358 | thumbs.numSubThumbbails++; |
| 359 | holder = ar.thumbHolder; |
| 360 | TaskAccessInfo.SubTask sub = new TaskAccessInfo.SubTask(); |
| 361 | sub.holder = holder; |
| 362 | sub.activity = ar; |
| 363 | sub.index = j-1; |
| 364 | subtasks.add(sub); |
| 365 | } |
| 366 | } |
| 367 | if (thumbs.numSubThumbbails > 0) { |
| 368 | thumbs.retriever = new IThumbnailRetriever.Stub() { |
| 369 | @Override |
| 370 | public Bitmap getThumbnail(int index) { |
| 371 | if (index < 0 || index >= thumbs.subtasks.size()) { |
| 372 | return null; |
| 373 | } |
| 374 | TaskAccessInfo.SubTask sub = thumbs.subtasks.get(index); |
| 375 | ActivityRecord resumedActivity = stack.mResumedActivity; |
| 376 | if (resumedActivity != null && resumedActivity.thumbHolder == sub.holder) { |
| 377 | return stack.screenshotActivities(resumedActivity); |
| 378 | } |
| 379 | return sub.holder.lastThumbnail; |
| 380 | } |
| 381 | }; |
| 382 | } |
| 383 | return thumbs; |
| 384 | } |
| 385 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | void dump(PrintWriter pw, String prefix) { |
Dianne Hackborn | 7f96b79 | 2012-05-29 18:46:45 -0700 | [diff] [blame] | 387 | if (numActivities != 0 || rootWasReset || userId != 0) { |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 388 | pw.print(prefix); pw.print("numActivities="); pw.print(numActivities); |
Dianne Hackborn | 7f96b79 | 2012-05-29 18:46:45 -0700 | [diff] [blame] | 389 | pw.print(" rootWasReset="); pw.print(rootWasReset); |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 390 | pw.print(" userId="); pw.print(userId); |
| 391 | pw.print(" numFullscreen="); pw.println(numFullscreen); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 392 | } |
| 393 | if (affinity != null) { |
| 394 | pw.print(prefix); pw.print("affinity="); pw.println(affinity); |
| 395 | } |
| 396 | if (intent != null) { |
| 397 | StringBuilder sb = new StringBuilder(128); |
| 398 | sb.append(prefix); sb.append("intent={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 399 | intent.toShortString(sb, false, true, false, true); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 400 | sb.append('}'); |
| 401 | pw.println(sb.toString()); |
| 402 | } |
| 403 | if (affinityIntent != null) { |
| 404 | StringBuilder sb = new StringBuilder(128); |
| 405 | sb.append(prefix); sb.append("affinityIntent={"); |
Dianne Hackborn | 21c241e | 2012-03-08 13:57:23 -0800 | [diff] [blame] | 406 | affinityIntent.toShortString(sb, false, true, false, true); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 407 | sb.append('}'); |
| 408 | pw.println(sb.toString()); |
| 409 | } |
| 410 | if (origActivity != null) { |
| 411 | pw.print(prefix); pw.print("origActivity="); |
| 412 | pw.println(origActivity.flattenToShortString()); |
| 413 | } |
| 414 | if (realActivity != null) { |
| 415 | pw.print(prefix); pw.print("realActivity="); |
| 416 | pw.println(realActivity.flattenToShortString()); |
| 417 | } |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 418 | pw.print(prefix); pw.print("Activities="); pw.println(mActivities); |
Dianne Hackborn | 36cd41f | 2011-05-25 21:00:46 -0700 | [diff] [blame] | 419 | if (!askedCompatMode) { |
| 420 | pw.print(prefix); pw.print("askedCompatMode="); pw.println(askedCompatMode); |
| 421 | } |
Dianne Hackborn | cfb9f2b | 2011-08-24 10:51:49 -0700 | [diff] [blame] | 422 | pw.print(prefix); pw.print("lastThumbnail="); pw.print(lastThumbnail); |
| 423 | pw.print(" lastDescription="); pw.println(lastDescription); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 424 | pw.print(prefix); pw.print("lastActiveTime="); pw.print(lastActiveTime); |
| 425 | pw.print(" (inactive for "); |
| 426 | pw.print((getInactiveDuration()/1000)); pw.println("s)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 427 | } |
| 428 | |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 429 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 430 | public String toString() { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 431 | StringBuilder sb = new StringBuilder(128); |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 432 | if (stringName != null) { |
| 433 | sb.append(stringName); |
| 434 | sb.append(" U="); |
| 435 | sb.append(userId); |
| 436 | sb.append(" sz="); |
| 437 | sb.append(mActivities.size()); |
| 438 | sb.append('}'); |
| 439 | return sb.toString(); |
| 440 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 441 | sb.append("TaskRecord{"); |
| 442 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 443 | sb.append(" #"); |
| 444 | sb.append(taskId); |
| 445 | if (affinity != null) { |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 446 | sb.append(" A="); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 447 | sb.append(affinity); |
| 448 | } else if (intent != null) { |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 449 | sb.append(" I="); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 450 | sb.append(intent.getComponent().flattenToShortString()); |
| 451 | } else if (affinityIntent != null) { |
Craig Mautner | 5d9c7be | 2013-02-15 14:02:56 -0800 | [diff] [blame] | 452 | sb.append(" aI="); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 453 | sb.append(affinityIntent.getComponent().flattenToShortString()); |
| 454 | } else { |
| 455 | sb.append(" ??"); |
| 456 | } |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 457 | stringName = sb.toString(); |
| 458 | return toString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 459 | } |
| 460 | } |