summaryrefslogtreecommitdiff
path: root/core/java/android/app/ActivityOptions.java
diff options
context:
space:
mode:
authorLouis Chang <louischang@google.com>2019-04-24 18:35:20 +0800
committerLouis Chang <louischang@google.com>2019-07-29 14:44:19 +0800
commit477e93ea569b3b83a284ba1a52fd32e321a75663 (patch)
treed6f5ffad157f3efff0eaaf0f75bec84f8ff6a6e3 /core/java/android/app/ActivityOptions.java
parent31a00d0a73a69f5c728ea64d87b98b045fa0b188 (diff)
Adding caller display id when launching activities via PendingIntent
Activities were launched on primary display when they were started via PendingIntent, because we didn’t have the caller information from PendingIntent and were unable to determine the preferred displays for the newly created activities. Applications should use the correct context while calling PendingIntent.send(). Also fix that animation type could be overrides when merging two activity options. Bug: 130967908 Test: atest MultiDisplayActivityLaunchTests Change-Id: I9c50900937f20a83768d5e676b93c4c02665f8cb
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
-rw-r--r--core/java/android/app/ActivityOptions.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index 926044bffdd0..b8d9575f4b0f 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -177,6 +177,13 @@ public class ActivityOptions {
private static final String KEY_LAUNCH_DISPLAY_ID = "android.activity.launchDisplayId";
/**
+ * The id of the display where the caller was on.
+ * @see #setCallerDisplayId(int)
+ * @hide
+ */
+ private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId";
+
+ /**
* The windowing mode the activity should be launched into.
* @hide
*/
@@ -269,6 +276,8 @@ public class ActivityOptions {
= "android:activity.remoteAnimationAdapter";
/** @hide */
+ public static final int ANIM_UNDEFINED = -1;
+ /** @hide */
public static final int ANIM_NONE = 0;
/** @hide */
public static final int ANIM_CUSTOM = 1;
@@ -299,7 +308,7 @@ public class ActivityOptions {
private String mPackageName;
private Rect mLaunchBounds;
- private int mAnimationType = ANIM_NONE;
+ private int mAnimationType = ANIM_UNDEFINED;
private int mCustomEnterResId;
private int mCustomExitResId;
private int mCustomInPlaceResId;
@@ -318,6 +327,7 @@ public class ActivityOptions {
private int mExitCoordinatorIndex;
private PendingIntent mUsageTimeReport;
private int mLaunchDisplayId = INVALID_DISPLAY;
+ private int mCallerDisplayId = INVALID_DISPLAY;
@WindowConfiguration.WindowingMode
private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED;
@WindowConfiguration.ActivityType
@@ -896,7 +906,7 @@ public class ActivityOptions {
Slog.w(TAG, e);
}
mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS);
- mAnimationType = opts.getInt(KEY_ANIM_TYPE);
+ mAnimationType = opts.getInt(KEY_ANIM_TYPE, ANIM_UNDEFINED);
switch (mAnimationType) {
case ANIM_CUSTOM:
mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0);
@@ -945,6 +955,7 @@ public class ActivityOptions {
}
mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false);
mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY);
+ mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY);
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);
@@ -1204,6 +1215,17 @@ public class ActivityOptions {
}
/** @hide */
+ public int getCallerDisplayId() {
+ return mCallerDisplayId;
+ }
+
+ /** @hide */
+ public ActivityOptions setCallerDisplayId(int callerDisplayId) {
+ mCallerDisplayId = callerDisplayId;
+ return this;
+ }
+
+ /** @hide */
public int getLaunchWindowingMode() {
return mLaunchWindowingMode;
}
@@ -1447,7 +1469,9 @@ public class ActivityOptions {
if (mLaunchBounds != null) {
b.putParcelable(KEY_LAUNCH_BOUNDS, mLaunchBounds);
}
- b.putInt(KEY_ANIM_TYPE, mAnimationType);
+ if (mAnimationType != ANIM_UNDEFINED) {
+ b.putInt(KEY_ANIM_TYPE, mAnimationType);
+ }
if (mUsageTimeReport != null) {
b.putParcelable(KEY_USAGE_TIME_REPORT, mUsageTimeReport);
}
@@ -1506,6 +1530,9 @@ public class ActivityOptions {
if (mLaunchDisplayId != INVALID_DISPLAY) {
b.putInt(KEY_LAUNCH_DISPLAY_ID, mLaunchDisplayId);
}
+ if (mCallerDisplayId != INVALID_DISPLAY) {
+ b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId);
+ }
if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) {
b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode);
}