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

Commit 2adba07d authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Show a scrim activity if task is not resizable

Add a callback to TaskStackChangeListener which gets fired when the system
might need to inform the user that a specific app might not work in
multi-window.

Use that callback in SysUI to show a translucent activity which scrims the
activity behind to inform that it might not be resizable.

Debounce the information to once per multi-window session, to not make it
annoying.

Introduce launchTaskId to start an activity in an existing task, and protect
that with START_TASKS_FROM_RECENTS permission.

Bug: 27327287
Bug: 27431869
Change-Id: I89e8d653872ab01ba3c1e252b426e5481da0e6ca
parent c39c7b0c
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -153,6 +153,12 @@ public class ActivityOptions {
     */
    private static final String KEY_LAUNCH_STACK_ID = "android.activity.launchStackId";

    /**
     * The task id the activity should be launched into.
     * @hide
     */
    private static final String KEY_LAUNCH_TASK_ID = "android.activity.launchTaskId";

    /**
     * Where the docked stack should be positioned.
     * @hide
@@ -224,6 +230,7 @@ public class ActivityOptions {
    private int mExitCoordinatorIndex;
    private PendingIntent mUsageTimeReport;
    private int mLaunchStackId = INVALID_STACK_ID;
    private int mLaunchTaskId = -1;
    private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
    private AppTransitionAnimationSpec mAnimSpecs[];

@@ -766,6 +773,7 @@ public class ActivityOptions {
                break;
        }
        mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID);
        mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
        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);
@@ -927,6 +935,21 @@ public class ActivityOptions {
        mLaunchStackId = launchStackId;
    }

    /**
     * Sets the task the activity will be launched in.
     * @hide
     */
    public void setLaunchTaskId(int taskId) {
        mLaunchTaskId = taskId;
    }

    /**
     * @hide
     */
    public int getLaunchTaskId() {
        return mLaunchTaskId;
    }

    /** @hide */
    public int getDockCreateMode() {
        return mDockCreateMode;
@@ -1079,6 +1102,7 @@ public class ActivityOptions {
                break;
        }
        b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId);
        b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId);
        b.putInt(KEY_DOCK_CREATE_MODE, mDockCreateMode);
        if (mAnimSpecs != null) {
            b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs);
+6 −1
Original line number Diff line number Diff line
@@ -803,7 +803,12 @@ class ContextImpl extends Context {
    @Override
    public void startActivity(Intent intent, Bundle options) {
        warnIfCallingFromSystemProcess();
        if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {

        // Calling start activity from outside an activity without FLAG_ACTIVITY_NEW_TASK is
        // generally not allowed, except if the caller specifies the task id the activity should
        // be launched in.
        if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0
                && options != null && ActivityOptions.fromBundle(options).getLaunchTaskId() == -1) {
            throw new AndroidRuntimeException(
                    "Calling startActivity() from outside of an Activity "
                    + " context requires the FLAG_ACTIVITY_NEW_TASK flag."
+5 −0
Original line number Diff line number Diff line
@@ -35,4 +35,9 @@ oneway interface ITaskStackListener {
     * Called whenever the pinned stack is done animating a resize.
     */
    void onPinnedStackAnimationEnded();

    /**
     * Called when we launched an activity that we forced to be resizable.
     */
    void onActivityForcedResizable(String packageName, int taskId);
}
+5 −0
Original line number Diff line number Diff line
@@ -88,6 +88,11 @@ oneway interface IStatusBar
     */
    void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);

    /**
     * Notifies the status bar that an app transition is done.
     */
    void appTransitionFinished();

    void showAssistDisclosure();
    void startAssist(in Bundle args);

+8 −0
Original line number Diff line number Diff line
@@ -263,6 +263,14 @@
            </intent-filter>
        </activity>

        <activity
            android:name=".stackdivider.ForcedResizableInfoActivity"
            android:theme="@style/ForcedResizableTheme"
            android:excludeFromRecents="true"
            android:stateNotNeeded="true"
            android:exported="false">
        </activity>

        <!-- Callback for dismissing screenshot notification after a share target is picked -->
        <receiver android:name=".screenshot.GlobalScreenshot$TargetChosenReceiver"
                  android:process=":screenshot"
Loading