Log stack issues and start resize effort.
- Modify Am.java to accept 'stack resize' command.
- Add logging for assigning home stack to non-home task to track down
bug. And maybe fix bug.
- Add template parameter to ArrayList.
Change-Id: If904c3ead623464ff5863b7241c68c1b7573bcf4
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index ce71e4a..cc69176 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -104,6 +104,7 @@
" am stop-user <USER_ID>\n" +
" am stack create <TASK_ID> <RELATIVE_STACK_ID> <POSITION> <WEIGHT>\n" +
" am stack movetask <STACK_ID> <TASK_ID> [true|false]\n" +
+ " am stack resize <STACK_ID> <WEIGHT>\n" +
" am stack dump\n" +
"\n" +
"am start: start an Activity. Options are:\n" +
@@ -199,6 +200,8 @@
"am stack movetask: move <TASK_ID> from its current stack to the top (true) or" +
" bottom (false) of <STACK_ID>.\n" +
"\n" +
+ "am stack resize: change <STACK_ID> relative size to new <WEIGHT>.\n" +
+ "\n" +
"am stack dump: list the hierarchy of stacks.\n" +
"\n" +
"<INTENT> specifications include these flags and arguments:\n" +
@@ -1481,6 +1484,8 @@
runStackCreate();
} else if (op.equals("movetask")) {
runStackMoveTask();
+ } else if (op.equals("resize")) {
+ runStackResize();
} else if (op.equals("dump")) {
runStackDump();
} else {
@@ -1528,6 +1533,18 @@
}
}
+ private void runStackResize() throws Exception {
+ String stackIdStr = nextArgRequired();
+ int stackId = Integer.valueOf(stackIdStr);
+ String weightStr = nextArgRequired();
+ float weight = Float.valueOf(weightStr);
+
+ try {
+ mAm.resizeStack(stackId, weight);
+ } catch (RemoteException e) {
+ }
+ }
+
private void runStackDump() throws Exception {
try {
List<ActivityManager.StackInfo> stacks = mAm.getStacks();
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index fad1bc5..21a45e9 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6326,6 +6326,11 @@
@Override
public void moveTaskToStack(int taskId, int stackId, boolean toTop) {
+ if (stackId == HOME_STACK_ID) {
+ Slog.e(TAG, "moveTaskToStack: Attempt to move task to home stack",
+ new RuntimeException("here").fillInStackTrace());
+ return;
+ }
synchronized (this) {
mWindowManager.moveTaskToStack(taskId, stackId, toTop);
mStackSupervisor.moveTaskToStack(taskId, stackId, toTop);
@@ -6388,8 +6393,8 @@
final void sendPendingThumbnail(ActivityRecord r, IBinder token,
Bitmap thumbnail, CharSequence description, boolean always) {
- TaskRecord task = null;
- ArrayList receivers = null;
+ TaskRecord task;
+ ArrayList<PendingThumbnailsRecord> receivers = null;
//System.out.println("Send pending thumbnail: " + r);
@@ -6415,12 +6420,11 @@
int N = mPendingThumbnails.size();
int i=0;
while (i<N) {
- PendingThumbnailsRecord pr =
- (PendingThumbnailsRecord)mPendingThumbnails.get(i);
+ PendingThumbnailsRecord pr = mPendingThumbnails.get(i);
//System.out.println("Looking in " + pr.pendingRecords);
if (pr.pendingRecords.remove(r)) {
if (receivers == null) {
- receivers = new ArrayList();
+ receivers = new ArrayList<PendingThumbnailsRecord>();
}
receivers.add(pr);
if (pr.pendingRecords.size() == 0) {
@@ -6438,8 +6442,7 @@
final int N = receivers.size();
for (int i=0; i<N; i++) {
try {
- PendingThumbnailsRecord pr =
- (PendingThumbnailsRecord)receivers.get(i);
+ PendingThumbnailsRecord pr = receivers.get(i);
pr.receiver.newThumbnail(
task != null ? task.taskId : -1, thumbnail, description);
if (pr.finished) {
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index f7f0812..59a674e 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -304,7 +304,7 @@
final int stackId = stack.mStackId;
final int nextStackId = mWindowManager.removeStack(stackId);
// TODO: Perhaps we need to let the ActivityManager determine the next focus...
- if (mFocusedStack.mStackId == stackId) {
+ if (getFocusedStack().mStackId == stackId) {
mFocusedStack = nextStackId == HOME_STACK_ID ? null : getStack(nextStackId);
}
}
@@ -1189,6 +1189,13 @@
mStackState = STACK_STATE_HOME_TO_FRONT;
}
} else {
+ if (r.task.stack == mHomeStack) {
+ // Try to correct, but how did we get here?
+ Slog.e(TAG, "!!! setFocusedStack: home stack used for non-home activity !!!",
+ new RuntimeException("here").fillInStackTrace());
+ moveTaskToStack(r.task.taskId, getCorrectStack(r).mStackId, true);
+ // r.task.stack has now changed.
+ }
mFocusedStack = r.task.stack;
if (mStackState != STACK_STATE_HOME_IN_BACK) {
mStackState = STACK_STATE_HOME_TO_BACK;
@@ -1598,10 +1605,9 @@
// This not being started from an existing activity, and not part
// of a new task... just put it in the top task, though these days
// this case should never happen.
- ActivityStack lastStack = getLastStack();
- targetStack = lastStack != null ? lastStack : mHomeStack;
+ targetStack = getCorrectStack(r);
moveHomeStack(targetStack.isHomeStack());
- ActivityRecord prev = lastStack == null ? null : targetStack.topActivity();
+ ActivityRecord prev = targetStack.topActivity();
r.setTask(prev != null ? prev.task
: targetStack.createTaskRecord(getNextTaskId(), r.info, intent, true),
null, true);