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

Commit bb742462 authored by Craig Mautner's avatar Craig Mautner
Browse files

Launch activity behind launching task.

Use ActivityOptions.makeLaunchTaskBehindAnimation() to launch tasks
behind the current task. Includes animations for launching and
launched tasks.

Fixes bug 16157517.

Change-Id: I0a94af70b4748592e94673b958ee824cfb3d7ec0
parent 96e22850
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -742,6 +742,8 @@ package android {
    field public static final int largeScreens = 16843398; // 0x1010286
    field public static final int largestWidthLimitDp = 16843622; // 0x1010366
    field public static final int launchMode = 16842781; // 0x101001d
    field public static final int launchTaskBehindBackgroundAnimation = 16843920; // 0x1010490
    field public static final int launchTaskBehindSourceAnimation = 16843921; // 0x1010491
    field public static final int layerType = 16843604; // 0x1010354
    field public static final int layout = 16842994; // 0x10100f2
    field public static final int layoutAnimation = 16842988; // 0x10100ec
@@ -854,7 +856,7 @@ package android {
    field public static final int mirrorForRtl = 16843726; // 0x10103ce
    field public static final int mode = 16843134; // 0x101017e
    field public static final int moreIcon = 16843061; // 0x1010135
    field public static final int multiArch = 16843920; // 0x1010490
    field public static final int multiArch = 16843922; // 0x1010492
    field public static final int multiprocess = 16842771; // 0x1010013
    field public static final int name = 16842755; // 0x1010003
    field public static final int navigationBarColor = 16843860; // 0x1010454
@@ -1284,7 +1286,7 @@ package android {
    field public static final int topLeftRadius = 16843177; // 0x10101a9
    field public static final int topOffset = 16843352; // 0x1010258
    field public static final int topRightRadius = 16843178; // 0x10101aa
    field public static final int touchscreenBlocksFocus = 16843921; // 0x1010491
    field public static final int touchscreenBlocksFocus = 16843923; // 0x1010493
    field public static final int track = 16843631; // 0x101036f
    field public static final int transcriptMode = 16843008; // 0x1010100
    field public static final int transformPivotX = 16843552; // 0x1010320
@@ -3664,6 +3666,7 @@ package android.app {
  public class ActivityOptions {
    method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int);
    method public static android.app.ActivityOptions makeLaunchTaskBehindAnimation();
    method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int);
    method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.view.View, java.lang.String);
    method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.util.Pair<android.view.View, java.lang.String>...);
@@ -7696,7 +7699,6 @@ package android.content {
    field public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608; // 0x800000
    field public static final int FLAG_ACTIVITY_FORWARD_RESULT = 33554432; // 0x2000000
    field public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576; // 0x100000
    field public static final int FLAG_ACTIVITY_LAUNCH_BEHIND = 4096; // 0x1000
    field public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 134217728; // 0x8000000
    field public static final int FLAG_ACTIVITY_NEW_DOCUMENT = 524288; // 0x80000
    field public static final int FLAG_ACTIVITY_NEW_TASK = 268435456; // 0x10000000
+23 −3
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.content.pm.IPackageDataObserver;
import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Binder;
@@ -2196,13 +2195,21 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case MEDIA_RESOURCES_RELEASED: {
        case MEDIA_RESOURCES_RELEASED_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            mediaResourcesReleased(token);
            reply.writeNoException();
            return true;
        }

        case NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            notifyLaunchTaskBehindComplete(token);
            reply.writeNoException();
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -5069,7 +5076,20 @@ class ActivityManagerProxy implements IActivityManager
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(MEDIA_RESOURCES_RELEASED, data, reply, IBinder.FLAG_ONEWAY);
        mRemote.transact(MEDIA_RESOURCES_RELEASED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public void notifyLaunchTaskBehindComplete(IBinder token) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION, data, reply,
                IBinder.FLAG_ONEWAY);
        reply.readException();
        data.recycle();
        reply.recycle();
+25 −4
Original line number Diff line number Diff line
@@ -126,6 +126,8 @@ public class ActivityOptions {
    public static final int ANIM_SCENE_TRANSITION = 5;
    /** @hide */
    public static final int ANIM_DEFAULT = 6;
    /** @hide */
    public static final int ANIM_LAUNCH_TASK_BEHIND = 7;

    private String mPackageName;
    private int mAnimationType = ANIM_NONE;
@@ -432,6 +434,27 @@ public class ActivityOptions {
        return opts;
    }

    /**
     * If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be
     * presented to the user but will instead be only available through the recents task list.
     * In addition, the new task wil be affiliated with the launching activity's task.
     * Affiliated tasks are grouped together in the recents task list.
     *
     * <p>This behavior is not supported for activities with {@link
     * android.R.styleable#AndroidManifestActivity_launchMode launchMode} values of
     * <code>singleInstance</code> or <code>singleTask</code>.
     */
    public static ActivityOptions makeLaunchTaskBehindAnimation() {
        final ActivityOptions opts = new ActivityOptions();
        opts.mAnimationType = ANIM_LAUNCH_TASK_BEHIND;
        return opts;
    }

    /** @hide */
    public boolean getLaunchTaskBehind() {
        return mAnimationType == ANIM_LAUNCH_TASK_BEHIND;
    }

    private ActivityOptions() {
    }

@@ -647,16 +670,15 @@ public class ActivityOptions {
        if (mPackageName != null) {
            b.putString(KEY_PACKAGE_NAME, mPackageName);
        }
        b.putInt(KEY_ANIM_TYPE, mAnimationType);
        switch (mAnimationType) {
            case ANIM_CUSTOM:
                b.putInt(KEY_ANIM_TYPE, mAnimationType);
                b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId);
                b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId);
                b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
                        != null ? mAnimationStartedListener.asBinder() : null);
                break;
            case ANIM_SCALE_UP:
                b.putInt(KEY_ANIM_TYPE, mAnimationType);
                b.putInt(KEY_ANIM_START_X, mStartX);
                b.putInt(KEY_ANIM_START_Y, mStartY);
                b.putInt(KEY_ANIM_START_WIDTH, mStartWidth);
@@ -664,7 +686,6 @@ public class ActivityOptions {
                break;
            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
                b.putInt(KEY_ANIM_TYPE, mAnimationType);
                b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
                b.putInt(KEY_ANIM_START_X, mStartX);
                b.putInt(KEY_ANIM_START_Y, mStartY);
@@ -672,7 +693,6 @@ public class ActivityOptions {
                        != null ? mAnimationStartedListener.asBinder() : null);
                break;
            case ANIM_SCENE_TRANSITION:
                b.putInt(KEY_ANIM_TYPE, mAnimationType);
                if (mTransitionReceiver != null) {
                    b.putParcelable(KEY_TRANSITION_COMPLETE_LISTENER, mTransitionReceiver);
                }
@@ -683,6 +703,7 @@ public class ActivityOptions {
                b.putInt(KEY_EXIT_COORDINATOR_INDEX, mExitCoordinatorIndex);
                break;
        }

        return b;
    }

+4 −1
Original line number Diff line number Diff line
@@ -444,6 +444,8 @@ public interface IActivityManager extends IInterface {
    public boolean isBackgroundMediaPlaying(IBinder token) throws RemoteException;
    public void mediaResourcesReleased(IBinder token) throws RemoteException;

    public void notifyLaunchTaskBehindComplete(IBinder token) throws RemoteException;

    /*
     * Private non-Binder interfaces
     */
@@ -750,5 +752,6 @@ public interface IActivityManager extends IInterface {
    int IS_TOP_OF_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+224;
    int SET_MEDIA_PLAYING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+225;
    int IS_BG_MEDIA_PLAYING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+226;
    int MEDIA_RESOURCES_RELEASED = IBinder.FIRST_CALL_TRANSACTION+227;
    int MEDIA_RESOURCES_RELEASED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+227;
    int NOTIFY_LAUNCH_TASK_BEHIND_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+228;
}
+0 −11
Original line number Diff line number Diff line
@@ -3809,17 +3809,6 @@ public class Intent implements Parcelable, Cloneable {
     * {@link android.R.styleable#AndroidManifestActivity_autoRemoveFromRecents}.
     */
    public static final int FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS = 0x00002000;
    /**
     * If set along with FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be
     * presented to the user but will instead be only available through the recents task list.
     * In addition, the new task wil be affiliated with the launching activity's task.
     * Affiliated tasks are grouped together in the recents task list.
     *
     * <p>This behavior is not supported for activities with {@link
     * android.R.styleable#AndroidManifestActivity_launchMode launchMode} values of
     * <code>singleInstance</code> or <code>singleTask</code>.
     */
    public static final int FLAG_ACTIVITY_LAUNCH_BEHIND = 0x00001000;

    /**
     * If set, when sending a broadcast only registered receivers will be
Loading