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

Commit 4f1df4fa authored by Craig Mautner's avatar Craig Mautner
Browse files

Restore window manager stack order on user switch.

Only the activity stacks were being restored. Also add needed debug
logs.

Fixes bug 11223831.

Change-Id: Ief42688721c49e8cea14277619c797bf7c25b859
parent 4a534e00
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -551,9 +551,6 @@ final class ActivityStack {
     * Move the activities around in the stack to bring a user to the foreground.
     */
    final void switchUserLocked(int userId) {
        if (VALIDATE_TOKENS) {
            validateAppTokensLocked();
        }
        if (mCurrentUser == userId) {
            return;
        }
@@ -564,11 +561,16 @@ final class ActivityStack {
        for (int i = 0; i < index; ++i) {
            TaskRecord task = mTaskHistory.get(i);
            if (task.userId == userId) {
                if (DEBUG_TASKS) Slog.d(TAG, "switchUserLocked: stack=" + getStackId() +
                        " moving " + task + " to top");
                mTaskHistory.remove(i);
                mTaskHistory.add(task);
                --index;
            }
        }
        if (VALIDATE_TOKENS) {
            validateAppTokensLocked();
        }
    }

    void minimalResumeActivityLocked(ActivityRecord r) {
@@ -2951,6 +2953,7 @@ final class ActivityStack {
        for (int taskNdx = top; taskNdx >= 0; --taskNdx) {
            final TaskRecord task = mTaskHistory.get(taskNdx);
            if (task.isHomeTask()) {
                if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeTaskToTop: moving " + task);
                mTaskHistory.remove(taskNdx);
                mTaskHistory.add(top, task);
                mWindowManager.moveTaskToTop(task.taskId);
+13 −8
Original line number Diff line number Diff line
@@ -68,9 +68,8 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.util.EventLog;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;

import android.util.SparseBooleanArray;
import com.android.internal.app.HeavyWeightSwitcherActivity;
import com.android.internal.os.TransferPipe;
import com.android.server.am.ActivityManagerService.PendingActivityLaunch;
@@ -204,8 +203,8 @@ public final class ActivityStackSupervisor {
     */
    final PowerManager.WakeLock mGoingToSleep;

    /** State of the stacks when user switched, indexed by userId. */
    SparseBooleanArray mUserHomeInFront = new SparseBooleanArray(2);
    /** Stack id of the front stack when user switched, indexed by userId. */
    SparseIntArray mUserStackInFront = new SparseIntArray(2);

    public ActivityStackSupervisor(ActivityManagerService service, Context context,
            Looper looper) {
@@ -1927,7 +1926,7 @@ public final class ActivityStackSupervisor {
    }

    void removeUserLocked(int userId) {
        mUserHomeInFront.delete(userId);
        mUserStackInFront.delete(userId);
    }

    /**
@@ -2248,8 +2247,8 @@ public final class ActivityStackSupervisor {
    }

    boolean switchUserLocked(int userId, UserStartedState uss) {
        mUserHomeInFront.put(mCurrentUser, isFrontStack(mHomeStack));
        final boolean homeInFront = mUserHomeInFront.get(userId, true);
        mUserStackInFront.put(mCurrentUser, getFocusedStack().getStackId());
        final int restoreStackId = mUserStackInFront.get(userId, HOME_STACK_ID);
        mCurrentUser = userId;

        mStartingUsers.add(uss);
@@ -2257,7 +2256,13 @@ public final class ActivityStackSupervisor {
            mStacks.get(stackNdx).switchUserLocked(userId);
        }

        ActivityStack stack = getStack(restoreStackId);
        if (stack == null) {
            stack = mHomeStack;
        }
        final boolean homeInFront = stack.isHomeStack();
        moveHomeStack(homeInFront);
        mWindowManager.moveTaskToTop(stack.topTask().taskId);
        return homeInFront;
    }

@@ -2351,7 +2356,7 @@ public final class ActivityStackSupervisor {
        pw.print(prefix); pw.print("mStackState="); pw.println(stackStateToString(mStackState));
        pw.print(prefix); pw.println("mSleepTimeout: " + mSleepTimeout);
        pw.print(prefix); pw.println("mCurTaskId: " + mCurTaskId);
        pw.print(prefix); pw.println("mUserHomeInFront: " + mUserHomeInFront);
        pw.print(prefix); pw.println("mUserStackInFront: " + mUserStackInFront);
    }

    ArrayList<ActivityRecord> getDumpActivitiesLocked(String name) {