summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWale Ogunwale <ogunwale@google.com>2015-01-05 22:14:47 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-01-05 22:14:47 +0000
commit62fbd4feb1bccfdfa08a96c71eb5a1b102ac4c2c (patch)
treedd9fc7bd4eb5858ba9c23e8162c4bf40d91d8bcf
parent7768fd2f8e412f87300882bfa5f205944425fd0f (diff)
parentb8e51390af6015c1eaff7679546a5a7d2dfa701d (diff)
downloadframeworks_base-62fbd4feb1bccfdfa08a96c71eb5a1b102ac4c2c.zip
frameworks_base-62fbd4feb1bccfdfa08a96c71eb5a1b102ac4c2c.tar.gz
frameworks_base-62fbd4feb1bccfdfa08a96c71eb5a1b102ac4c2c.tar.bz2
am 170a678c: am 1d893785: Merge "Don\'t restore persistent task to a stack until needed." into lmp-mr1-dev
automerge: b8e5139 * commit 'b8e51390af6015c1eaff7679546a5a7d2dfa701d': Don't restore persistent task to a stack until needed.
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java26
-rw-r--r--services/core/java/com/android/server/am/ActivityStackSupervisor.java77
2 files changed, 67 insertions, 36 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index d6fb1fe..3be3cf1 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8182,17 +8182,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
- private TaskRecord taskForIdLocked(int id) {
- final TaskRecord task = recentTaskForIdLocked(id);
- if (task != null) {
- return task;
- }
-
- // Don't give up. Sometimes it just hasn't made it to recents yet.
- return mStackSupervisor.anyTaskForIdLocked(id);
- }
-
- private TaskRecord recentTaskForIdLocked(int id) {
+ TaskRecord recentTaskForIdLocked(int id) {
final int N = mRecentTasks.size();
for (int i=0; i<N; i++) {
TaskRecord tr = mRecentTasks.get(i);
@@ -8208,7 +8198,7 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized (this) {
enforceCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER,
"getTaskThumbnail()");
- TaskRecord tr = recentTaskForIdLocked(id);
+ TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(id);
if (tr != null) {
return tr.getTaskThumbnailLocked();
}
@@ -8453,7 +8443,7 @@ public final class ActivityManagerService extends ActivityManagerNative
* @return Returns true if the given task was found and removed.
*/
private boolean removeTaskByIdLocked(int taskId, boolean killProcess) {
- TaskRecord tr = taskForIdLocked(taskId);
+ TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(taskId);
if (tr != null) {
tr.removeTaskActivitiesLocked();
cleanUpRemovedTaskLocked(tr, killProcess);
@@ -8529,7 +8519,7 @@ public final class ActivityManagerService extends ActivityManagerNative
"moveTaskToBack()");
synchronized(this) {
- TaskRecord tr = taskForIdLocked(taskId);
+ TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(taskId);
if (tr != null) {
if (tr == mStackSupervisor.mLockTaskModeTask) {
mStackSupervisor.showLockTaskToast();
@@ -8721,7 +8711,7 @@ public final class ActivityManagerService extends ActivityManagerNative
long ident = Binder.clearCallingIdentity();
try {
synchronized (this) {
- TaskRecord tr = taskForIdLocked(taskId);
+ TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(taskId);
return tr != null && tr.stack != null && tr.stack.isHomeStack();
}
} finally {
@@ -11178,9 +11168,6 @@ public final class ActivityManagerService extends ActivityManagerNative
if (mRecentTasks == null) {
mRecentTasks = mTaskPersister.restoreTasksLocked();
mTaskPersister.restoreTasksFromOtherDeviceLocked();
- if (!mRecentTasks.isEmpty()) {
- mStackSupervisor.createStackForRestoredTaskHistory(mRecentTasks);
- }
cleanupRecentTasksLocked(UserHandle.USER_ALL);
mTaskPersister.startPersisting();
}
@@ -11197,8 +11184,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mDidUpdate = true;
}
writeLastDonePreBootReceivers(doneReceivers);
- showBootMessage(mContext.getText(
- R.string.android_upgrading_complete),
+ showBootMessage(mContext.getText(R.string.android_upgrading_complete),
false);
systemReady(goingCallback);
}
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index f164a7c..a612575 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -24,6 +24,7 @@ import static com.android.server.am.ActivityManagerService.localLOGV;
import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION;
import static com.android.server.am.ActivityManagerService.DEBUG_FOCUS;
import static com.android.server.am.ActivityManagerService.DEBUG_PAUSE;
+import static com.android.server.am.ActivityManagerService.DEBUG_RECENTS;
import static com.android.server.am.ActivityManagerService.DEBUG_RESULTS;
import static com.android.server.am.ActivityManagerService.DEBUG_STACK;
import static com.android.server.am.ActivityManagerService.DEBUG_SWITCH;
@@ -460,7 +461,21 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
}
}
- return null;
+
+ // Don't give up! Look in recents.
+ if (DEBUG_RECENTS) Slog.v(TAG, "Looking for task id=" + id + " in recents");
+ TaskRecord task = mService.recentTaskForIdLocked(id);
+ if (task == null) {
+ if (DEBUG_RECENTS) Slog.d(TAG, "\tDidn't find task id=" + id + " in recents");
+ return null;
+ }
+
+ if (!restoreRecentTaskLocked(task)) {
+ if (DEBUG_RECENTS) Slog.w(TAG, "Couldn't restore task id=" + id + " found in recents");
+ return null;
+ }
+ if (DEBUG_RECENTS) Slog.w(TAG, "Restored task id=" + id + " from in recents");
+ return task;
}
ActivityRecord isInAnyStackLocked(IBinder token) {
@@ -2586,23 +2601,53 @@ public final class ActivityStackSupervisor implements DisplayListener {
return mLastStackId;
}
- void createStackForRestoredTaskHistory(ArrayList<TaskRecord> tasks) {
- int stackId = createStackOnDisplay(getNextStackId(), Display.DEFAULT_DISPLAY);
- final ActivityStack stack = getStack(stackId);
- for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
- final TaskRecord task = tasks.get(taskNdx);
- stack.addTask(task, false, false);
- final int taskId = task.taskId;
- final ArrayList<ActivityRecord> activities = task.mActivities;
- for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
- final ActivityRecord r = activities.get(activityNdx);
- mWindowManager.addAppToken(0, r.appToken, taskId, stackId,
- r.info.screenOrientation, r.fullscreen,
- (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0,
- r.userId, r.info.configChanges, task.voiceSession != null,
- r.mLaunchTaskBehind);
+ private boolean restoreRecentTaskLocked(TaskRecord task) {
+ ActivityStack stack = null;
+ // Determine stack to restore task to.
+ if (mLeanbackOnlyDevice) {
+ // There is only one stack for lean back devices.
+ stack = mHomeStack;
+ } else {
+ // Look for the top stack on the home display that isn't the home stack.
+ final ArrayList<ActivityStack> homeDisplayStacks = mHomeStack.mStacks;
+ for (int stackNdx = homeDisplayStacks.size() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack tmpStack = homeDisplayStacks.get(stackNdx);
+ if (!tmpStack.isHomeStack()) {
+ stack = tmpStack;
+ break;
+ }
}
}
+
+ if (stack == null) {
+ // We couldn't find a stack to restore the task to. Possible if are restoring recents
+ // before an application stack is created...Go ahead and create one on the default
+ // display.
+ stack = getStack(createStackOnDisplay(getNextStackId(), Display.DEFAULT_DISPLAY));
+ if (DEBUG_RECENTS)
+ Slog.v(TAG, "Created stack=" + stack + " for recents restoration.");
+ }
+
+ if (stack == null) {
+ // What does this mean??? Not sure how we would get here...
+ if (DEBUG_RECENTS)
+ Slog.v(TAG, "Unable to find/create stack to restore recent task=" + task);
+ return false;
+ }
+
+ stack.addTask(task, false, false);
+ if (DEBUG_RECENTS)
+ Slog.v(TAG, "Added restored task=" + task + " to stack=" + stack);
+ final ArrayList<ActivityRecord> activities = task.mActivities;
+ for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
+ final ActivityRecord r = activities.get(activityNdx);
+ mWindowManager.addAppToken(0, r.appToken, task.taskId, stack.mStackId,
+ r.info.screenOrientation, r.fullscreen,
+ (r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0,
+ r.userId, r.info.configChanges, task.voiceSession != null,
+ r.mLaunchTaskBehind);
+ }
+ return true;
}
void moveTaskToStack(int taskId, int stackId, boolean toTop) {