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

Commit c875ae74 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Don't move forced resizable info activity to the front

If we start the forced resizable activity with an existing task,
avoid moving that task to the front. This can cause that a previous
task that was moved to the back gets moved to the front again just
because we started that activity. That's not good.

Bug: 28223489
Change-Id: If8acf31b8be98b82665de1015d5621331c37fb64
parent 74610328
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -159,6 +159,12 @@ public class ActivityOptions {
     */
    private static final String KEY_LAUNCH_TASK_ID = "android.activity.launchTaskId";

    /**
     * See {@link #setAvoidMoveToFront}.
     * @hide
     */
    private static final String KEY_DONT_MOVE_TO_FRONT = "android.activity.dontMoveToFront";

    /**
     * Where the docked stack should be positioned.
     * @hide
@@ -232,6 +238,7 @@ public class ActivityOptions {
    private int mLaunchStackId = INVALID_STACK_ID;
    private int mLaunchTaskId = -1;
    private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
    private boolean mAvoidMoveToFront;
    private AppTransitionAnimationSpec mAnimSpecs[];

    /**
@@ -774,6 +781,7 @@ public class ActivityOptions {
        }
        mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID);
        mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
        mAvoidMoveToFront = opts.getBoolean(KEY_DONT_MOVE_TO_FRONT, false);
        mDockCreateMode = opts.getInt(KEY_DOCK_CREATE_MODE, DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT);
        if (opts.containsKey(KEY_ANIM_SPECS)) {
            Parcelable[] specs = opts.getParcelableArray(KEY_ANIM_SPECS);
@@ -950,6 +958,23 @@ public class ActivityOptions {
        return mLaunchTaskId;
    }

    /**
     * Set's whether the task should be moved to the front. This is different from
     * {@link #getLaunchTaskBehind()} as we don't want to have an animation at all when launching
     * an activity that shouldn't be moved to the front.
     * @hide
     */
    public void setAvoidMoveToFront(boolean avoidMoveToFront) {
        mAvoidMoveToFront = avoidMoveToFront;
    }

    /**
     * @hide
     */
    public boolean getAvoidMoveToFront() {
        return mAvoidMoveToFront;
    }

    /** @hide */
    public int getDockCreateMode() {
        return mDockCreateMode;
@@ -1103,6 +1128,7 @@ public class ActivityOptions {
        }
        b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId);
        b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId);
        b.putBoolean(KEY_DONT_MOVE_TO_FRONT, mAvoidMoveToFront);
        b.putInt(KEY_DOCK_CREATE_MODE, mDockCreateMode);
        if (mAnimSpecs != null) {
            b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs);
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class ForcedResizableInfoActivityController {
            Intent intent = new Intent(mContext, ForcedResizableInfoActivity.class);
            ActivityOptions options = ActivityOptions.makeBasic();
            options.setLaunchTaskId(mPendingTaskIds.valueAt(i));
            options.setAvoidMoveToFront(true);
            mContext.startActivity(intent, options.toBundle());
        }
        mPendingTaskIds.clear();
+18 −3
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ class ActivityStarter {
    private boolean mMovedToFront;
    private boolean mNoAnimation;
    private boolean mKeepCurTransition;
    private boolean mAvoidMoveToFront;

    private IVoiceInteractionSession mVoiceSession;
    private IVoiceInteractor mVoiceInteractor;
@@ -207,6 +208,7 @@ class ActivityStarter {
        mMovedToFront = false;
        mNoAnimation = false;
        mKeepCurTransition = false;
        mAvoidMoveToFront = false;

        mVoiceSession = null;
        mVoiceInteractor = null;
@@ -1223,6 +1225,18 @@ class ActivityStarter {
            mDoResume = false;
        }

        if (mOptions != null && mOptions.getLaunchTaskId() != -1 && mOptions.getAvoidMoveToFront()) {
            final TaskRecord task = mSupervisor.anyTaskForIdLocked(mOptions.getLaunchTaskId());
            final ActivityRecord top = task != null ? task.getTopActivity() : null;
            if (top != null && !top.visible) {

                // The caller specifies that we'd like to be avoided to be moved to the front, so be
                // it!
                mDoResume = false;
                mAvoidMoveToFront = true;
            }
        }

        mNotTop = (mLaunchFlags & FLAG_ACTIVITY_PREVIOUS_IS_TOP) != 0 ? r : null;

        mInTask = inTask;
@@ -1419,8 +1433,9 @@ class ActivityStarter {
        ActivityRecord curTop = (focusStack == null)
                ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop);

        if (curTop != null && (curTop.task != intentActivity.task ||
                curTop.task != focusStack.topTask())) {
        if (curTop != null
                && (curTop.task != intentActivity.task || curTop.task != focusStack.topTask())
                && !mAvoidMoveToFront) {
            mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
            if (mSourceRecord == null || (mSourceStack.topActivity() != null &&
                    mSourceStack.topActivity().task == mSourceRecord.task)) {
@@ -1631,7 +1646,7 @@ class ActivityStarter {
            mTargetStack.moveToFront("sourceStackToFront");
        }
        final TaskRecord topTask = mTargetStack.topTask();
        if (topTask != sourceTask) {
        if (topTask != sourceTask && !mAvoidMoveToFront) {
            mTargetStack.moveTaskToFrontLocked(sourceTask, mNoAnimation, mOptions,
                    mStartActivity.appTimeTracker, "sourceTaskToFront");
        }