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

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

Merge "Add mechanism to request Core to reparent to the TDA on launch" into main

parents dae12c16 1878c40c
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -381,6 +381,12 @@ public class ActivityOptions extends ComponentOptions {
     */
    private static final String KEY_TASK_ALWAYS_ON_TOP = "android.activity.alwaysOnTop";

    /**
     * See {@link #setReparentLeafTaskToTda}
     */
    private static final String KEY_REPARENT_LEAF_TASK_TO_TDA =
            "android.activity.reparentLeafTaskToTda";

    /**
     * See {@link #setTaskOverlay}.
     * @hide
@@ -570,6 +576,7 @@ public class ActivityOptions extends ComponentOptions {
    private boolean mApplyMultipleTaskFlagForShortcut;
    private boolean mApplyNoUserActionFlagForShortcut;
    private boolean mTaskAlwaysOnTop;
    private boolean mReparentLeafTaskToTda;
    private boolean mTaskOverlay;
    private boolean mTaskOverlayCanResume;
    private boolean mAvoidMoveToFront;
@@ -1414,6 +1421,7 @@ public class ActivityOptions extends ComponentOptions {
        mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
        mPendingIntentLaunchFlags = opts.getInt(KEY_PENDING_INTENT_LAUNCH_FLAGS, 0);
        mTaskAlwaysOnTop = opts.getBoolean(KEY_TASK_ALWAYS_ON_TOP, false);
        mReparentLeafTaskToTda = opts.getBoolean(KEY_REPARENT_LEAF_TASK_TO_TDA, false);
        mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false);
        mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false);
        mAvoidMoveToFront = opts.getBoolean(KEY_AVOID_MOVE_TO_FRONT, false);
@@ -1996,6 +2004,16 @@ public class ActivityOptions extends ComponentOptions {
        mTaskAlwaysOnTop = alwaysOnTop;
    }

    /**
     * Similar to {@link WindowContainerTransaction#setReparentLeafTaskToTda(boolean)}, requests
     * that the given launch should reparent the leaf task to the ancestor TaskDisplayArea if it
     * is not currently parented there.
     * @hide
     */
    public void setReparentLeafTaskToTda(boolean reparent) {
        mReparentLeafTaskToTda = reparent;
    }

    /**
     * @hide
     */
@@ -2003,6 +2021,13 @@ public class ActivityOptions extends ComponentOptions {
        return mTaskAlwaysOnTop;
    }

    /**
     * @hide
     */
    public boolean getReparentLeafTaskToTda() {
        return mReparentLeafTaskToTda;
    }

    /**
     * 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.
@@ -2561,6 +2586,9 @@ public class ActivityOptions extends ComponentOptions {
        if (mTaskAlwaysOnTop) {
            b.putBoolean(KEY_TASK_ALWAYS_ON_TOP, mTaskAlwaysOnTop);
        }
        if (mReparentLeafTaskToTda) {
            b.putBoolean(KEY_REPARENT_LEAF_TASK_TO_TDA, mReparentLeafTaskToTda);
        }
        if (mTaskOverlay) {
            b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay);
        }
+1 −1
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ public class SafeActivityOptions {

        // If launched from bubble is specified, then ensure that the caller is system or sysui.
        if ((options.getLaunchedFromBubble() || options.getTaskAlwaysOnTop()
                || options.getLaunchNextToBubble())
                || options.getLaunchNextToBubble() || options.getReparentLeafTaskToTda())
                && !isSystemOrSystemUI(callingPid, callingUid)) {
            final String msg = "Permission Denial: starting " + getIntentString(intent)
                    + " from " + callerApp + " (pid=" + callingPid
+5 −4
Original line number Diff line number Diff line
@@ -878,18 +878,19 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
            final int position = onTop ? POSITION_TOP : POSITION_BOTTOM;
            final Task launchParentTask = getLaunchRootTask(resolvedWindowingMode, activityType,
                    options, sourceTask, launchFlags, candidateTask);
            final boolean reparentToTda = (options != null && options.getReparentLeafTaskToTda())
                    || candidateTask.getRootTask().mReparentLeafTaskIfRelaunch;
            if (launchParentTask != null) {
                if (candidateTask.getParent() == null) {
                    launchParentTask.addChild(candidateTask, position);
                } else if (candidateTask.getParent() != launchParentTask) {
                    candidateTask.reparent(launchParentTask, position);
                }
            } else if (candidateTask.getDisplayArea() != this
                    || candidateTask.getRootTask().mReparentLeafTaskIfRelaunch) {
            } else if (candidateTask.getDisplayArea() != this || reparentToTda) {
                if (candidateTask.getParent() == null) {
                    addChild(candidateTask, position);
                } else {
                    if (candidateTask.getRootTask().mReparentLeafTaskIfRelaunch) {
                } else if (candidateTask.getParent() != this) {
                    if (reparentToTda) {
                        ProtoLog.d(WM_DEBUG_TASKS, "Reparenting to display area on relaunch: "
                                + "rootTaskId=%d toTop=%b", candidateTask.mTaskId, onTop);
                    }
+1 −0
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ public class ActivityOptionsTest {
                case "android.activity.pendingIntentLaunchFlags":
                    // KEY_PENDING_INTENT_LAUNCH_FLAGS
                case "android.activity.alwaysOnTop": // KEY_TASK_ALWAYS_ON_TOP
                case "android.activity.reparentLeafTaskToTda": // KEY_TASK_ALWAYS_ON_TOP
                case "android.activity.taskOverlay": // KEY_TASK_OVERLAY
                case "android.activity.taskOverlayCanResume": // KEY_TASK_OVERLAY_CAN_RESUME
                case "android.activity.avoidMoveToFront": // KEY_AVOID_MOVE_TO_FRONT