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

Commit 0a53b766 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Allow auto-pip on launching new Task from TaskBar

Loosen the check on FLAG_RESUME_WHILE_PAUSING in
TaskFragment#startPausing for auto-enter-pip.

Fixed also the round corner radius calculation in WMShell component for
entering PiP transition.

Bug: 198227082
Bug: 202574512
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/bEPWcJSn8iGbLLNg6cM0E3
Test: no auto-enter on quick switch and does on launching new Task,
      see video for details
Test: atest PinnedStackTests#testAutoPipOnLaunchingAnotherActivity
Change-Id: I53e62a5f6e663b2d6df8cd0aaa858ff01ef073e8
parent 4ad4975b
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -961,6 +961,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "-1101551167": {
      "message": "Auto-PIP allowed, entering PIP mode directly: %s, didAutoPip: %b",
      "level": "DEBUG",
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/TaskFragment.java"
    },
    "-1089874824": {
      "message": "SURFACE SHOW (performLayout): %s",
      "level": "INFO",
@@ -2629,12 +2635,6 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "660908897": {
      "message": "Auto-PIP allowed, entering PIP mode directly: %s",
      "level": "DEBUG",
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/TaskFragment.java"
    },
    "662572728": {
      "message": "Attempted to add a toast window with bad token %s.  Aborting.",
      "level": "WARN",
+6 −4
Original line number Diff line number Diff line
@@ -594,10 +594,10 @@ public class PipAnimationController {
                        getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
                                initialSourceValue, bounds, insets);
                        if (shouldApplyCornerRadius()) {
                            final Rect destinationBounds = new Rect(bounds);
                            destinationBounds.inset(insets);
                            final Rect sourceBounds = new Rect(initialContainerRect);
                            sourceBounds.inset(insets);
                            getSurfaceTransactionHelper().round(tx, leash,
                                    initialContainerRect, destinationBounds);
                                    sourceBounds, bounds);
                        }
                    }
                    if (!handlePipTransaction(leash, tx, bounds)) {
@@ -641,11 +641,13 @@ public class PipAnimationController {
                            y = fraction * (end.bottom - start.top) + start.top;
                        }
                    }
                    final Rect sourceBounds = new Rect(initialContainerRect);
                    sourceBounds.inset(insets);
                    getSurfaceTransactionHelper()
                            .rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds,
                                    insets, degree, x, y, isOutPipDirection,
                                    rotationDelta == ROTATION_270 /* clockwise */)
                            .round(tx, leash, initialContainerRect, bounds);
                            .round(tx, leash, sourceBounds, bounds);
                    tx.apply();
                }

+12 −12
Original line number Diff line number Diff line
@@ -1417,29 +1417,29 @@ class TaskFragment extends WindowContainer<WindowContainer> {

        boolean pauseImmediately = false;
        boolean shouldAutoPip = false;
        if (resuming != null && (resuming.info.flags & FLAG_RESUME_WHILE_PAUSING) != 0) {
            // If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous
            // activity to be paused, while at the same time resuming the new resume activity
            // only if the previous activity can't go into Pip since we want to give Pip
            // activities a chance to enter Pip before resuming the next activity.
            final boolean lastResumedCanPip = prev != null && prev.checkEnterPictureInPictureState(
                    "shouldResumeWhilePausing", userLeaving);
        if (resuming != null) {
            // Resuming the new resume activity only if the previous activity can't go into Pip
            // since we want to give Pip activities a chance to enter Pip before resuming the
            // next activity.
            final boolean lastResumedCanPip = prev.checkEnterPictureInPictureState(
                    "shouldAutoPipWhilePausing", userLeaving);
            if (lastResumedCanPip && prev.pictureInPictureArgs.isAutoEnterEnabled()) {
                shouldAutoPip = true;
            } else if (!lastResumedCanPip) {
                pauseImmediately = true;
                // If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous
                // activity to be paused.
                pauseImmediately = (resuming.info.flags & FLAG_RESUME_WHILE_PAUSING) != 0;
            } else {
                // The previous activity may still enter PIP even though it did not allow auto-PIP.
            }
        }

        boolean didAutoPip = false;
        if (prev.attachedToProcess()) {
            if (shouldAutoPip) {
                boolean didAutoPip = mAtmService.enterPictureInPictureMode(
                        prev, prev.pictureInPictureArgs);
                ProtoLog.d(WM_DEBUG_STATES, "Auto-PIP allowed, entering PIP mode "
                        + "directly: %s", prev);

                didAutoPip = mAtmService.enterPictureInPictureMode(prev, prev.pictureInPictureArgs);
                        + "directly: %s, didAutoPip: %b", prev, didAutoPip);
            } else {
                schedulePauseActivity(prev, userLeaving, pauseImmediately, reason);
            }