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

Commit 0e7e9487 authored by Jerry Chang's avatar Jerry Chang
Browse files

Fix drag to split gesture puts an existing task into pip mode

And flag drag-to-split launch with no-user-action to prevent sending
user leaving event to the current top activity since it's going to be
put into another side of the split. This prevents the current top
activity from going into pip mode with user leaving event.

Bug: 223936167
Test: atest WMShellUnitTests
Test: Drag an app icon onto a task which supports auto-pip, it'll enter
      multi-window mode instead of pip mode properly.
Change-Id: Ifbeccbd19c8c83a31e116d9a73a2d7432c07917f
parent 4bb44e08
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.splitscreen;

import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.content.Intent.FLAG_ACTIVITY_NO_USER_ACTION;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.RemoteAnimationTarget.MODE_OPENING;

@@ -321,8 +322,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        }
    }

    public void startIntent(PendingIntent intent, Intent fillInIntent, @SplitPosition int position,
            @Nullable Bundle options) {
    public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent,
            @SplitPosition int position, @Nullable Bundle options) {
        if (!ENABLE_SHELL_TRANSITIONS) {
            startIntentLegacy(intent, fillInIntent, position, options);
            return;
@@ -331,6 +332,15 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        try {
            options = mStageCoordinator.resolveStartStage(STAGE_TYPE_UNDEFINED, position, options,
                    null /* wct */);

            // Flag this as a no-user-action launch to prevent sending user leaving event to the
            // current top activity since it's going to be put into another side of the split. This
            // prevents the current top activity from going into pip mode due to user leaving event.
            if (fillInIntent == null) {
                fillInIntent = new Intent();
            }
            fillInIntent.addFlags(FLAG_ACTIVITY_NO_USER_ACTION);

            intent.send(mContext, 0, fillInIntent, null /* onFinished */, null /* handler */,
                    null /* requiredPermission */, options);
        } catch (PendingIntent.CanceledException e) {
@@ -338,7 +348,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        }
    }

    private void startIntentLegacy(PendingIntent intent, Intent fillInIntent,
    private void startIntentLegacy(PendingIntent intent, @Nullable Intent fillInIntent,
            @SplitPosition int position, @Nullable Bundle options) {
        final WindowContainerTransaction evictWct = new WindowContainerTransaction();
        mStageCoordinator.prepareEvictChildTasks(position, evictWct);
@@ -377,6 +387,15 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,

        final WindowContainerTransaction wct = new WindowContainerTransaction();
        options = mStageCoordinator.resolveStartStage(STAGE_TYPE_UNDEFINED, position, options, wct);

        // Flag this as a no-user-action launch to prevent sending user leaving event to the current
        // top activity since it's going to be put into another side of the split. This prevents the
        // current top activity from going into pip mode due to user leaving event.
        if (fillInIntent == null) {
            fillInIntent = new Intent();
        }
        fillInIntent.addFlags(FLAG_ACTIVITY_NO_USER_ACTION);

        wct.sendPendingIntent(intent, fillInIntent, options);
        mSyncQueue.queue(transition, WindowManager.TRANSIT_OPEN, wct);
    }