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

Commit d846b723 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Have moveActivityToStack API set focus activity or stack."

parents c2a6916f b30daaa8
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.internal.util.XmlUtils.writeIntAttribute;
import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST;
import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
@@ -8943,17 +8944,29 @@ public final class ActivityManagerService extends ActivityManagerNative
    @Override
    public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
        if (stackId == HOME_STACK_ID) {
            throw new IllegalArgumentException(
                    "moveTaskToStack: Attempt to move token " + token + " to home stack");
        }
        synchronized (this) {
            final long origId = Binder.clearCallingIdentity();
            long ident = Binder.clearCallingIdentity();
            try {
                final ActivityRecord r = ActivityRecord.forTokenLocked(token);
                if (r == null) {
                    throw new IllegalArgumentException(
                            "moveActivityToStack: No activity record matching token=" + token);
                }
                moveTaskToStack(r.task.taskId, stackId, true /*toTop*/);
                if (DEBUG_STACK) Slog.d(TAG_STACK, "moveActivityToStack: moving r=" + r
                        + " to stackId=" + stackId);
                mStackSupervisor.moveTaskToStackLocked(r.task.taskId, stackId, ON_TOP);
                if (mFocusedActivity != r) {
                    setFocusedActivityLocked(r, "moveActivityToStack");
                } else {
                    mStackSupervisor.setFocusedStack(r, "moveActivityToStack");
                }
                mStackSupervisor.resumeTopActivitiesLocked(r.task.stack, null, null);
            } finally {
                Binder.restoreCallingIdentity(origId);
                Binder.restoreCallingIdentity(ident);
            }
        }
    }
@@ -8963,8 +8976,8 @@ public final class ActivityManagerService extends ActivityManagerNative
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "moveTaskToStack()");
        if (stackId == HOME_STACK_ID) {
            Slog.e(TAG, "moveTaskToStack: Attempt to move task " + taskId + " to home stack",
                    new RuntimeException("here").fillInStackTrace());
            throw new IllegalArgumentException(
                    "moveTaskToStack: Attempt to move task " + taskId + " to home stack");
        }
        synchronized (this) {
            long ident = Binder.clearCallingIdentity();
+10 −2
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public final class ActivityStackSupervisor implements DisplayListener {

    // Used to indicate if an object (e.g. task) should be moved/created
    // at the top of its container (e.g. stack).
    private static final boolean ON_TOP = true;
    static final boolean ON_TOP = true;

    // Used to indicate that an objects (e.g. task) removal from its container
    // (e.g. stack) is due to it moving to another container.
@@ -2953,13 +2953,21 @@ public final class ActivityStackSupervisor implements DisplayListener {
        // Place the task in the right stack if it isn't there already based on the requested
        // bounds.
        int stackId = task.stack.mStackId;
        final boolean wasFrontStack = isFrontStack(task.stack);
        if (bounds == null && stackId != FULLSCREEN_WORKSPACE_STACK_ID) {
            stackId = FULLSCREEN_WORKSPACE_STACK_ID;
        } else if (bounds != null && task.stack.mStackId != FREEFORM_WORKSPACE_STACK_ID) {
            stackId = FREEFORM_WORKSPACE_STACK_ID;
        }
        if (stackId != task.stack.mStackId) {
            moveTaskToStackUncheckedLocked(task, stackId, ON_TOP, "resizeTask");
            final String reason = "resizeTask";
            final ActivityStack stack =
                    moveTaskToStackUncheckedLocked(task, stackId, ON_TOP, reason);
            if (wasFrontStack) {
                // Since the stack was previously in front,
                // move the stack in which we are placing the task to the front.
                stack.moveToFront(reason);
            }
        }

        final Configuration overrideConfig = mWindowManager.resizeTask(task.taskId, bounds);