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

Commit 07279227 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fixing crash when enforcing top stack."

parents 538d5a3d 7c3ede36
Loading
Loading
Loading
Loading
+22 −11
Original line number Original line Diff line number Diff line
@@ -66,6 +66,7 @@ import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.ASSISTANT_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.ASSISTANT_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_CLOSE;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_CLOSE;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_OPEN;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_OPEN;
@@ -505,7 +506,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        }
        }
        onParentChanged();
        onParentChanged();


        activityDisplay.attachStack(this, onTop);
        activityDisplay.attachStack(this, findStackInsertIndex(onTop));
        if (mStackId == DOCKED_STACK_ID) {
        if (mStackId == DOCKED_STACK_ID) {
            // If we created a docked stack we want to resize it so it resizes all other stacks
            // If we created a docked stack we want to resize it so it resizes all other stacks
            // in the system.
            // in the system.
@@ -799,16 +800,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        }
        }


        mStacks.remove(this);
        mStacks.remove(this);
        int addIndex = mStacks.size();
        mStacks.add(findStackInsertIndex(ON_TOP), this);
        if (addIndex > 0) {
            final ActivityStack topStack = mStacks.get(addIndex - 1);
            if (StackId.isAlwaysOnTop(topStack.mStackId) && topStack != this) {
                // If the top stack is always on top, we move this stack just below it.
                addIndex--;
            }
        }

        mStacks.add(addIndex, this);
        mStackSupervisor.setFocusStackUnchecked(reason, this);
        mStackSupervisor.setFocusStackUnchecked(reason, this);
        if (task != null) {
        if (task != null) {
            insertTaskAtTop(task, null);
            insertTaskAtTop(task, null);
@@ -841,6 +833,25 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        }
        }
    }
    }


    /**
     * @return the index to insert a new stack into, taking the always-on-top stacks into account.
     */
    private int findStackInsertIndex(boolean onTop) {
        if (onTop) {
            int addIndex = mStacks.size();
            if (addIndex > 0) {
                final ActivityStack topStack = mStacks.get(addIndex - 1);
                if (StackId.isAlwaysOnTop(topStack.mStackId) && topStack != this) {
                    // If the top stack is always on top, we move this stack just below it.
                    addIndex--;
                }
            }
            return addIndex;
        } else {
            return 0;
        }
    }

    boolean isFocusable() {
    boolean isFocusable() {
        if (StackId.canReceiveKeys(mStackId)) {
        if (StackId.canReceiveKeys(mStackId)) {
            return true;
            return true;
+3 −7
Original line number Original line Diff line number Diff line
@@ -4654,14 +4654,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            mDisplayId = display.getDisplayId();
            mDisplayId = display.getDisplayId();
        }
        }


        void attachStack(ActivityStack stack, boolean onTop) {
        void attachStack(ActivityStack stack, int position) {
            if (DEBUG_STACK) Slog.v(TAG_STACK, "attachStack: attaching " + stack
            if (DEBUG_STACK) Slog.v(TAG_STACK, "attachStack: attaching " + stack
                    + " to displayId=" + mDisplayId + " onTop=" + onTop);
                    + " to displayId=" + mDisplayId + " position=" + position);
            if (onTop) {
            mStacks.add(position, stack);
                mStacks.add(stack);
            } else {
                mStacks.add(0, stack);
            }
        }
        }


        void detachStack(ActivityStack stack) {
        void detachStack(ActivityStack stack) {