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

Commit 1d33d198 authored by Louis Chang's avatar Louis Chang
Browse files

Reduce having task trampoline when starting app Bubbles

The task trampoline on bubble may unexpectedly happen due to
the following two reasons:
- In commit a8a63db6, the bubble task cannot be reused. Therefore,
  the next activity will be launched in a new Task when needed.
- The bubble task is started as a document task. Since the document
  task cannot be reused, the next activity will be launched in a
  new Task when needed.

Avoid starting app bubble as document task. Also make the app
bubble task reusable just like other normal app tasks.

Bug: 378786164
Test: verified on couple 3p apps.
Flag: com.android.wm.shell.enable_bubble_anything
Change-Id: Ib8e16f3db77aa350f97296f7767b40bd5e966681
parent 00b503d4
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -222,15 +222,9 @@ public class BubbleExpandedView extends LinearLayout {
                    mTaskView.getBoundsOnScreen(launchBounds);

                    options.setTaskAlwaysOnTop(true);
                    options.setLaunchedFromBubble(true);
                    options.setPendingIntentBackgroundActivityStartMode(
                            MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS);

                    Intent fillInIntent = new Intent();
                    // Apply flags to make behaviour match documentLaunchMode=always.
                    fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                    fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);

                    final boolean isShortcutBubble = (mBubble.hasMetadataShortcutId()
                            || (mBubble.getShortcutInfo() != null && Flags.enableBubbleAnything()));

@@ -242,7 +236,6 @@ public class BubbleExpandedView extends LinearLayout {
                                context,
                                /* requestCode= */ 0,
                                mBubble.getAppBubbleIntent()
                                        .addFlags(FLAG_ACTIVITY_NEW_DOCUMENT)
                                        .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK),
                                PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
                                /* options= */ null);
@@ -250,13 +243,19 @@ public class BubbleExpandedView extends LinearLayout {
                                launchBounds);
                    } else if (!mIsOverflow && isShortcutBubble) {
                        ProtoLog.v(WM_SHELL_BUBBLES, "startingShortcutBubble=%s", getBubbleKey());
                        options.setLaunchedFromBubble(true);
                        options.setApplyActivityFlagsForBubbles(true);
                        mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
                                options, launchBounds);
                    } else {
                        options.setLaunchedFromBubble(true);
                        if (mBubble != null) {
                            mBubble.setIntentActive();
                        }
                        final Intent fillInIntent = new Intent();
                        // Apply flags to make behaviour match documentLaunchMode=always.
                        fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                        fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
                        mTaskView.startActivity(mPendingIntent, fillInIntent, options,
                                launchBounds);
                    }
+6 −8
Original line number Diff line number Diff line
@@ -105,15 +105,8 @@ public class BubbleTaskViewHelper {
                        getBubbleKey());
                try {
                    options.setTaskAlwaysOnTop(true);
                    options.setLaunchedFromBubble(true);
                    options.setPendingIntentBackgroundActivityStartMode(
                            MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS);

                    Intent fillInIntent = new Intent();
                    // Apply flags to make behaviour match documentLaunchMode=always.
                    fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                    fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);

                    final boolean isShortcutBubble = (mBubble.hasMetadataShortcutId()
                            || (mBubble.getShortcutInfo() != null && Flags.enableBubbleAnything()));
                    if (mBubble.isAppBubble()) {
@@ -124,20 +117,25 @@ public class BubbleTaskViewHelper {
                                context,
                                /* requestCode= */ 0,
                                mBubble.getAppBubbleIntent()
                                        .addFlags(FLAG_ACTIVITY_NEW_DOCUMENT)
                                        .addFlags(FLAG_ACTIVITY_MULTIPLE_TASK),
                                PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
                                /* options= */ null);
                        mTaskView.startActivity(pi, /* fillInIntent= */ null, options,
                                launchBounds);
                    } else if (isShortcutBubble) {
                        options.setLaunchedFromBubble(true);
                        options.setApplyActivityFlagsForBubbles(true);
                        mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
                                options, launchBounds);
                    } else {
                        options.setLaunchedFromBubble(true);
                        if (mBubble != null) {
                            mBubble.setIntentActive();
                        }
                        final Intent fillInIntent = new Intent();
                        // Apply flags to make behaviour match documentLaunchMode=always.
                        fillInIntent.addFlags(FLAG_ACTIVITY_NEW_DOCUMENT);
                        fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK);
                        mTaskView.startActivity(mPendingIntent, fillInIntent, options,
                                launchBounds);
                    }