diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
index b5a575499a3a4..922472a261132 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
@@ -59,6 +59,8 @@ import java.util.concurrent.Executor;
public class Bubble implements BubbleViewProvider {
private static final String TAG = "Bubble";
+ public static final String KEY_APP_BUBBLE = "key_app_bubble";
+
private final String mKey;
@Nullable
private final String mGroupKey;
@@ -163,6 +165,14 @@ public class Bubble implements BubbleViewProvider {
@Nullable
private PendingIntent mDeleteIntent;
+ /**
+ * Used only for a special bubble in the stack that has the key {@link #KEY_APP_BUBBLE}.
+ * There can only be one of these bubbles in the stack and this intent will be populated for
+ * that bubble.
+ */
+ @Nullable
+ private Intent mAppIntent;
+
/**
* Create a bubble with limited information based on given {@link ShortcutInfo}.
* Note: Currently this is only being used when the bubble is persisted to disk.
@@ -192,6 +202,22 @@ public class Bubble implements BubbleViewProvider {
mBubbleMetadataFlagListener = listener;
}
+ public Bubble(Intent intent,
+ UserHandle user,
+ Executor mainExecutor) {
+ mKey = KEY_APP_BUBBLE;
+ mGroupKey = null;
+ mLocusId = null;
+ mFlags = 0;
+ mUser = user;
+ mShowBubbleUpdateDot = false;
+ mMainExecutor = mainExecutor;
+ mTaskId = INVALID_TASK_ID;
+ mAppIntent = intent;
+ mDesiredHeight = Integer.MAX_VALUE;
+ mPackageName = intent.getPackage();
+ }
+
@VisibleForTesting(visibility = PRIVATE)
public Bubble(@NonNull final BubbleEntry entry,
final Bubbles.BubbleMetadataFlagListener listener,
@@ -417,6 +443,9 @@ public class Bubble implements BubbleViewProvider {
mShortcutInfo = info.shortcutInfo;
mAppName = info.appName;
+ if (mTitle == null) {
+ mTitle = mAppName;
+ }
mFlyoutMessage = info.flyoutMessage;
mBadgeBitmap = info.badgeBitmap;
@@ -520,7 +549,7 @@ public class Bubble implements BubbleViewProvider {
* @return the last time this bubble was updated or accessed, whichever is most recent.
*/
long getLastActivity() {
- return Math.max(mLastUpdated, mLastAccessed);
+ return isAppBubble() ? Long.MAX_VALUE : Math.max(mLastUpdated, mLastAccessed);
}
/**
@@ -719,6 +748,15 @@ public class Bubble implements BubbleViewProvider {
return mDeleteIntent;
}
+ @Nullable
+ Intent getAppBubbleIntent() {
+ return mAppIntent;
+ }
+
+ boolean isAppBubble() {
+ return KEY_APP_BUBBLE.equals(mKey);
+ }
+
Intent getSettingsIntent(final Context context) {
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index 0dfba3464f236..93413dbe7e5fd 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1016,6 +1016,20 @@ public class BubbleController implements ConfigurationChangeListener {
}
}
+ /**
+ * Adds a bubble for a specific intent. These bubbles are not backed by a notification
+ * and remain until the user dismisses the bubble or bubble stack. Only one intent bubble
+ * is supported at a time.
+ *
+ * @param intent the intent to display in the bubble expanded view.
+ */
+ public void addAppBubble(Intent intent) {
+ if (intent == null || intent.getPackage() == null) return;
+ Bubble b = new Bubble(intent, UserHandle.of(mCurrentUserId), mMainExecutor);
+ b.setShouldAutoExpand(true);
+ inflateAndAdd(b, /* suppressFlyout= */ true, /* showInShade= */ false);
+ }
+
/**
* Fills the overflow bubbles by loading them from disk.
*/
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
index 840b2856270c4..06f232cb7489f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java
@@ -224,15 +224,23 @@ public class BubbleExpandedView extends LinearLayout {
try {
options.setTaskAlwaysOnTop(true);
options.setLaunchedFromBubble(true);
- if (!mIsOverflow && mBubble.hasMetadataShortcutId()) {
+
+ Intent fillInIntent = new Intent();
+ // Apply flags to make behaviour match documentLaunchMode=always.
+ fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
+ fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
+
+ if (mBubble.isAppBubble()) {
+ PendingIntent pi = PendingIntent.getActivity(mContext, 0,
+ mBubble.getAppBubbleIntent(),
+ PendingIntent.FLAG_MUTABLE,
+ null);
+ mTaskView.startActivity(pi, fillInIntent, options, launchBounds);
+ } else if (!mIsOverflow && mBubble.hasMetadataShortcutId()) {
options.setApplyActivityFlagsForBubbles(true);
mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
options, launchBounds);
} else {
- Intent fillInIntent = new Intent();
- // Apply flags to make behaviour match documentLaunchMode=always.
- fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
- fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
if (mBubble != null) {
mBubble.setIntentActive();
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
index c9d523c779ea9..33074de8f583b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java
@@ -591,6 +591,7 @@ public abstract class WMShellBaseModule {
ShellInit shellInit,
ShellController shellController,
ShellCommandHandler shellCommandHandler,
+ Optional bubbleController,
WindowManager windowManager,
ShellTaskOrganizer organizer,
TaskViewTransitions taskViewTransitions,
@@ -602,6 +603,7 @@ public abstract class WMShellBaseModule {
shellInit,
shellController,
shellCommandHandler,
+ bubbleController,
windowManager,
organizer,
taskViewTransitions,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/floating/FloatingTasksController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/floating/FloatingTasksController.java
index c79b9b8cc443a..67552991869b8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/floating/FloatingTasksController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/floating/FloatingTasksController.java
@@ -39,6 +39,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.TaskViewTransitions;
+import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
@@ -54,6 +55,7 @@ import com.android.wm.shell.sysui.ShellInit;
import java.io.PrintWriter;
import java.util.Objects;
+import java.util.Optional;
/**
* Entry point for creating and managing floating tasks.
@@ -70,6 +72,8 @@ public class FloatingTasksController implements RemoteCallable bubbleController,
WindowManager windowManager,
ShellTaskOrganizer organizer,
TaskViewTransitions transitions,
@@ -120,6 +126,7 @@ public class FloatingTasksController implements RemoteCallable