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

Commit 1ecb1ccb authored by Mady Mellor's avatar Mady Mellor
Browse files

Bubble API: intent extra for bubbled activities

Apps need a better way to check if their shortcut or
pending intent is bubbled, to do this we'll add an intent
extra on the bubbled activity that they may check.

- updated doc around bubbles for how to check the extra
- applied flag on activity for intent & shortcut

Bug: 171220648
Test: atest NotificationManagerTest (see CTS CL)
Change-Id: Iba97a0058e1e4fc33c4df32a3f258ff350ad04e2
parent 32906bfb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10962,6 +10962,7 @@ package android.content {
    field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
    field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
    field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
    field public static final String EXTRA_IS_BUBBLED = "android.intent.extra.IS_BUBBLED";
    field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
    field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
    field public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
+18 −0
Original line number Diff line number Diff line
@@ -9474,6 +9474,15 @@ 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>
             *
             * <p>If the shortcut has not been published when the bubble notification is sent,
             * no bubble will be produced. If the shortcut is deleted while the bubble is active,
             * the bubble will be removed.</p>
@@ -9502,6 +9511,15 @@ 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>
             *
             * @throws NullPointerException if intent is null.
             * @throws NullPointerException if icon is null.
             */
+11 −1
Original line number Diff line number Diff line
@@ -6062,6 +6062,16 @@ 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).
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ public class BubbleExpandedView extends LinearLayout {
                        // Apply flags to make behaviour match documentLaunchMode=always.
                        fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                        fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
                        fillInIntent.putExtra(Intent.EXTRA_IS_BUBBLED, true);
                        if (mBubble != null) {
                            mBubble.setIntentActive();
                        }
+1 −0
Original line number Diff line number Diff line
@@ -929,6 +929,7 @@ public class LauncherAppsService extends SystemService {
                // Flag for bubble to make behaviour match documentLaunchMode=always.
                intents[0].addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                intents[0].addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
                intents[0].putExtra(Intent.EXTRA_IS_BUBBLED, true);
            }

            intents[0].addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);