resolve merge conflicts of 2322ea5 to master.
Change-Id: I1570e633bf0d552a32d7fa9a2e0ebd81953f632b
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 2935bc0..df4b6d6 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -2363,7 +2363,7 @@
return mAppBindArgs;
}
- final void setFocusedActivityLocked(ActivityRecord r) {
+ final void setFocusedActivityLocked(ActivityRecord r, String reason) {
if (mFocusedActivity != r) {
if (DEBUG_FOCUS) Slog.d(TAG, "setFocusedActivityLocked: r=" + r);
mFocusedActivity = r;
@@ -2372,7 +2372,7 @@
} else {
finishRunningVoiceLocked();
}
- mStackSupervisor.setFocusedStack(r);
+ mStackSupervisor.setFocusedStack(r, reason + " setFocusedActivity");
if (r != null) {
mWindowManager.setFocusedApp(r.appToken, true);
}
@@ -2396,7 +2396,7 @@
if (stack != null) {
ActivityRecord r = stack.topRunningActivityLocked(null);
if (r != null) {
- setFocusedActivityLocked(r);
+ setFocusedActivityLocked(r, "setFocusedStack");
}
}
}
@@ -2440,7 +2440,7 @@
mHandler.sendMessage(msg);
}
- private final int updateLruProcessInternalLocked(ProcessRecord app, long now, int index,
+ private int updateLruProcessInternalLocked(ProcessRecord app, long now, int index,
String what, Object obj, ProcessRecord srcApp) {
app.lastActivityTime = now;
@@ -3114,7 +3114,7 @@
return intent;
}
- boolean startHomeActivityLocked(int userId) {
+ boolean startHomeActivityLocked(int userId, String reason) {
if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL
&& mTopAction == null) {
// We are running in factory test mode, but unable to find
@@ -3136,7 +3136,7 @@
aInfo.applicationInfo.uid, true);
if (app == null || app.instrumentationClass == null) {
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
- mStackSupervisor.startHomeActivity(intent, aInfo);
+ mStackSupervisor.startHomeActivity(intent, aInfo, reason);
}
}
@@ -5697,7 +5697,7 @@
startProcessLocked(procs.get(ip), "on-hold", null);
}
}
-
+
if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
// Start looking for apps that are abusing wake locks.
Message nmsg = mHandler.obtainMessage(CHECK_EXCESSIVE_WAKE_LOCKS_MSG);
@@ -5837,7 +5837,7 @@
synchronized (this) {
ActivityStack stack = ActivityRecord.getStackLocked(token);
if (stack != null) {
- stack.activityDestroyedLocked(token);
+ stack.activityDestroyedLocked(token, "activityDestroyed");
}
}
}
@@ -5948,7 +5948,7 @@
throw new IllegalArgumentException("File descriptors passed in options");
}
}
-
+
synchronized(this) {
int callingUid = Binder.getCallingUid();
int origUserId = userId;
@@ -5978,7 +5978,7 @@
return getIntentSenderLocked(type, packageName, callingUid, userId,
token, resultWho, requestCode, intents, resolvedTypes, flags, options);
-
+
} catch (RemoteException e) {
throw new SecurityException(e);
}
@@ -8019,7 +8019,7 @@
if (prev != null && prev.isRecentsActivity()) {
task.setTaskToReturnTo(ActivityRecord.RECENTS_ACTIVITY_TYPE);
}
- mStackSupervisor.findTaskToMoveToFrontLocked(task, flags, options);
+ mStackSupervisor.findTaskToMoveToFrontLocked(task, flags, options, "moveTaskToFront");
} finally {
Binder.restoreCallingIdentity(origId);
}
@@ -8048,7 +8048,7 @@
mStackSupervisor.showLockTaskToast();
return false;
}
- return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId, null);
+ return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId);
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -8154,7 +8154,7 @@
try {
if (DEBUG_STACK) Slog.d(TAG, "moveTaskToStack: moving task=" + taskId + " to stackId="
+ stackId + " toTop=" + toTop);
- mStackSupervisor.moveTaskToStack(taskId, stackId, toTop);
+ mStackSupervisor.moveTaskToStackLocked(taskId, stackId, toTop);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -8260,7 +8260,8 @@
|| (task != mStackSupervisor.getFocusedStack().topTask()))) {
throw new IllegalArgumentException("Invalid task, not in foreground");
}
- mStackSupervisor.setLockTaskModeLocked(task, !isSystemInitiated);
+ mStackSupervisor.setLockTaskModeLocked(task, !isSystemInitiated,
+ "startLockTask");
}
}
} finally {
@@ -8345,7 +8346,7 @@
Log.d(TAG, "stopLockTaskMode");
// Stop lock task
synchronized (this) {
- mStackSupervisor.setLockTaskModeLocked(null, false);
+ mStackSupervisor.setLockTaskModeLocked(null, false, "stopLockTask");
}
} finally {
Binder.restoreCallingIdentity(ident);
@@ -10811,7 +10812,7 @@
// Start up initial activity.
mBooting = true;
- startHomeActivityLocked(mCurrentUserId);
+ startHomeActivityLocked(mCurrentUserId, "systemReady");
try {
if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
@@ -18366,7 +18367,7 @@
return true;
}
- mStackSupervisor.setLockTaskModeLocked(null, false);
+ mStackSupervisor.setLockTaskModeLocked(null, false, "startUser");
final UserInfo userInfo = getUserManagerLocked().getUserInfo(userId);
if (userInfo == null) {
@@ -18623,7 +18624,7 @@
void moveUserToForeground(UserStartedState uss, int oldUserId, int newUserId) {
boolean homeInFront = mStackSupervisor.switchUserLocked(newUserId, uss);
if (homeInFront) {
- startHomeActivityLocked(newUserId);
+ startHomeActivityLocked(newUserId, "moveUserToFroreground");
} else {
mStackSupervisor.resumeTopActivitiesLocked();
}
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index af6a314..6573521 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -515,7 +515,7 @@
void setTask(TaskRecord newTask, TaskRecord taskToAffiliateWith) {
if (task != null && task.removeActivity(this)) {
if (task != newTask) {
- task.stack.removeTask(task);
+ task.stack.removeTask(task, "setTask");
} else {
Slog.d(TAG, "!!! REMOVE THIS LOG !!! setTask: nearly removed stack=" +
(newTask == null ? null : newTask.stack));
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 5d21de7..13df444 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -292,7 +292,7 @@
// so we need to be conservative and assume it isn't.
Slog.w(TAG, "Activity destroy timeout for " + r);
synchronized (mService) {
- activityDestroyedLocked(r != null ? r.appToken : null);
+ activityDestroyedLocked(r != null ? r.appToken : null, "destroyTimeout");
}
} break;
case STOP_TIMEOUT_MSG: {
@@ -476,10 +476,10 @@
mActivityContainer.mActivityDisplay.mDisplayId == Display.DEFAULT_DISPLAY;
}
- final void moveToFront() {
+ final void moveToFront(String reason) {
if (isAttached()) {
if (isOnHomeDisplay()) {
- mStackSupervisor.moveHomeStack(isHomeStack());
+ mStackSupervisor.moveHomeStack(isHomeStack(), reason);
}
mStacks.remove(this);
mStacks.add(this);
@@ -1497,7 +1497,7 @@
final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ?
HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo();
return isOnHomeDisplay() &&
- mStackSupervisor.resumeHomeStackTask(returnTaskType, prev);
+ mStackSupervisor.resumeHomeStackTask(returnTaskType, prev, "noMoreActivities");
}
next.delayedResume = false;
@@ -1533,7 +1533,7 @@
"resumeTopActivityLocked: Launching home next");
final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ?
HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo();
- return mStackSupervisor.resumeHomeStackTask(returnTaskType, prev);
+ return mStackSupervisor.resumeHomeStackTask(returnTaskType, prev, "prevFinished");
}
}
@@ -1819,11 +1819,8 @@
next.app.thread.scheduleNewIntent(next.newIntents, next.appToken);
}
- EventLog.writeEvent(EventLogTags.AM_RESUME_ACTIVITY,
- next.userId, System.identityHashCode(next),
- next.task.taskId, next.shortComponentName + " top="
- + mStacks.get(mStacks.size() - 1).mStackId + " Callers="
- + Debug.getCallers(6));
+ EventLog.writeEvent(EventLogTags.AM_RESUME_ACTIVITY, next.userId,
+ System.identityHashCode(next), next.task.taskId, next.shortComponentName);
next.sleeping = false;
mService.showAskCompatModeDialogLocked(next);
@@ -2472,18 +2469,19 @@
r.addResultLocked(null, resultWho, requestCode, resultCode, data);
}
- private void adjustFocusedActivityLocked(ActivityRecord r) {
+ private void adjustFocusedActivityLocked(ActivityRecord r, String reason) {
if (mStackSupervisor.isFrontStack(this) && mService.mFocusedActivity == r) {
ActivityRecord next = topRunningActivityLocked(null);
if (next != r) {
final TaskRecord task = r.task;
if (r.frontOfTask && task == topTask() && task.isOverHomeStack()) {
- mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo());
+ mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo(),
+ reason + " adjustFocus");
}
}
ActivityRecord top = mStackSupervisor.topRunningActivityLocked();
if (top != null) {
- mService.setFocusedActivityLocked(top);
+ mService.setFocusedActivityLocked(top, reason + " adjustTopFocus");
}
}
}
@@ -2507,7 +2505,7 @@
}
if (r.app != null && r.app.thread != null) {
- adjustFocusedActivityLocked(r);
+ adjustFocusedActivityLocked(r, "stopActivity");
r.resumeKeyDispatchingLocked();
try {
r.stopped = false;
@@ -2711,7 +2709,7 @@
r.pauseKeyDispatchingLocked();
- adjustFocusedActivityLocked(r);
+ adjustFocusedActivityLocked(r, "finishActivity");
finishActivityResultsLocked(r, resultCode, resultData);
@@ -3014,7 +3012,7 @@
r.finishLaunchTickingLocked();
}
- private void removeActivityFromHistoryLocked(ActivityRecord r) {
+ private void removeActivityFromHistoryLocked(ActivityRecord r, String reason) {
mStackSupervisor.removeChildActivityContainers(r);
finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
r.makeFinishing();
@@ -3039,9 +3037,9 @@
"removeActivityFromHistoryLocked: last activity removed from " + this);
if (mStackSupervisor.isFrontStack(this) && task == topTask() &&
task.isOverHomeStack()) {
- mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo());
+ mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo(), reason);
}
- removeTask(task);
+ removeTask(task, reason);
}
cleanUpActivityServicesLocked(r);
r.removeUriPermissionsLocked();
@@ -3206,7 +3204,7 @@
// up.
//Slog.w(TAG, "Exception thrown during finish", e);
if (r.finishing) {
- removeActivityFromHistoryLocked(r);
+ removeActivityFromHistoryLocked(r, reason + " exceptionInScheduleDestroy");
removedFromHistory = true;
skipDestroy = true;
}
@@ -3236,7 +3234,7 @@
} else {
// remove this record from the history.
if (r.finishing) {
- removeActivityFromHistoryLocked(r);
+ removeActivityFromHistoryLocked(r, reason + " hadNoApp");
removedFromHistory = true;
} else {
if (DEBUG_STATES) Slog.v(TAG, "Moving to DESTROYED: " + r + " (no app)");
@@ -3255,7 +3253,7 @@
return removedFromHistory;
}
- final void activityDestroyedLocked(IBinder token) {
+ final void activityDestroyedLocked(IBinder token, String reason) {
final long origId = Binder.clearCallingIdentity();
try {
ActivityRecord r = ActivityRecord.forToken(token);
@@ -3267,7 +3265,7 @@
if (isInStackLocked(token) != null) {
if (r.state == ActivityState.DESTROYING) {
cleanUpActivityLocked(r, true, false);
- removeActivityFromHistoryLocked(r);
+ removeActivityFromHistoryLocked(r, reason);
}
}
mStackSupervisor.resumeTopActivitiesLocked();
@@ -3403,7 +3401,7 @@
mService.updateUsageStats(r, false);
}
}
- removeActivityFromHistoryLocked(r);
+ removeActivityFromHistoryLocked(r, "appDied");
} else {
// We have the current state for this activity, so
@@ -3472,15 +3470,16 @@
}
}
- final void moveTaskToFrontLocked(TaskRecord tr, ActivityRecord reason, Bundle options) {
+ final void moveTaskToFrontLocked(TaskRecord tr, ActivityRecord source, Bundle options,
+ String reason) {
if (DEBUG_SWITCH) Slog.v(TAG, "moveTaskToFront: " + tr);
final int numTasks = mTaskHistory.size();
final int index = mTaskHistory.indexOf(tr);
if (numTasks == 0 || index < 0) {
// nothing to do!
- if (reason != null &&
- (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
+ if (source != null &&
+ (source.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
ActivityOptions.abort(options);
} else {
updateTransitLocked(AppTransition.TRANSIT_TASK_TO_FRONT, options);
@@ -3491,11 +3490,11 @@
// Shift all activities with this task up to the top
// of the stack, keeping them in the same internal order.
insertTaskAtTop(tr);
- moveToFront();
+ moveToFront(reason);
if (DEBUG_TRANSITION) Slog.v(TAG, "Prepare to front transition: task=" + tr);
- if (reason != null &&
- (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
+ if (source != null &&
+ (source.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
ActivityRecord r = topRunningActivityLocked(null);
if (r != null) {
@@ -3525,7 +3524,7 @@
* @param taskId The taskId to collect and move to the bottom.
* @return Returns true if the move completed, false if not.
*/
- final boolean moveTaskToBackLocked(int taskId, ActivityRecord reason) {
+ final boolean moveTaskToBackLocked(int taskId) {
final TaskRecord tr = taskForIdLocked(taskId);
if (tr == null) {
Slog.i(TAG, "moveTaskToBack: bad taskId=" + taskId);
@@ -3580,16 +3579,7 @@
}
}
- if (reason != null &&
- (reason.intent.getFlags() & Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
- mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
- ActivityRecord r = topRunningActivityLocked(null);
- if (r != null) {
- mNoAnimActivities.add(r);
- }
- } else {
- mWindowManager.prepareAppTransition(AppTransition.TRANSIT_TASK_TO_BACK, false);
- }
+ mWindowManager.prepareAppTransition(AppTransition.TRANSIT_TASK_TO_BACK, false);
mWindowManager.moveTaskToBottom(taskId);
if (VALIDATE_TOKENS) {
@@ -3604,7 +3594,7 @@
}
final int taskToReturnTo = tr.getTaskToReturnTo();
tr.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE);
- return mStackSupervisor.resumeHomeStackTask(taskToReturnTo, null);
+ return mStackSupervisor.resumeHomeStackTask(taskToReturnTo, null, "moveTaskToBack");
}
mStackSupervisor.resumeTopActivitiesLocked();
@@ -4046,7 +4036,7 @@
return starting;
}
- void removeTask(TaskRecord task) {
+ void removeTask(TaskRecord task, String reason) {
mStackSupervisor.endLockTaskModeIfTaskEnding(task);
mWindowManager.removeTask(task.taskId);
final ActivityRecord r = mResumedActivity;
@@ -4084,7 +4074,7 @@
if (mTaskHistory.isEmpty()) {
if (DEBUG_STACK) Slog.i(TAG, "removeTask: moving to back stack=" + this);
if (isOnHomeDisplay()) {
- mStackSupervisor.moveHomeStack(!isHomeStack());
+ mStackSupervisor.moveHomeStack(!isHomeStack(), reason + " leftTaskHistoryEmpty");
}
if (mStacks != null) {
mStacks.remove(this);
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 4cf8f00..b7728b3 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -399,7 +399,7 @@
return false;
}
- void moveHomeStack(boolean toFront) {
+ void moveHomeStack(boolean toFront, String reason) {
ArrayList<ActivityStack> stacks = mHomeStack.mStacks;
final int topNdx = stacks.size() - 1;
if (topNdx <= 0) {
@@ -417,7 +417,7 @@
}
EventLog.writeEvent(EventLogTags.AM_HOME_STACK_MOVED,
mCurrentUser, toFront ? 1 : 0, stacks.get(topNdx).getStackId(),
- mFocusedStack == null ? -1 : mFocusedStack.getStackId());
+ mFocusedStack == null ? -1 : mFocusedStack.getStackId(), reason);
if (mService.mBooting || !mService.mBooted) {
final ActivityRecord r = topRunningActivityLocked();
@@ -427,16 +427,16 @@
}
}
- void moveHomeStackTaskToTop(int homeStackTaskType) {
+ void moveHomeStackTaskToTop(int homeStackTaskType, String reason) {
if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) {
mWindowManager.showRecentApps();
return;
}
- moveHomeStack(true);
+ moveHomeStack(true, reason);
mHomeStack.moveHomeStackTaskToTop(homeStackTaskType);
}
- boolean resumeHomeStackTask(int homeStackTaskType, ActivityRecord prev) {
+ boolean resumeHomeStackTask(int homeStackTaskType, ActivityRecord prev, String reason) {
if (!mService.mBooting && !mService.mBooted) {
// Not ready yet!
return false;
@@ -446,7 +446,7 @@
mWindowManager.showRecentApps();
return false;
}
- moveHomeStackTaskToTop(homeStackTaskType);
+ moveHomeStackTaskToTop(homeStackTaskType, reason);
if (prev != null) {
prev.task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE);
}
@@ -454,10 +454,10 @@
ActivityRecord r = mHomeStack.topRunningActivityLocked(null);
// if (r != null && (r.isHomeActivity() || r.isRecentsActivity())) {
if (r != null && r.isHomeActivity()) {
- mService.setFocusedActivityLocked(r);
+ mService.setFocusedActivityLocked(r, reason);
return resumeTopActivitiesLocked(mHomeStack, prev, null);
}
- return mService.startHomeActivityLocked(mCurrentUser);
+ return mService.startHomeActivityLocked(mCurrentUser, reason);
}
TaskRecord anyTaskForIdLocked(int id) {
@@ -829,8 +829,8 @@
return aInfo;
}
- void startHomeActivity(Intent intent, ActivityInfo aInfo) {
- moveHomeStackTaskToTop(HOME_ACTIVITY_TYPE);
+ void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason) {
+ moveHomeStackTaskToTop(HOME_ACTIVITY_TYPE, reason);
startActivityLocked(null, intent, null, aInfo, null, null, null, null, 0, 0, 0, null,
0, 0, 0, null, false, null, null, null);
}
@@ -1581,7 +1581,7 @@
return mHomeStack;
}
- void setFocusedStack(ActivityRecord r) {
+ void setFocusedStack(ActivityRecord r, String reason) {
if (r != null) {
final TaskRecord task = r.task;
boolean isHomeActivity = !r.isApplicationActivity();
@@ -1592,7 +1592,7 @@
final ActivityRecord parent = task.stack.mActivityContainer.mParentActivity;
isHomeActivity = parent != null && parent.isHomeActivity();
}
- moveHomeStack(isHomeActivity);
+ moveHomeStack(isHomeActivity, reason);
}
}
@@ -1840,7 +1840,7 @@
targetStack.mLastPausedActivity = null;
if (DEBUG_TASKS) Slog.d(TAG, "Bring to front target: " + targetStack
+ " from " + intentActivity);
- targetStack.moveToFront();
+ targetStack.moveToFront("intentActivityFound");
if (intentActivity.task.intent == null) {
// This task was started because of movement of
// the activity based on affinity... now that we
@@ -1869,7 +1869,8 @@
intentActivity.setTaskToAffiliateWith(sourceRecord.task);
}
movedHome = true;
- targetStack.moveTaskToFrontLocked(intentActivity.task, r, options);
+ targetStack.moveTaskToFrontLocked(intentActivity.task, r, options,
+ "bringingFoundTaskToFront");
if ((launchFlags &
(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME))
== (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) {
@@ -2067,7 +2068,7 @@
newTask = true;
targetStack = adjustStackFocus(r, newTask);
if (!launchTaskBehind) {
- targetStack.moveToFront();
+ targetStack.moveToFront("startingNewTask");
}
if (reuseTask == null) {
r.setTask(targetStack.createTaskRecord(getNextTaskId(),
@@ -2096,10 +2097,10 @@
return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
}
targetStack = sourceTask.stack;
- targetStack.moveToFront();
+ targetStack.moveToFront("sourceStackToFront");
final TaskRecord topTask = targetStack.topTask();
if (topTask != sourceTask) {
- targetStack.moveTaskToFrontLocked(sourceTask, r, options);
+ targetStack.moveTaskToFrontLocked(sourceTask, r, options, "sourceTaskToFront");
}
if (!addingToTask && (launchFlags&Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
// In this case, we are adding the activity to an existing
@@ -2153,7 +2154,7 @@
return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
}
targetStack = inTask.stack;
- targetStack.moveTaskToFrontLocked(inTask, r, options);
+ targetStack.moveTaskToFrontLocked(inTask, r, options, "inTaskToFront");
// Check whether we should actually launch the new activity in to the task,
// or just reuse the current activity on top.
@@ -2189,7 +2190,7 @@
// of a new task... just put it in the top task, though these days
// this case should never happen.
targetStack = adjustStackFocus(r, newTask);
- targetStack.moveToFront();
+ targetStack.moveToFront("addingToTopTask");
ActivityRecord prev = targetStack.topActivity();
r.setTask(prev != null ? prev.task : targetStack.createTaskRecord(getNextTaskId(),
r.info, intent, null, null, true), null);
@@ -2212,7 +2213,7 @@
targetStack.startActivityLocked(r, newTask, doResume, keepCurTransition, options);
if (!launchTaskBehind) {
// Don't set focus on an activity that's going to the back.
- mService.setFocusedActivityLocked(r);
+ mService.setFocusedActivityLocked(r, "startedActivity");
}
return ActivityManager.START_SUCCESS;
}
@@ -2509,7 +2510,7 @@
}
}
- void findTaskToMoveToFrontLocked(TaskRecord task, int flags, Bundle options) {
+ void findTaskToMoveToFrontLocked(TaskRecord task, int flags, Bundle options, String reason) {
if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
mUserLeaving = true;
}
@@ -2518,7 +2519,7 @@
// we'll just indicate that this task returns to the home task.
task.setTaskToReturnTo(HOME_ACTIVITY_TYPE);
}
- task.stack.moveTaskToFrontLocked(task, null, options);
+ task.stack.moveTaskToFrontLocked(task, null, options, reason);
if (DEBUG_STACK) Slog.d(TAG, "findTaskToMoveToFront: moved to front of stack="
+ task.stack);
}
@@ -2643,7 +2644,7 @@
// display.
stack = createStackOnDisplay(getNextStackId(), Display.DEFAULT_DISPLAY);
// Restore home stack to top.
- moveHomeStack(true);
+ moveHomeStack(true, "restoreRecentTask");
if (DEBUG_RECENTS)
Slog.v(TAG, "Created stack=" + stack + " for recents restoration.");
}
@@ -2670,7 +2671,7 @@
return true;
}
- void moveTaskToStack(int taskId, int stackId, boolean toTop) {
+ void moveTaskToStackLocked(int taskId, int stackId, boolean toTop) {
final TaskRecord task = anyTaskForIdLocked(taskId);
if (task == null) {
return;
@@ -2680,7 +2681,7 @@
Slog.w(TAG, "moveTaskToStack: no stack for id=" + stackId);
return;
}
- task.stack.removeTask(task);
+ task.stack.removeTask(task, "moveTaskToStack");
stack.addTask(task, toTop, true);
mWindowManager.addTask(taskId, stackId, toTop);
resumeTopActivitiesLocked();
@@ -3046,14 +3047,14 @@
}
final boolean homeInFront = stack.isHomeStack();
if (stack.isOnHomeDisplay()) {
- moveHomeStack(homeInFront);
+ moveHomeStack(homeInFront, "switchUserOnHomeDisplay");
TaskRecord task = stack.topTask();
if (task != null) {
mWindowManager.moveTaskToTop(task.taskId);
}
} else {
// Stack was moved to another display while user was swapped out.
- resumeHomeStackTask(HOME_ACTIVITY_TYPE, null);
+ resumeHomeStackTask(HOME_ACTIVITY_TYPE, null, "switchUserOnOtherDisplay");
}
return homeInFront;
}
@@ -3448,7 +3449,7 @@
mLockTaskNotify.showToast(mLockTaskIsLocked);
}
- void setLockTaskModeLocked(TaskRecord task, boolean isLocked) {
+ void setLockTaskModeLocked(TaskRecord task, boolean isLocked, String reason) {
if (task == null) {
// Take out of lock task mode if necessary
if (mLockTaskModeTask != null) {
@@ -3465,7 +3466,7 @@
return;
}
mLockTaskModeTask = task;
- findTaskToMoveToFrontLocked(task, 0, null);
+ findTaskToMoveToFrontLocked(task, 0, null, reason);
resumeTopActivitiesLocked();
final Message lockTaskMsg = Message.obtain();
diff --git a/services/core/java/com/android/server/am/EventLogTags.logtags b/services/core/java/com/android/server/am/EventLogTags.logtags
index 41499be..c376744 100644
--- a/services/core/java/com/android/server/am/EventLogTags.logtags
+++ b/services/core/java/com/android/server/am/EventLogTags.logtags
@@ -94,4 +94,4 @@
30043 am_focused_activity (User|1|5),(Component Name|3)
# Home Stack brought to front or rear
-30044 am_home_stack_moved (User|1|5),(To Front|1|5),(Top Stack Id|1|5),(Focused Stack Id|1|5)
+30044 am_home_stack_moved (User|1|5),(To Front|1|5),(Top Stack Id|1|5),(Focused Stack Id|1|5),(Reason|3)