Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0245eda authored by Craig Mautner's avatar Craig Mautner
Browse files

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
parent 5457e61f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class Am extends BaseCommand {
                "       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 @@ public class Am extends BaseCommand {
                "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 @@ public class Am extends BaseCommand {
            runStackCreate();
        } else if (op.equals("movetask")) {
            runStackMoveTask();
        } else if (op.equals("resize")) {
            runStackResize();
        } else if (op.equals("dump")) {
            runStackDump();
        } else {
@@ -1528,6 +1533,18 @@ public class Am extends BaseCommand {
        }
    }

    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();
+10 −7
Original line number Diff line number Diff line
@@ -6326,6 +6326,11 @@ public final class ActivityManagerService extends ActivityManagerNative
    @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 @@ public final class ActivityManagerService extends ActivityManagerNative
    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 @@ public final class ActivityManagerService extends ActivityManagerNative
            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 @@ public final class ActivityManagerService extends ActivityManagerNative
            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) {
+10 −4
Original line number Diff line number Diff line
@@ -304,7 +304,7 @@ public class ActivityStackSupervisor {
            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 @@ public class ActivityStackSupervisor {
                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 @@ public class ActivityStackSupervisor {
            // 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);