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

Commit 8f0eb87c authored by Louis Chang's avatar Louis Chang
Browse files

Adding a WCT to update a Task policy of launch-next-to-bubble

Sets when a Task turns into a Bubble and reset it when it leaves.

Bug: 388651207
Test: wm presubmit
Test: WindowContainerTransactionTests
Flag: com.android.wm.shell.enable_create_any_bubble
Change-Id: I74b49191c0462007b609c065be7cd7e91ae5b896
parent c7d34595
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -225,6 +225,19 @@ public final class WindowContainerTransaction implements Parcelable {
        return this;
    }

    /**
     * Sets whether the container should launch next as Bubble
     * @hide
     */
    @NonNull
    public WindowContainerTransaction setLaunchNextToBubble(
            @NonNull WindowContainerToken container, boolean launchNextToBubble) {
        final Change chg = getOrCreateChange(container.asBinder());
        chg.mLaunchNextToBubble = launchNextToBubble;
        chg.mChangeMask |= Change.CHANGE_LAUNCH_NEXT_TO_BUBBLE;
        return this;
    }

    /**
     * Sets whether a container or any of its children can be focusable. When {@code false}, no
     * child can be focused; however, when {@code true}, it is still possible for children to be
@@ -1341,6 +1354,7 @@ public final class WindowContainerTransaction implements Parcelable {
        public static final int CHANGE_DRAG_RESIZING = 1 << 7;
        public static final int CHANGE_RELATIVE_BOUNDS = 1 << 8;
        public static final int CHANGE_FORCE_EXCLUDED_FROM_RECENTS = 1 << 9;
        public static final int CHANGE_LAUNCH_NEXT_TO_BUBBLE = 1 << 10;

        @IntDef(flag = true, prefix = { "CHANGE_" }, value = {
                CHANGE_FOCUSABLE,
@@ -1353,6 +1367,7 @@ public final class WindowContainerTransaction implements Parcelable {
                CHANGE_DRAG_RESIZING,
                CHANGE_RELATIVE_BOUNDS,
                CHANGE_FORCE_EXCLUDED_FROM_RECENTS,
                CHANGE_LAUNCH_NEXT_TO_BUBBLE,
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface ChangeMask {}
@@ -1377,6 +1392,8 @@ public final class WindowContainerTransaction implements Parcelable {
        private int mActivityWindowingMode = -1;
        private int mWindowingMode = -1;

        private boolean mLaunchNextToBubble = false;

        private Change() {}

        private Change(@NonNull Parcel in) {
@@ -1402,6 +1419,7 @@ public final class WindowContainerTransaction implements Parcelable {

            mWindowingMode = in.readInt();
            mActivityWindowingMode = in.readInt();
            mLaunchNextToBubble = in.readBoolean();
        }

        /**
@@ -1435,6 +1453,9 @@ public final class WindowContainerTransaction implements Parcelable {
            if ((other.mChangeMask & CHANGE_FORCE_EXCLUDED_FROM_RECENTS) != 0) {
                mForceExcludedFromRecents = other.mForceExcludedFromRecents;
            }
            if ((other.mChangeMask & CHANGE_LAUNCH_NEXT_TO_BUBBLE) != 0) {
                mLaunchNextToBubble = other.mLaunchNextToBubble;
            }
            mChangeMask |= other.mChangeMask;
            if (other.mActivityWindowingMode >= WINDOWING_MODE_UNDEFINED) {
                mActivityWindowingMode = other.mActivityWindowingMode;
@@ -1464,6 +1485,15 @@ public final class WindowContainerTransaction implements Parcelable {
            return mConfiguration;
        }

        /** Gets the requested mLaunchNextToBubble state */
        public boolean getLaunchNextToBubble() {
            if ((mChangeMask & CHANGE_LAUNCH_NEXT_TO_BUBBLE) == 0) {
                throw new RuntimeException(
                        "mLaunchNextToBubble not set. check CHANGE_LAUNCH_NEXT_TO_BUBBLE first");
            }
            return mLaunchNextToBubble;
        }

        /** Gets the requested focusable state */
        public boolean getFocusable() {
            if ((mChangeMask & CHANGE_FOCUSABLE) == 0) {
@@ -1598,6 +1628,9 @@ public final class WindowContainerTransaction implements Parcelable {
            if ((mChangeMask & CHANGE_RELATIVE_BOUNDS) != 0) {
                sb.append("relativeBounds:").append(mRelativeBounds).append(",");
            }
            if ((mChangeMask & CHANGE_LAUNCH_NEXT_TO_BUBBLE) != 0) {
                sb.append("launchNextToBubble:").append(mLaunchNextToBubble).append(",");
            }
            if (mConfigAtTransitionEnd) {
                sb.append("configAtTransitionEnd").append(",");
            }
@@ -1628,6 +1661,7 @@ public final class WindowContainerTransaction implements Parcelable {

            dest.writeInt(mWindowingMode);
            dest.writeInt(mActivityWindowingMode);
            dest.writeBoolean(mLaunchNextToBubble);
        }

        @Override
+2 −2
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ public class BubbleExpandedView extends LinearLayout {
                                // Needs to be mutable for the fillInIntent
                                PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
                                /* options= */ null);
                        options.setLaunchNextToBubble(true);
                        options.setLaunchNextToBubble(true /* launchNextToBubble */);
                        mTaskView.startActivity(pi, fillInIntent, options, launchBounds);
                    } else if (!mIsOverflow && isShortcutBubble) {
                        ProtoLog.v(WM_SHELL_BUBBLES, "startingShortcutBubble=%s", getBubbleKey());
@@ -257,7 +257,7 @@ public class BubbleExpandedView extends LinearLayout {
                            options.setLaunchedFromBubble(true);
                            options.setApplyActivityFlagsForBubbles(true);
                        } else {
                            options.setLaunchNextToBubble(true);
                            options.setLaunchNextToBubble(true /* launchNextToBubble */);
                            options.setApplyMultipleTaskFlagForShortcut(true);
                        }
                        mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ class BubbleTaskStackListener(

        val wct = WindowContainerTransaction()
        wct.setTaskForceExcludedFromRecents(task.token, false /* forceExcluded */)
            .setLaunchNextToBubble(task.token, false /* launchNextToBubble */)
        taskOrganizer.applyTransaction(wct)

        taskOrganizer.setInterceptBackPressedOnTaskRoot(task.token, false /* intercept */)
+2 −2
Original line number Diff line number Diff line
@@ -144,14 +144,14 @@ public class BubbleTaskViewListener implements TaskView.Listener {
                                PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT,
                                /* options= */ null);
                    }
                    options.setLaunchNextToBubble(true);
                    options.setLaunchNextToBubble(true /* launchNextToBubble */);
                    mTaskView.startActivity(pi, fillInIntent, options, launchBounds);
                } else if (isShortcutBubble) {
                    if (mBubble.isChat()) {
                        options.setLaunchedFromBubble(true);
                        options.setApplyActivityFlagsForBubbles(true);
                    } else {
                        options.setLaunchNextToBubble(true);
                        options.setLaunchNextToBubble(true /* launchNextToBubble */);
                        options.setApplyMultipleTaskFlagForShortcut(true);
                    }
                    mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,7 @@ public class BubbleTransitions {
            }

            wct.setAlwaysOnTop(mTaskInfo.token, true /* alwaysOnTop */);
            wct.setLaunchNextToBubble(mTaskInfo.token, true /* launchNextToBubble */);
            if (com.android.window.flags.Flags.excludeTaskFromRecents()) {
                wct.setTaskForceExcludedFromRecents(mTaskInfo.token, true /* forceExcluded */);
            }
@@ -533,6 +534,7 @@ public class BubbleTransitions {
            final WindowContainerToken token = mTaskInfo.getToken();
            wct.setWindowingMode(token, WINDOWING_MODE_UNDEFINED);
            wct.setAlwaysOnTop(token, false /* alwaysOnTop */);
            wct.setLaunchNextToBubble(token, false /* launchNextToBubble */);
            if (com.android.window.flags.Flags.excludeTaskFromRecents()) {
                wct.setTaskForceExcludedFromRecents(token, false /* forceExcluded */);
            }
@@ -696,6 +698,7 @@ public class BubbleTransitions {
            final WindowContainerToken token = bubble.getTaskView().getTaskInfo().getToken();
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            wct.setAlwaysOnTop(token, false /* alwaysOnTop */);
            wct.setLaunchNextToBubble(token, false /* launchNextToBubble */);
            if (com.android.window.flags.Flags.excludeTaskFromRecents()) {
                wct.setTaskForceExcludedFromRecents(token, false /* forceExcluded */);
            }
Loading