Start moving Tasks from DisplayContent to TaskStack
- Create new classes for Stacks on WindowManager.
- Stop using DisplayContent methods and members:
addAppToken(),
removeAppToken(),
setAppTaskId(),
removeTask(),
mTaskIdToDisplayContents,
mTaskIdToTask.
- Start using WindowManagerService.createTask().
- Establish hierarchy of references: AppWindowToken=>Task=>
TaskStack=>StackBox=>DisplayContent.
- Clean up StackBox, TaskStack, and Task.
Change-Id: I798990aa7966784d22f4a43822087d8bb0404dd6
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index dc11f44..18d9e59 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -67,7 +67,6 @@
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
-import android.util.SparseArray;
import android.view.Display;
import java.io.FileDescriptor;
@@ -309,6 +308,8 @@
private int mCurrentUser;
+ final int mStackId;
+
static final int SLEEP_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG;
static final int PAUSE_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 1;
static final int IDLE_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 2;
@@ -451,7 +452,8 @@
return count;
}
- ActivityStack(ActivityManagerService service, Context context, boolean mainStack, Looper looper) {
+ ActivityStack(ActivityManagerService service, Context context, boolean mainStack, Looper looper,
+ int stackId) {
mHandler = new ActivityStackHandler(looper);
mService = service;
mContext = context;
@@ -461,6 +463,7 @@
mGoingToSleep = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ActivityManager-Sleep");
mLaunchingActivity = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ActivityManager-Launch");
mLaunchingActivity.setReferenceCounted(false);
+ mStackId = stackId;
}
private boolean okToShow(ActivityRecord r) {
@@ -1855,7 +1858,8 @@
task.addActivityToTop(r);
r.putInHistory();
mService.mWindowManager.addAppToken(task.mActivities.indexOf(r),
- r.appToken, r.task.taskId, r.info.screenOrientation, r.fullscreen,
+ r.appToken, r.task.taskId, mStackId, r.info.screenOrientation,
+ r.fullscreen,
(r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0);
if (VALIDATE_TOKENS) {
validateAppTokensLocked();
@@ -1917,7 +1921,7 @@
}
r.updateOptionsLocked(options);
mService.mWindowManager.addAppToken(task.mActivities.indexOf(r),
- r.appToken, r.task.taskId, r.info.screenOrientation, r.fullscreen,
+ r.appToken, r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
(r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0);
boolean doShow = true;
if (newTask) {
@@ -1956,7 +1960,7 @@
// If this is the first activity, don't do any fancy animations,
// because there is nothing for it to animate on top of.
mService.mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken,
- r.task.taskId, r.info.screenOrientation, r.fullscreen,
+ r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
(r.info.flags & ActivityInfo.FLAG_SHOW_ON_LOCK_SCREEN) != 0);
ActivityOptions.abort(options);
}
@@ -5034,4 +5038,26 @@
}
return task;
}
+
+ ArrayList<TaskRecord> getAllTasks() {
+ return new ArrayList<TaskRecord>(mTaskHistory);
+ }
+
+ void moveTask(int taskId, boolean toTop) {
+ final TaskRecord task = mService.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ return;
+ }
+ task.stack.mTaskHistory.remove(task);
+ task.stack = this;
+ if (toTop) {
+ mTaskHistory.add(task);
+ } else {
+ mTaskHistory.add(0, task);
+ }
+ }
+
+ public int getStackId() {
+ return mStackId;
+ }
}