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

Commit f0769536 authored by Louis Chang's avatar Louis Chang Committed by Automerger Merge Worker
Browse files

Merge "New activity launch mode - singleInstancePerTask" into sc-dev am: 9992fd7f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13639640

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia9b347be2ccc8219fef5f5d36d3794558bc07afb
parents 999a8c88 9992fd7f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11723,6 +11723,7 @@ package android.content.pm {
    field public static final int FLAG_STATE_NOT_NEEDED = 16; // 0x10
    field public static final int LAUNCH_MULTIPLE = 0; // 0x0
    field public static final int LAUNCH_SINGLE_INSTANCE = 3; // 0x3
    field public static final int LAUNCH_SINGLE_INSTANCE_PER_TASK = 4; // 0x4
    field public static final int LAUNCH_SINGLE_TASK = 2; // 0x2
    field public static final int LAUNCH_SINGLE_TOP = 1; // 0x1
    field public static final int PERSIST_ACROSS_REBOOTS = 2; // 0x2
+20 −4
Original line number Diff line number Diff line
@@ -73,13 +73,29 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     * the {@link android.R.attr#launchMode} attribute.
     */
    public static final int LAUNCH_SINGLE_INSTANCE = 3;
    /**
     * Constant corresponding to <code>singleInstancePerTask</code> in
     * the {@link android.R.attr#launchMode} attribute.
     */
    public static final int LAUNCH_SINGLE_INSTANCE_PER_TASK = 4;

    /** @hide */
    @IntDef(prefix = "LAUNCH_", value = {
            LAUNCH_MULTIPLE,
            LAUNCH_SINGLE_TOP,
            LAUNCH_SINGLE_TASK,
            LAUNCH_SINGLE_INSTANCE,
            LAUNCH_SINGLE_INSTANCE_PER_TASK
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface LaunchMode {
    }

    /**
     * The launch mode style requested by the activity.  From the
     * {@link android.R.attr#launchMode} attribute, one of
     * {@link #LAUNCH_MULTIPLE},
     * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or
     * {@link #LAUNCH_SINGLE_INSTANCE}.
     * {@link android.R.attr#launchMode} attribute.
     */
    @LaunchMode
    public int launchMode;

    /**
+1 −0
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ public class PackageParser {
    public static final String METADATA_SUPPORTS_SIZE_CHANGES = "android.supports_size_changes";
    public static final String METADATA_ACTIVITY_WINDOW_LAYOUT_AFFINITY =
            "android.activity_window_layout_affinity";
    public static final String METADATA_ACTIVITY_LAUNCH_MODE = "android.activity.launch_mode";

    /**
     * Bit mask of all the valid bits that can be set in recreateOnConfigChanges.
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content.pm.parsing.component;

import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE_PER_TASK;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.parsing.component.ComponentParseUtils.flag;

@@ -23,6 +24,7 @@ import android.annotation.NonNull;
import android.app.ActivityTaskManager;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageParser;
import android.content.pm.parsing.ParsingPackage;
import android.content.pm.parsing.ParsingPackageUtils;
import android.content.pm.parsing.ParsingUtils;
@@ -402,6 +404,16 @@ public class ParsedActivityUtils {
            }
        }

        if (!isAlias && activity.launchMode != LAUNCH_SINGLE_INSTANCE_PER_TASK
                && activity.metaData != null && activity.metaData.containsKey(
                PackageParser.METADATA_ACTIVITY_LAUNCH_MODE)) {
            final String launchMode = activity.metaData.getString(
                    PackageParser.METADATA_ACTIVITY_LAUNCH_MODE);
            if (launchMode != null && launchMode.equals("singleInstancePerTask")) {
                activity.launchMode = LAUNCH_SINGLE_INSTANCE_PER_TASK;
            }
        }

        ParseResult<ActivityInfo.WindowLayout> layoutResult =
                resolveActivityWindowLayout(activity, input);
        if (layoutResult.isError()) {
+6 −0
Original line number Diff line number Diff line
@@ -822,6 +822,12 @@
            <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
            Stack</a> document for more details about tasks.-->
        <enum name="singleInstance" value="3" />
        <!-- The activity can only be running as the root activity of the task, the first activity
            that created the task, and therefore there will only be one instance of this activity
            in a task. In constrast to the {@code singleTask} launch mode, this activity can be
            started in multiple instances in different tasks if the
            {@code FLAG_ACTIVITY_MULTIPLE_TASK} is set.-->
        <enum name="singleInstancePerTask" value="4" />
    </attr>

    <!-- Specify the orientation an activity should be run in.  If not
Loading