diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 8b3780590d44a..8ccf02caf8c02 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -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", diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java index 05111a3d44369..9575b0a720bc8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java @@ -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(); } diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index e66d92e8ea07c..51cede0c051d7 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1417,29 +1417,29 @@ class TaskFragment extends 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); }