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

Commit 0568aed2 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

ActivityOptions.set/getLaunchStackId() be gone!

Removed ActivityOptions.set/getLaunchStackId() and replacement
ActivityOptions.set/getWindowingMode() and set/getActivityType()

Test: Existing tests pass.
Test: go/wm-smoke
Bug: 64146578
Change-Id: Ifc1c35f7b13c335cdf1a1694208e9fe0aea0c1fa
parent 704a3c0d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4052,10 +4052,11 @@ package android.app {
    method public static android.app.ActivityOptions makeThumbnailScaleUpAnimation(android.view.View, android.graphics.Bitmap, int, int);
    method public void requestUsageTimeReport(android.app.PendingIntent);
    method public android.app.ActivityOptions setAppVerificationBundle(android.os.Bundle);
    method public void setLaunchActivityType(int);
    method public android.app.ActivityOptions setLaunchBounds(android.graphics.Rect);
    method public android.app.ActivityOptions setLaunchDisplayId(int);
    method public void setLaunchStackId(int);
    method public void setLaunchTaskId(int);
    method public void setLaunchWindowingMode(int);
    method public void setTaskOverlay(boolean, boolean);
    method public android.os.Bundle toBundle();
    method public void update(android.app.ActivityOptions);
@@ -6244,6 +6245,7 @@ package android.app {
    field public static final int ACTIVITY_TYPE_UNDEFINED = 0; // 0x0
    field public static final int WINDOWING_MODE_FREEFORM = 5; // 0x5
    field public static final int WINDOWING_MODE_FULLSCREEN = 1; // 0x1
    field public static final int WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY = 4; // 0x4
    field public static final int WINDOWING_MODE_PINNED = 2; // 0x2
    field public static final int WINDOWING_MODE_SPLIT_SCREEN_PRIMARY = 3; // 0x3
    field public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY = 4; // 0x4
+24 −15
Original line number Diff line number Diff line
@@ -769,21 +769,6 @@ public class ActivityManager {
                    || stackId == ASSISTANT_STACK_ID;
        }

        /**
         * Returns true if animation specs should be constructed for app transition that moves
         * the task to the specified stack.
         * @hide
         */
        public static boolean useAnimationSpecForAppTransition(int stackId) {
            // TODO: INVALID_STACK_ID is also animated because we don't persist stack id's across
            // reboots.
            return stackId == FREEFORM_WORKSPACE_STACK_ID
                    || stackId == FULLSCREEN_WORKSPACE_STACK_ID
                    || stackId == ASSISTANT_STACK_ID
                    || stackId == DOCKED_STACK_ID
                    || stackId == INVALID_STACK_ID;
        }

        /**
         * Returns true if activities from stasks in the given {@param stackId} are allowed to
         * enter picture-in-picture.
@@ -885,6 +870,18 @@ public class ActivityManager {
            return windowingMode;
        }

        /** Returns the stack id for the input windowing mode.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getStackIdForWindowingMode(int windowingMode) {
            switch (windowingMode) {
                case WINDOWING_MODE_PINNED: return PINNED_STACK_ID;
                case WINDOWING_MODE_FREEFORM: return FREEFORM_WORKSPACE_STACK_ID;
                case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: return DOCKED_STACK_ID;
                default: return INVALID_STACK_ID;
            }
        }

        /** Returns the activity type that should be used for this input stack id.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
@@ -905,6 +902,18 @@ public class ActivityManager {
            }
            return activityType;
        }

        /** Returns the stack id for the input activity type.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getStackIdForActivityType(int activityType) {
            switch (activityType) {
                case ACTIVITY_TYPE_HOME: return HOME_STACK_ID;
                case ACTIVITY_TYPE_RECENTS: return RECENTS_STACK_ID;
                case ACTIVITY_TYPE_ASSISTANT: return ASSISTANT_STACK_ID;
                default: return INVALID_STACK_ID;
            }
        }
    }

    /**
+42 −9
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.app;

import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.INVALID_DISPLAY;

import android.annotation.Nullable;
@@ -164,10 +166,16 @@ public class ActivityOptions {
    private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId";

    /**
     * The stack id the activity should be launched into.
     * The windowing mode the activity should be launched into.
     * @hide
     */
    private static final String KEY_LAUNCH_STACK_ID = "android.activity.launchStackId";
    private static final String KEY_LAUNCH_WINDOWING_MODE = "android.activity.windowingMode";

    /**
     * The activity type the activity should be launched as.
     * @hide
     */
    private static final String KEY_LAUNCH_ACTIVITY_TYPE = "android.activity.activityType";

    /**
     * The task id the activity should be launched into.
@@ -272,7 +280,10 @@ public class ActivityOptions {
    private int mExitCoordinatorIndex;
    private PendingIntent mUsageTimeReport;
    private int mLaunchDisplayId = INVALID_DISPLAY;
    private int mLaunchStackId = INVALID_STACK_ID;
    @WindowConfiguration.WindowingMode
    private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED;
    @WindowConfiguration.ActivityType
    private int mLaunchActivityType = ACTIVITY_TYPE_UNDEFINED;
    private int mLaunchTaskId = -1;
    private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
    private boolean mDisallowEnterPictureInPictureWhileLaunching;
@@ -860,7 +871,8 @@ public class ActivityOptions {
                break;
        }
        mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY);
        mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID);
        mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED);
        mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED);
        mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
        mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false);
        mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false);
@@ -1070,14 +1082,34 @@ public class ActivityOptions {
    }

    /** @hide */
    public int getLaunchStackId() {
        return mLaunchStackId;
    public int getLaunchWindowingMode() {
        return mLaunchWindowingMode;
    }

    /**
     * Sets the windowing mode the activity should launch into. If the input windowing mode is
     * {@link android.app.WindowConfiguration#WINDOWING_MODE_SPLIT_SCREEN_SECONDARY} and the device
     * isn't currently in split-screen windowing mode, then the activity will be launched in
     * {@link android.app.WindowConfiguration#WINDOWING_MODE_FULLSCREEN} windowing mode. For clarity
     * on this you can use
     * {@link android.app.WindowConfiguration#WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY}
     *
     * @hide
     */
    @TestApi
    public void setLaunchWindowingMode(int windowingMode) {
        mLaunchWindowingMode = windowingMode;
    }

    /** @hide */
    public int getLaunchActivityType() {
        return mLaunchActivityType;
    }

    /** @hide */
    @TestApi
    public void setLaunchStackId(int launchStackId) {
        mLaunchStackId = launchStackId;
    public void setLaunchActivityType(int activityType) {
        mLaunchActivityType = activityType;
    }

    /**
@@ -1291,7 +1323,8 @@ public class ActivityOptions {
                break;
        }
        b.putInt(KEY_LAUNCH_DISPLAY_ID, mLaunchDisplayId);
        b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId);
        b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode);
        b.putInt(KEY_LAUNCH_ACTIVITY_TYPE, mLaunchActivityType);
        b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId);
        b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay);
        b.putBoolean(KEY_TASK_OVERLAY_CAN_RESUME, mTaskOverlayCanResume);
+14 −0
Original line number Diff line number Diff line
@@ -63,8 +63,21 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
    /**
     * The containers adjacent to the {@link #WINDOWING_MODE_SPLIT_SCREEN_PRIMARY} container in
     * split-screen mode.
     * NOTE: Containers launched with the windowing mode with APIs like
     * {@link ActivityOptions#setLaunchWindowingMode(int)} will be launched in
     * {@link #WINDOWING_MODE_FULLSCREEN} if the display isn't currently in split-screen windowing
     * mode
     * @see #WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY
     */
    public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY = 4;
    /**
     * Alias for {@link #WINDOWING_MODE_SPLIT_SCREEN_SECONDARY} that makes it clear that the usage
     * points for APIs like {@link ActivityOptions#setLaunchWindowingMode(int)} that the container
     * will launch into fullscreen or split-screen secondary depending on if the device is currently
     * in fullscreen mode or split-screen mode.
     */
    public static final int WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY =
            WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
    /** Can be freely resized within its parent container. */
    public static final int WINDOWING_MODE_FREEFORM = 5;

@@ -75,6 +88,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
            WINDOWING_MODE_PINNED,
            WINDOWING_MODE_SPLIT_SCREEN_PRIMARY,
            WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
            WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY,
            WINDOWING_MODE_FREEFORM,
    })
    public @interface WindowingMode {}
+6 −5
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

package android.widget;

import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.annotation.ColorInt;
import android.annotation.DimenRes;
import android.app.ActivityManager.StackId;
import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.Application;
@@ -324,11 +325,11 @@ public class RemoteViews implements Parcelable, Filter {

        public boolean onClickHandler(View view, PendingIntent pendingIntent,
                Intent fillInIntent) {
            return onClickHandler(view, pendingIntent, fillInIntent, StackId.INVALID_STACK_ID);
            return onClickHandler(view, pendingIntent, fillInIntent, WINDOWING_MODE_UNDEFINED);
        }

        public boolean onClickHandler(View view, PendingIntent pendingIntent,
                Intent fillInIntent, int launchStackId) {
                Intent fillInIntent, int windowingMode) {
            try {
                // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
                Context context = view.getContext();
@@ -339,8 +340,8 @@ public class RemoteViews implements Parcelable, Filter {
                    opts = ActivityOptions.makeBasic();
                }

                if (launchStackId != StackId.INVALID_STACK_ID) {
                    opts.setLaunchStackId(launchStackId);
                if (windowingMode != WINDOWING_MODE_UNDEFINED) {
                    opts.setLaunchWindowingMode(windowingMode);
                }
                context.startIntentSender(
                        pendingIntent.getIntentSender(), fillInIntent,
Loading