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

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

Merge "Ensure that we always resume task overlay activities if requested."

parents 846946ec cbcadc98
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -176,6 +176,13 @@ public class ActivityOptions {
     */
    private static final String KEY_TASK_OVERLAY = "android.activity.taskOverlay";

    /**
     * See {@link #setTaskOverlay}.
     * @hide
     */
    private static final String KEY_TASK_OVERLAY_CAN_RESUME =
            "android.activity.taskOverlayCanResume";

    /**
     * Where the docked stack should be positioned.
     * @hide
@@ -252,6 +259,7 @@ public class ActivityOptions {
    private int mLaunchTaskId = -1;
    private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
    private boolean mTaskOverlay;
    private boolean mTaskOverlayCanResume;
    private AppTransitionAnimationSpec mAnimSpecs[];
    private int mRotationAnimationHint = -1;

@@ -862,6 +870,7 @@ public class ActivityOptions {
        mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID);
        mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
        mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false);
        mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, 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);
@@ -1071,12 +1080,13 @@ public class ActivityOptions {

    /**
     * Set's whether the activity launched with this option should be a task overlay. That is the
     * activity will always be the top activity of the task and doesn't cause the task to be moved
     * to the front when it is added.
     * activity will always be the top activity of the task.  If {@param canResume} is true, then
     * the task will also not be moved to the front of the stack.
     * @hide
     */
    public void setTaskOverlay(boolean taskOverlay) {
    public void setTaskOverlay(boolean taskOverlay, boolean canResume) {
        mTaskOverlay = taskOverlay;
        mTaskOverlayCanResume = canResume;
    }

    /**
@@ -1086,6 +1096,13 @@ public class ActivityOptions {
        return mTaskOverlay;
    }

    /**
     * @hide
     */
    public boolean canTaskOverlayResume() {
        return mTaskOverlayCanResume;
    }

    /** @hide */
    public int getDockCreateMode() {
        return mDockCreateMode;
@@ -1241,6 +1258,7 @@ public class ActivityOptions {
        b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId);
        b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId);
        b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay);
        b.putBoolean(KEY_TASK_OVERLAY_CAN_RESUME, mTaskOverlayCanResume);
        b.putInt(KEY_DOCK_CREATE_MODE, mDockCreateMode);
        if (mAnimSpecs != null) {
            b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs);
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class WorkLockActivityController {

        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchTaskId(taskId);
        options.setTaskOverlay(true);
        options.setTaskOverlay(true, false /* canResume */);
        mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
    }

+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class PipMenuActivityController {
                    ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
                    options.setLaunchTaskId(
                            pinnedStackInfo.taskIds[pinnedStackInfo.taskIds.length - 1]);
                    options.setTaskOverlay(true);
                    options.setTaskOverlay(true, true /* canResume */);
                    mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
                } else {
                    Log.e(TAG, "No PIP tasks found");
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public class ForcedResizableInfoActivityController {
            Intent intent = new Intent(mContext, ForcedResizableInfoActivity.class);
            ActivityOptions options = ActivityOptions.makeBasic();
            options.setLaunchTaskId(mPendingTaskIds.valueAt(i));
            options.setTaskOverlay(true);
            options.setTaskOverlay(true, false /* canResume */);
            mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
        }
        mPendingTaskIds.clear();
+12 −9
Original line number Diff line number Diff line
@@ -1236,18 +1236,21 @@ class ActivityStarter {
            mDoResume = false;
        }

        if (mOptions != null && mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) {
        if (mOptions != null && mOptions.getLaunchTaskId() != -1
                && mOptions.getTaskOverlay()) {
            r.mTaskOverlay = true;
            if (!mOptions.canTaskOverlayResume()) {
                final TaskRecord task = mSupervisor.anyTaskForIdLocked(mOptions.getLaunchTaskId());
                final ActivityRecord top = task != null ? task.getTopActivity() : null;
                if (top != null && top.state != RESUMED) {

                // The caller specifies that we'd like to be avoided to be moved to the front, so be
                // it!
                    // 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;