diff options
| author | Wale Ogunwale <ogunwale@google.com> | 2020-10-13 18:36:37 -0700 |
|---|---|---|
| committer | Wale Ogunwale <ogunwale@google.com> | 2020-10-15 12:54:12 -0700 |
| commit | 0227500a45ffb793ce1ae424989053056354df98 (patch) | |
| tree | e4b461b7e2a5c2cd645bc25180f90ed7bacbc894 /core/java | |
| parent | d526fc1562e02606dd232a6ee894166821af807c (diff) | |
Add launch cookie support to activities/tasks
Allow callers to associate callbacks from WM containing TaskInfo with
activity launches they requested.
Bug: 129067201
Test: Bubbles works.
Change-Id: If43170d64d8aea0796d55fb480f5ee9c0465a696
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 31 | ||||
| -rw-r--r-- | core/java/android/app/TaskInfo.java | 64 |
2 files changed, 58 insertions, 37 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 3748a33568e2..ef146b118c33 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -37,6 +37,7 @@ import android.graphics.Rect; import android.hardware.HardwareBuffer; import android.os.Bundle; import android.os.Handler; +import android.os.IBinder; import android.os.IRemoteCallback; import android.os.Parcel; import android.os.Parcelable; @@ -306,6 +307,12 @@ public class ActivityOptions { private static final String KEY_REMOTE_ANIMATION_ADAPTER = "android:activity.remoteAnimationAdapter"; + /** + * @see #setLaunchCookie + * @hide + */ + private static final String KEY_LAUNCH_COOKIE = "android.activity.launchCookie"; + /** @hide */ public static final int ANIM_UNDEFINED = -1; /** @hide */ @@ -381,6 +388,7 @@ public class ActivityOptions { private Bundle mAppVerificationBundle; private IAppTransitionAnimationSpecsFuture mSpecsFuture; private RemoteAnimationAdapter mRemoteAnimationAdapter; + private IBinder mLaunchCookie; /** * Create an ActivityOptions specifying a custom animation to run when @@ -1071,6 +1079,7 @@ public class ActivityOptions { KEY_SPECS_FUTURE)); } mRemoteAnimationAdapter = opts.getParcelable(KEY_REMOTE_ANIMATION_ADAPTER); + mLaunchCookie = opts.getBinder(KEY_LAUNCH_COOKIE); } /** @@ -1496,6 +1505,25 @@ public class ActivityOptions { } /** + * Sets a launch cookie that can be used to track the activity and task that are launch as a + * result of this option. + * + * @hide + */ + public void setLaunchCookie(IBinder launchCookie) { + mLaunchCookie = launchCookie; + } + + /** + * @return The launch tracking cookie if set or {@code null} otherwise. + * + * @hide + */ + public IBinder getLaunchCookie() { + return mLaunchCookie; + } + + /** * Update the current values in this ActivityOptions from those supplied * in <var>otherOptions</var>. Any values * defined in <var>otherOptions</var> replace those in the base options. @@ -1717,6 +1745,9 @@ public class ActivityOptions { if (mRemoteAnimationAdapter != null) { b.putParcelable(KEY_REMOTE_ANIMATION_ADAPTER, mRemoteAnimationAdapter); } + if (mLaunchCookie != null) { + b.putBinder(KEY_LAUNCH_COOKIE, mLaunchCookie); + } return b; } diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java index 4718cf1545ce..849f679c9439 100644 --- a/core/java/android/app/TaskInfo.java +++ b/core/java/android/app/TaskInfo.java @@ -24,11 +24,14 @@ import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; +import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.util.Log; import android.window.WindowContainerToken; +import java.util.ArrayList; + /** * Stores information about a particular Task. */ @@ -177,6 +180,13 @@ public class TaskInfo { */ public boolean isResizeable; + /** + * The launch cookies associated with activities in this task if any. + * @see ActivityOptions#setLaunchCookie(IBinder) + * @hide + */ + public ArrayList<IBinder> launchCookies = new ArrayList<>(); + TaskInfo() { // Do nothing } @@ -213,6 +223,11 @@ public class TaskInfo { return configuration; } + /** @hide */ + public void addLaunchCookie(IBinder cookie) { + launchCookies.add(cookie); + } + /** * Reads the TaskInfo from a parcel. */ @@ -222,9 +237,7 @@ public class TaskInfo { taskId = source.readInt(); displayId = source.readInt(); isRunning = source.readBoolean(); - baseIntent = source.readInt() != 0 - ? Intent.CREATOR.createFromParcel(source) - : null; + baseIntent = source.readTypedObject(Intent.CREATOR); baseActivity = ComponentName.readFromParcel(source); topActivity = ComponentName.readFromParcel(source); origActivity = ComponentName.readFromParcel(source); @@ -233,21 +246,16 @@ public class TaskInfo { numActivities = source.readInt(); lastActiveTime = source.readLong(); - taskDescription = source.readInt() != 0 - ? ActivityManager.TaskDescription.CREATOR.createFromParcel(source) - : null; + taskDescription = source.readTypedObject(ActivityManager.TaskDescription.CREATOR); supportsSplitScreenMultiWindow = source.readBoolean(); resizeMode = source.readInt(); configuration.readFromParcel(source); token = WindowContainerToken.CREATOR.createFromParcel(source); topActivityType = source.readInt(); - pictureInPictureParams = source.readInt() != 0 - ? PictureInPictureParams.CREATOR.createFromParcel(source) - : null; - topActivityInfo = source.readInt() != 0 - ? ActivityInfo.CREATOR.createFromParcel(source) - : null; + pictureInPictureParams = source.readTypedObject(PictureInPictureParams.CREATOR); + topActivityInfo = source.readTypedObject(ActivityInfo.CREATOR); isResizeable = source.readBoolean(); + source.readBinderList(launchCookies); } /** @@ -259,13 +267,8 @@ public class TaskInfo { dest.writeInt(taskId); dest.writeInt(displayId); dest.writeBoolean(isRunning); + dest.writeTypedObject(baseIntent, 0); - if (baseIntent != null) { - dest.writeInt(1); - baseIntent.writeToParcel(dest, 0); - } else { - dest.writeInt(0); - } ComponentName.writeToParcel(baseActivity, dest); ComponentName.writeToParcel(topActivity, dest); ComponentName.writeToParcel(origActivity, dest); @@ -274,30 +277,16 @@ public class TaskInfo { dest.writeInt(numActivities); dest.writeLong(lastActiveTime); - if (taskDescription != null) { - dest.writeInt(1); - taskDescription.writeToParcel(dest, flags); - } else { - dest.writeInt(0); - } + dest.writeTypedObject(taskDescription, flags); dest.writeBoolean(supportsSplitScreenMultiWindow); dest.writeInt(resizeMode); configuration.writeToParcel(dest, flags); token.writeToParcel(dest, flags); dest.writeInt(topActivityType); - if (pictureInPictureParams == null) { - dest.writeInt(0); - } else { - dest.writeInt(1); - pictureInPictureParams.writeToParcel(dest, flags); - } - if (topActivityInfo == null) { - dest.writeInt(0); - } else { - dest.writeInt(1); - topActivityInfo.writeToParcel(dest, flags); - } + dest.writeTypedObject(pictureInPictureParams, flags); + dest.writeTypedObject(topActivityInfo, flags); dest.writeBoolean(isResizeable); + dest.writeBinderList(launchCookies); } @Override @@ -316,6 +305,7 @@ public class TaskInfo { + " token=" + token + " topActivityType=" + topActivityType + " pictureInPictureParams=" + pictureInPictureParams - + " topActivityInfo=" + topActivityInfo; + + " topActivityInfo=" + topActivityInfo + + " launchCookies" + launchCookies; } } |
