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

Commit cc2d9171 authored by Ats Jenk's avatar Ats Jenk
Browse files

Only clear launch bounds if split is launching with active bubbles

Bubbled tasks have bounds set. Tasks launched in split should not have
specific bounds set as they need to inherint them from parent.

When launching split screen via an intent, we don't know if an existing
bubble will be reused or not. Previously we were always clearing the
launch bounds when a task moved to split. But this caused performance
regressions with launching split screen.
Limit clearing of the launch bounds to only scenario when there are
active bubbles. We still do not know if the existing bubble will be used
for the split screen, but if there are bubbles present, it might.
And if there are no bubbles, we can know for certain that an existing
bubbled task is not used. And we do not need to clear bounds.

Bug: 422665646
Test: atest WMShellUnitTests:StageCoordinatorTests
Test: manual, have Calculator in a bubble, start split screen using
  Clock from home screen, select Calculator as the second split app,
  observe that Clock and Calculator and Clock start in split screen with
  correct bounds
Flag: com.android.wm.shell.enable_enter_split_remove_bubble
Change-Id: I655ff78adffca0322f8fc271a56f0425696eb281
parent 8df8b77e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -638,7 +638,8 @@ public abstract class WMShellModule {
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer,
            DesktopState desktopState,
            IActivityTaskManager activityTaskManager,
            MSDLPlayer msdlPlayer) {
            MSDLPlayer msdlPlayer,
            Optional<BubbleController> bubbleController) {
        return new SplitScreenController(
                context,
                shellInit,
@@ -667,7 +668,8 @@ public abstract class WMShellModule {
                rootDisplayAreaOrganizer,
                desktopState,
                activityTaskManager,
                msdlPlayer);
                msdlPlayer,
                bubbleController);
    }

    //
+7 −2
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ import com.android.wm.shell.R;
import com.android.wm.shell.RootDisplayAreaOrganizer;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.common.ComponentUtils;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
@@ -215,6 +216,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
    private final SplitScreenShellCommandHandler mSplitScreenShellCommandHandler;
    private final DesktopState mDesktopState;
    private final MSDLPlayer mMSDLPlayer;
    private final Optional<BubbleController> mBubbleController;

    @VisibleForTesting
    StageCoordinator mStageCoordinator;
@@ -250,7 +252,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer,
            DesktopState desktopState,
            IActivityTaskManager activityTaskManager,
            MSDLPlayer msdlPlayer) {
            MSDLPlayer msdlPlayer,
            Optional<BubbleController> bubbleController) {
        mShellCommandHandler = shellCommandHandler;
        mShellController = shellController;
        mTaskOrganizer = shellTaskOrganizer;
@@ -280,6 +283,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        mSplitScreenShellCommandHandler = new SplitScreenShellCommandHandler(this);
        mDesktopState = desktopState;
        mMSDLPlayer = msdlPlayer;
        mBubbleController = bubbleController;
        // TODO(b/238217847): Temporarily add this check here until we can remove the dynamic
        //                    override for this controller from the base module
        if (ActivityTaskManager.supportsSplitScreenMultiWindow(context)) {
@@ -325,7 +329,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
                mMainExecutor, mMainHandler, mRecentTasksOptional, mLaunchAdjacentController,
                mWindowDecorViewModel, mSplitState, mDesktopTasksController,
                mDesktopUserRepositories, mRootTDAOrganizer,
                mRootDisplayAreaOrganizer, mDesktopState, mActivityTaskManager, mMSDLPlayer);
                mRootDisplayAreaOrganizer, mDesktopState, mActivityTaskManager, mMSDLPlayer,
                mBubbleController);
    }

    @Override
+16 −5
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ import com.android.wm.shell.R;
import com.android.wm.shell.RootDisplayAreaOrganizer;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.bubbles.BubbleController;
import com.android.wm.shell.common.ComponentUtils;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
@@ -255,6 +256,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    private final DesktopState mDesktopState;
    /** A haptics controller that plays haptic effects. */
    private final MSDLPlayer mMSDLPlayer;
    private final Optional<BubbleController> mBubbleController;

    private final Rect mTempRect1 = new Rect();
    private final Rect mTempRect2 = new Rect();
@@ -402,7 +404,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            Optional<DesktopUserRepositories> desktopUserRepositories,
            RootTaskDisplayAreaOrganizer rootTDAOrganizer,
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer, DesktopState desktopState,
            IActivityTaskManager activityTaskManager, MSDLPlayer msdlPlayer) {
            IActivityTaskManager activityTaskManager, MSDLPlayer msdlPlayer,
            Optional<BubbleController> bubbleController) {
        mContext = context;
        mDisplayId = displayId;
        mSyncQueue = syncQueue;
@@ -420,6 +423,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mRootTDAOrganizer = rootTDAOrganizer;
        mDesktopState = desktopState;
        mMSDLPlayer = msdlPlayer;
        mBubbleController = bubbleController;

        DisplayManager displayManager = context.getSystemService(DisplayManager.class);

@@ -509,7 +513,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            Optional<DesktopUserRepositories> desktopUserRepositories,
            RootTaskDisplayAreaOrganizer rootTDAOrganizer,
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer, DesktopState desktopState,
            IActivityTaskManager activityTaskManager, MSDLPlayer msdlPlayer) {
            IActivityTaskManager activityTaskManager, MSDLPlayer msdlPlayer,
            Optional<BubbleController> bubbleController) {
        mContext = context;
        mDisplayId = displayId;
        mSyncQueue = syncQueue;
@@ -537,6 +542,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mRootTDAOrganizer = rootTDAOrganizer;
        mDesktopState = desktopState;
        mMSDLPlayer = msdlPlayer;
        mBubbleController = bubbleController;

        mDisplayController.addDisplayWindowListener(this);
        transitions.addHandler(this);
@@ -2087,10 +2093,15 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        //                     this might have to be changed as more split-to-pip cujs are defined.
        options.setDisallowEnterPictureInPictureWhileLaunching(true);
        if (enableEnterSplitRemoveBubble()) {
            // Set an empty rect as the requested launch bounds. This ensures that if an existing
            // task is reused, and it has bounds set, they are cleared.
            mBubbleController.ifPresent(bc -> {
                if (bc.hasBubbles()) {
                    // Bubbles are present. Set an empty rect for the launch bounds in case we
                    // are launching an existing bubble task to split. Bubbles sets bounds on the
                    // task level and we need to clear them before a task can enter split screen.
                    options.setLaunchBounds(new Rect());
                }
            });
        }

        opts.putAll(options.toBundle());
    }
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class TvSplitScreenController extends SplitScreenController {
                Optional.empty(), Optional.empty(), null /* stageCoordinator */,
                multiInstanceHelper, splitState,
                mainExecutor, mainHandler, rootDisplayAreaOrganizer, desktopState,
                activityTaskManager, msdlPlayer);
                activityTaskManager, msdlPlayer, Optional.empty());

        mTaskOrganizer = shellTaskOrganizer;
        mSyncQueue = syncQueue;
+2 −1
Original line number Diff line number Diff line
@@ -68,7 +68,8 @@ public class TvStageCoordinator extends StageCoordinator
                displayInsetsController, transitions, transactionPool, iconProvider,
                mainExecutor, mainHandler, recentTasks, launchAdjacentController,
                Optional.empty(), splitState, Optional.empty(), Optional.empty(), rootTDAOrganizer,
                rootDisplayAreaOrganizer, desktopState, activityTaskManager, msdlPlayer);
                rootDisplayAreaOrganizer, desktopState, activityTaskManager, msdlPlayer,
                Optional.empty());

        mTvSplitMenuController = new TvSplitMenuController(context, this,
                systemWindows, mainHandler);
Loading