Merge "Allow auto-pip on launching new Task from TaskBar" into sc-v2-dev am: aa2c404692

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16215474

Change-Id: Ifc5f764ed93af2928002b74a44865d7a1f155785
This commit is contained in:
Hongwei Wang
2021-11-19 00:28:19 +00:00
committed by Automerger Merge Worker
3 changed files with 24 additions and 22 deletions

View File

@@ -961,6 +961,12 @@
"group": "WM_DEBUG_ORIENTATION", "group": "WM_DEBUG_ORIENTATION",
"at": "com\/android\/server\/wm\/RootWindowContainer.java" "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": { "-1089874824": {
"message": "SURFACE SHOW (performLayout): %s", "message": "SURFACE SHOW (performLayout): %s",
"level": "INFO", "level": "INFO",
@@ -2629,12 +2635,6 @@
"group": "WM_ERROR", "group": "WM_ERROR",
"at": "com\/android\/server\/wm\/WindowManagerService.java" "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": { "662572728": {
"message": "Attempted to add a toast window with bad token %s. Aborting.", "message": "Attempted to add a toast window with bad token %s. Aborting.",
"level": "WARN", "level": "WARN",

View File

@@ -594,10 +594,10 @@ public class PipAnimationController {
getSurfaceTransactionHelper().scaleAndCrop(tx, leash, getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
initialSourceValue, bounds, insets); initialSourceValue, bounds, insets);
if (shouldApplyCornerRadius()) { if (shouldApplyCornerRadius()) {
final Rect destinationBounds = new Rect(bounds); final Rect sourceBounds = new Rect(initialContainerRect);
destinationBounds.inset(insets); sourceBounds.inset(insets);
getSurfaceTransactionHelper().round(tx, leash, getSurfaceTransactionHelper().round(tx, leash,
initialContainerRect, destinationBounds); sourceBounds, bounds);
} }
} }
if (!handlePipTransaction(leash, tx, bounds)) { if (!handlePipTransaction(leash, tx, bounds)) {
@@ -641,11 +641,13 @@ public class PipAnimationController {
y = fraction * (end.bottom - start.top) + start.top; y = fraction * (end.bottom - start.top) + start.top;
} }
} }
final Rect sourceBounds = new Rect(initialContainerRect);
sourceBounds.inset(insets);
getSurfaceTransactionHelper() getSurfaceTransactionHelper()
.rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds, .rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds,
insets, degree, x, y, isOutPipDirection, insets, degree, x, y, isOutPipDirection,
rotationDelta == ROTATION_270 /* clockwise */) rotationDelta == ROTATION_270 /* clockwise */)
.round(tx, leash, initialContainerRect, bounds); .round(tx, leash, sourceBounds, bounds);
tx.apply(); tx.apply();
} }

View File

@@ -1417,29 +1417,29 @@ class TaskFragment extends WindowContainer<WindowContainer> {
boolean pauseImmediately = false; boolean pauseImmediately = false;
boolean shouldAutoPip = false; boolean shouldAutoPip = false;
if (resuming != null && (resuming.info.flags & FLAG_RESUME_WHILE_PAUSING) != 0) { if (resuming != null) {
// If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous // Resuming the new resume activity only if the previous activity can't go into Pip
// activity to be paused, while at the same time resuming the new resume activity // since we want to give Pip activities a chance to enter Pip before resuming the
// only if the previous activity can't go into Pip since we want to give Pip // next activity.
// activities a chance to enter Pip before resuming the next activity. final boolean lastResumedCanPip = prev.checkEnterPictureInPictureState(
final boolean lastResumedCanPip = prev != null && prev.checkEnterPictureInPictureState( "shouldAutoPipWhilePausing", userLeaving);
"shouldResumeWhilePausing", userLeaving);
if (lastResumedCanPip && prev.pictureInPictureArgs.isAutoEnterEnabled()) { if (lastResumedCanPip && prev.pictureInPictureArgs.isAutoEnterEnabled()) {
shouldAutoPip = true; shouldAutoPip = true;
} else if (!lastResumedCanPip) { } 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 { } else {
// The previous activity may still enter PIP even though it did not allow auto-PIP. // The previous activity may still enter PIP even though it did not allow auto-PIP.
} }
} }
boolean didAutoPip = false;
if (prev.attachedToProcess()) { if (prev.attachedToProcess()) {
if (shouldAutoPip) { if (shouldAutoPip) {
boolean didAutoPip = mAtmService.enterPictureInPictureMode(
prev, prev.pictureInPictureArgs);
ProtoLog.d(WM_DEBUG_STATES, "Auto-PIP allowed, entering PIP mode " ProtoLog.d(WM_DEBUG_STATES, "Auto-PIP allowed, entering PIP mode "
+ "directly: %s", prev); + "directly: %s, didAutoPip: %b", prev, didAutoPip);
didAutoPip = mAtmService.enterPictureInPictureMode(prev, prev.pictureInPictureArgs);
} else { } else {
schedulePauseActivity(prev, userLeaving, pauseImmediately, reason); schedulePauseActivity(prev, userLeaving, pauseImmediately, reason);
} }