summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2021-04-12 14:53:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-04-12 14:53:01 +0000
commit02b75bb425be4aa0d326ce582d9169374795b60f (patch)
tree2f8585bce773fc066393b298b76bb19be32360c9 /core/java/android
parent7d9605d7c1c8659f95904caf84cd143d14fa4ffe (diff)
parent8693eabf20e798634427e812d69018232a926191 (diff)
Merge "API Update: extra_is_bubbled -> Activity#isLaunchedFromBubble" into sc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Activity.java22
-rw-r--r--core/java/android/app/ActivityOptions.java25
-rw-r--r--core/java/android/app/ActivityThread.java7
-rw-r--r--core/java/android/app/Notification.java18
-rw-r--r--core/java/android/app/servertransaction/LaunchActivityItem.java20
-rw-r--r--core/java/android/content/Intent.java10
6 files changed, 71 insertions, 31 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index f0d5a893bb96..45120b694b62 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -899,6 +899,9 @@ public class Activity extends ContextThemeWrapper
/** The options for scene transition. */
ActivityOptions mPendingOptions;
+ /** Whether this activity was launched from a bubble. **/
+ boolean mLaunchedFromBubble;
+
private static final class ManagedCursor {
ManagedCursor(Cursor cursor) {
mCursor = cursor;
@@ -6790,6 +6793,25 @@ public class Activity extends ContextThemeWrapper
return getSharedPreferences(getLocalClassName(), mode);
}
+ /**
+ * Indicates whether this activity is launched from a bubble. A bubble is a floating shortcut
+ * on the screen that expands to show an activity.
+ *
+ * If your activity can be used normally or as a bubble, you might use this method to check
+ * if the activity is bubbled to modify any behaviour that might be different between the
+ * normal activity and the bubbled activity. For example, if you normally cancel the
+ * notification associated with the activity when you open the activity, you might not want to
+ * do that when you're bubbled as that would remove the bubble.
+ *
+ * @return {@code true} if the activity is launched from a bubble.
+ *
+ * @see Notification.Builder#setBubbleMetadata(Notification.BubbleMetadata)
+ * @see Notification.BubbleMetadata.Builder#Builder(String)
+ */
+ public boolean isLaunchedFromBubble() {
+ return mLaunchedFromBubble;
+ }
+
private void ensureSearchManager() {
if (mSearchManager != null) {
return;
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index 006b2b5161d3..c21de62ed38e 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -323,6 +323,9 @@ public class ActivityOptions {
/** See {@link #setRemoveWithTaskOrganizer(boolean)}. */
private static final String KEY_REMOVE_WITH_TASK_ORGANIZER =
"android.activity.removeWithTaskOrganizer";
+ /** See {@link #setLaunchedFromBubble(boolean)}. */
+ private static final String KEY_LAUNCHED_FROM_BUBBLE =
+ "android.activity.launchTypeBubble";
/**
* @see #setLaunchCookie
@@ -410,6 +413,7 @@ public class ActivityOptions {
private boolean mOverrideTaskTransition;
private int mSplashScreenThemeResId;
private boolean mRemoveWithTaskOrganizer;
+ private boolean mLaunchedFromBubble;
/**
* Create an ActivityOptions specifying a custom animation to run when
@@ -1161,6 +1165,7 @@ public class ActivityOptions {
mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION);
mSplashScreenThemeResId = opts.getInt(KEY_SPLASH_SCREEN_THEME);
mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER);
+ mLaunchedFromBubble = opts.getBoolean(KEY_LAUNCHED_FROM_BUBBLE);
}
/**
@@ -1647,6 +1652,23 @@ public class ActivityOptions {
}
/**
+ * Sets whether this activity is launched from a bubble.
+ * @hide
+ */
+ @TestApi
+ public void setLaunchedFromBubble(boolean fromBubble) {
+ mLaunchedFromBubble = fromBubble;
+ }
+
+ /**
+ * @return whether the activity was launched from a bubble.
+ * @hide
+ */
+ public boolean getLaunchedFromBubble() {
+ return mLaunchedFromBubble;
+ }
+
+ /**
* 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.
@@ -1883,6 +1905,9 @@ public class ActivityOptions {
if (mRemoveWithTaskOrganizer) {
b.putBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER, mRemoveWithTaskOrganizer);
}
+ if (mLaunchedFromBubble) {
+ b.putBoolean(KEY_LAUNCHED_FROM_BUBBLE, mLaunchedFromBubble);
+ }
return b;
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 35890c811428..8ff14b0ad28f 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -594,6 +594,9 @@ public final class ActivityThread extends ClientTransactionHandler
*/
FixedRotationAdjustments mPendingFixedRotationAdjustments;
+ /** Whether this activiy was launched from a bubble. */
+ boolean mLaunchedFromBubble;
+
@LifecycleState
private int mLifecycleState = PRE_ON_CREATE;
@@ -613,7 +616,7 @@ public final class ActivityThread extends ClientTransactionHandler
List<ReferrerIntent> pendingNewIntents, ActivityOptions activityOptions,
boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client,
IBinder assistToken, FixedRotationAdjustments fixedRotationAdjustments,
- IBinder shareableActivityToken) {
+ IBinder shareableActivityToken, boolean launchedFromBubble) {
this.token = token;
this.assistToken = assistToken;
this.shareableActivityToken = shareableActivityToken;
@@ -634,6 +637,7 @@ public final class ActivityThread extends ClientTransactionHandler
compatInfo);
mActivityOptions = activityOptions;
mPendingFixedRotationAdjustments = fixedRotationAdjustments;
+ mLaunchedFromBubble = launchedFromBubble;
init();
}
@@ -3549,6 +3553,7 @@ public final class ActivityThread extends ClientTransactionHandler
activity.mPendingOptions = r.mActivityOptions;
r.mActivityOptions = null;
}
+ activity.mLaunchedFromBubble = r.mLaunchedFromBubble;
activity.mCalled = false;
if (r.isPersistable()) {
mInstrumentation.callActivityOnCreate(activity, r.state, r.persistentState);
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 0ca0b8521568..a60f1ca3cdcd 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -10205,13 +10205,8 @@ public class Notification implements Parcelable
* <p>The shortcut activity will be used when the bubble is expanded. This will display
* the shortcut activity in a floating window over the existing foreground activity.</p>
*
- * <p>When the shortcut is displayed in a bubble, there will be an intent
- * extra set on the activity, {@link Intent#EXTRA_IS_BUBBLED}
- * with {@code true}. You may check this in the onCreate of your activity via:
- *
- * <pre class="prettyprint">
- * boolean isBubbled = getIntent().getBooleanExtra(Intent.EXTRA_IS_BUBBLED, false);
- * </pre>
+ * <p>When the activity is launched from a bubble,
+ * {@link Activity#isLaunchedFromBubble()} will return with {@code true}.
* </p>
*
* <p>If the shortcut has not been published when the bubble notification is sent,
@@ -10242,13 +10237,8 @@ public class Notification implements Parcelable
* app content in a floating window over the existing foreground activity. The intent
* should point to a resizable activity. </p>
*
- * <p>When the activity is displayed in a bubble, there will be an intent
- * extra set on the activity, {@link Intent#EXTRA_IS_BUBBLED}
- * with {@code true}. You may check this in the onCreate of your activity via:
- *
- * <pre class="prettyprint">
- * boolean isBubbled = getIntent().getBooleanExtra(Intent.EXTRA_IS_BUBBLED, false);
- * </pre>
+ * <p>When the activity is launched from a bubble,
+ * {@link Activity#isLaunchedFromBubble()} will return with {@code true}.
* </p>
*
* @throws NullPointerException if intent is null.
diff --git a/core/java/android/app/servertransaction/LaunchActivityItem.java b/core/java/android/app/servertransaction/LaunchActivityItem.java
index 9f8fcc15b747..e281a0268184 100644
--- a/core/java/android/app/servertransaction/LaunchActivityItem.java
+++ b/core/java/android/app/servertransaction/LaunchActivityItem.java
@@ -72,6 +72,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
private ProfilerInfo mProfilerInfo;
private IBinder mAssistToken;
private IBinder mShareableActivityToken;
+ private boolean mLaunchedFromBubble;
/**
* It is only non-null if the process is the first time to launch activity. It is only an
* optimization for quick look up of the interface so the field is ignored for comparison.
@@ -96,7 +97,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
ActivityClientRecord r = new ActivityClientRecord(token, mIntent, mIdent, mInfo,
mOverrideConfig, mCompatInfo, mReferrer, mVoiceInteractor, mState, mPersistentState,
mPendingResults, mPendingNewIntents, mActivityOptions, mIsForward, mProfilerInfo,
- client, mAssistToken, mFixedRotationAdjustments, mShareableActivityToken);
+ client, mAssistToken, mFixedRotationAdjustments, mShareableActivityToken,
+ mLaunchedFromBubble);
client.handleLaunchActivity(r, pendingActions, null /* customIntent */);
Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
}
@@ -120,7 +122,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
List<ReferrerIntent> pendingNewIntents, ActivityOptions activityOptions,
boolean isForward, ProfilerInfo profilerInfo, IBinder assistToken,
IActivityClientController activityClientController,
- FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken) {
+ FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken,
+ boolean launchedFromBubble) {
LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class);
if (instance == null) {
instance = new LaunchActivityItem();
@@ -128,7 +131,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
setValues(instance, intent, ident, info, curConfig, overrideConfig, compatInfo, referrer,
voiceInteractor, procState, state, persistentState, pendingResults,
pendingNewIntents, activityOptions, isForward, profilerInfo, assistToken,
- activityClientController, fixedRotationAdjustments, shareableActivityToken);
+ activityClientController, fixedRotationAdjustments, shareableActivityToken,
+ launchedFromBubble);
return instance;
}
@@ -136,7 +140,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
@Override
public void recycle() {
setValues(this, null, 0, null, null, null, null, null, null, 0, null, null, null, null,
- null, false, null, null, null, null, null);
+ null, false, null, null, null, null, null, false);
ObjectPool.recycle(this);
}
@@ -166,6 +170,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
dest.writeStrongInterface(mActivityClientController);
dest.writeTypedObject(mFixedRotationAdjustments, flags);
dest.writeStrongBinder(mShareableActivityToken);
+ dest.writeBoolean(mLaunchedFromBubble);
}
/** Read from Parcel. */
@@ -183,7 +188,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
in.readTypedObject(ProfilerInfo.CREATOR),
in.readStrongBinder(),
IActivityClientController.Stub.asInterface(in.readStrongBinder()),
- in.readTypedObject(FixedRotationAdjustments.CREATOR), in.readStrongBinder());
+ in.readTypedObject(FixedRotationAdjustments.CREATOR), in.readStrongBinder(),
+ in.readBoolean());
}
public static final @NonNull Creator<LaunchActivityItem> CREATOR =
@@ -293,7 +299,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
ActivityOptions activityOptions, boolean isForward, ProfilerInfo profilerInfo,
IBinder assistToken, IActivityClientController activityClientController,
- FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken) {
+ FixedRotationAdjustments fixedRotationAdjustments, IBinder shareableActivityToken,
+ boolean launchedFromBubble) {
instance.mIntent = intent;
instance.mIdent = ident;
instance.mInfo = info;
@@ -314,5 +321,6 @@ public class LaunchActivityItem extends ClientTransactionItem {
instance.mActivityClientController = activityClientController;
instance.mFixedRotationAdjustments = fixedRotationAdjustments;
instance.mShareableActivityToken = shareableActivityToken;
+ instance.mLaunchedFromBubble = launchedFromBubble;
}
}
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index a482b8c189cd..9ad017c5f9c6 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -6177,16 +6177,6 @@ public class Intent implements Parcelable, Cloneable {
*/
public static final String EXTRA_UNSTARTABLE_REASON = "android.intent.extra.UNSTARTABLE_REASON";
- /**
- * A boolean extra indicating whether an activity is bubbled. Set on the shortcut or
- * pending intent provided for the bubble. If the extra is not present or false, then it is not
- * bubbled.
- *
- * @see android.app.Notification.Builder#setBubbleMetadata(Notification.BubbleMetadata)
- * @see android.app.Notification.BubbleMetadata.Builder#Builder(String)
- */
- public static final String EXTRA_IS_BUBBLED = "android.intent.extra.IS_BUBBLED";
-
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Intent flags (see mFlags variable).