Merge "Apply PictureInPictureSurfaceTransaction upon reparent" into sc-dev
This commit is contained in:
@@ -19,7 +19,6 @@ package android.view;
|
||||
import android.app.ActivityManager;
|
||||
import android.view.IRemoteAnimationFinishedCallback;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.graphics.Rect;
|
||||
import android.window.PictureInPictureSurfaceTransaction;
|
||||
import android.window.TaskSnapshot;
|
||||
|
||||
@@ -39,14 +38,13 @@ interface IRecentsAnimationController {
|
||||
TaskSnapshot screenshotTask(int taskId);
|
||||
|
||||
/**
|
||||
* Sets the final bounds on a Task. This is used by Launcher to notify the system that
|
||||
* animating Activity to PiP has completed and the associated task surface should be updated
|
||||
* accordingly. This should be called before `finish`
|
||||
* Sets the final surface transaction on a Task. This is used by Launcher to notify the system
|
||||
* that animating Activity to PiP has completed and the associated task surface should be
|
||||
* updated accordingly. This should be called before `finish`
|
||||
* @param taskId for which the leash should be updated
|
||||
* @param destinationBounds bounds of the final PiP window
|
||||
* @param finishTransaction leash operations for the final transform.
|
||||
*/
|
||||
void setFinishTaskBounds(int taskId, in Rect destinationBounds,
|
||||
void setFinishTaskTransaction(int taskId,
|
||||
in PictureInPictureSurfaceTransaction finishTransaction);
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package android.window;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.SurfaceControl;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -127,6 +130,22 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
|
||||
+ ")";
|
||||
}
|
||||
|
||||
/** Applies {@link PictureInPictureSurfaceTransaction} to a given leash. */
|
||||
public static void apply(@NonNull PictureInPictureSurfaceTransaction surfaceTransaction,
|
||||
@NonNull SurfaceControl surfaceControl,
|
||||
@NonNull SurfaceControl.Transaction tx) {
|
||||
final Matrix matrix = new Matrix();
|
||||
matrix.setScale(surfaceTransaction.mScaleX, surfaceTransaction.mScaleY);
|
||||
if (surfaceTransaction.mRotation != 0) {
|
||||
matrix.postRotate(surfaceTransaction.mRotation);
|
||||
}
|
||||
tx.setMatrix(surfaceControl, matrix, new float[9])
|
||||
.setPosition(surfaceControl,
|
||||
surfaceTransaction.mPositionX, surfaceTransaction.mPositionY)
|
||||
.setWindowCrop(surfaceControl, surfaceTransaction.getWindowCrop())
|
||||
.setCornerRadius(surfaceControl, surfaceTransaction.mCornerRadius);
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Creator<PictureInPictureSurfaceTransaction>
|
||||
CREATOR =
|
||||
new Creator<PictureInPictureSurfaceTransaction>() {
|
||||
|
||||
@@ -367,12 +367,6 @@
|
||||
"group": "WM_DEBUG_ORIENTATION",
|
||||
"at": "com\/android\/server\/wm\/DisplayRotation.java"
|
||||
},
|
||||
"-1729340764": {
|
||||
"message": "setFinishTaskBounds(%d): bounds=%s",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_RECENTS_ANIMATIONS",
|
||||
"at": "com\/android\/server\/wm\/RecentsAnimationController.java"
|
||||
},
|
||||
"-1715268616": {
|
||||
"message": "Last window, removing starting window %s",
|
||||
"level": "VERBOSE",
|
||||
@@ -1705,6 +1699,12 @@
|
||||
"group": "WM_ERROR",
|
||||
"at": "com\/android\/server\/wm\/WindowManagerService.java"
|
||||
},
|
||||
"-163974242": {
|
||||
"message": "setFinishTaskTransaction(%d): transaction=%s",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_RECENTS_ANIMATIONS",
|
||||
"at": "com\/android\/server\/wm\/RecentsAnimationController.java"
|
||||
},
|
||||
"-143556958": {
|
||||
"message": "resumeNextFocusableActivityWhenRootTaskIsEmpty: %s, go home",
|
||||
"level": "DEBUG",
|
||||
@@ -1897,12 +1897,6 @@
|
||||
"group": "WM_DEBUG_RECENTS_ANIMATIONS",
|
||||
"at": "com\/android\/server\/wm\/RecentsAnimationController.java"
|
||||
},
|
||||
"86989930": {
|
||||
"message": "setTaskWindowingMode: moving task=%d to windowingMode=%d toTop=%b",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_TASKS",
|
||||
"at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
|
||||
},
|
||||
"90764070": {
|
||||
"message": "Could not report token removal to the window token client.",
|
||||
"level": "WARN",
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.shared.system;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.view.IRecentsAnimationController;
|
||||
@@ -72,17 +71,16 @@ public class RecentsAnimationControllerCompat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the final bounds on a Task. This is used by Launcher to notify the system that
|
||||
* animating Activity to PiP has completed and the associated task surface should be updated
|
||||
* accordingly. This should be called before `finish`
|
||||
* Sets the final surface transaction on a Task. This is used by Launcher to notify the system
|
||||
* that animating Activity to PiP has completed and the associated task surface should be
|
||||
* updated accordingly. This should be called before `finish`
|
||||
* @param taskId Task id of the Activity in PiP mode.
|
||||
* @param destinationBounds Bounds of the PiP window on home.
|
||||
* @param finishTransaction leash operations for the final transform.
|
||||
*/
|
||||
public void setFinishTaskBounds(int taskId, Rect destinationBounds,
|
||||
public void setFinishTaskTransaction(int taskId,
|
||||
PictureInPictureSurfaceTransaction finishTransaction) {
|
||||
try {
|
||||
mAnimationController.setFinishTaskBounds(taskId, destinationBounds, finishTransaction);
|
||||
mAnimationController.setFinishTaskTransaction(taskId, finishTransaction);
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG, "Failed to set finish task bounds", e);
|
||||
}
|
||||
|
||||
@@ -185,10 +185,10 @@ public class RemoteTransitionCompat implements Parcelable {
|
||||
mWrapped.hideCurrentInputMethod();
|
||||
}
|
||||
|
||||
@Override public void setFinishTaskBounds(int taskId, Rect destinationBounds,
|
||||
@Override public void setFinishTaskTransaction(int taskId,
|
||||
PictureInPictureSurfaceTransaction finishTransaction) {
|
||||
if (mWrapped != null) {
|
||||
mWrapped.setFinishTaskBounds(taskId, destinationBounds, finishTransaction);
|
||||
mWrapped.setFinishTaskTransaction(taskId, finishTransaction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
@@ -231,17 +230,16 @@ public class RecentsAnimationController implements DeathRecipient {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinishTaskBounds(int taskId, Rect destinationBounds,
|
||||
public void setFinishTaskTransaction(int taskId,
|
||||
PictureInPictureSurfaceTransaction finishTransaction) {
|
||||
ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS,
|
||||
"setFinishTaskBounds(%d): bounds=%s", taskId, destinationBounds);
|
||||
"setFinishTaskTransaction(%d): transaction=%s", taskId, finishTransaction);
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mService.getWindowManagerLock()) {
|
||||
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
|
||||
final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i);
|
||||
if (taskAdapter.mTask.mTaskId == taskId) {
|
||||
taskAdapter.mFinishBounds.set(destinationBounds);
|
||||
taskAdapter.mFinishTransaction = finishTransaction;
|
||||
break;
|
||||
}
|
||||
@@ -1106,9 +1104,7 @@ public class RecentsAnimationController implements DeathRecipient {
|
||||
private final Rect mBounds = new Rect();
|
||||
// The bounds of the target relative to its parent.
|
||||
private final Rect mLocalBounds = new Rect();
|
||||
// The bounds of the target when animation is finished
|
||||
private final Rect mFinishBounds = new Rect();
|
||||
// Bounds and transform for the final transaction.
|
||||
// The final surface transaction when animation is finished.
|
||||
private PictureInPictureSurfaceTransaction mFinishTransaction;
|
||||
|
||||
TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) {
|
||||
@@ -1145,29 +1141,13 @@ public class RecentsAnimationController implements DeathRecipient {
|
||||
}
|
||||
|
||||
void onCleanup() {
|
||||
if (!mFinishBounds.isEmpty()) {
|
||||
final SurfaceControl taskSurface = mTask.mSurfaceControl;
|
||||
if (mFinishTransaction != null) {
|
||||
final Transaction pendingTransaction = mTask.getPendingTransaction();
|
||||
if (mFinishTransaction != null) {
|
||||
final Matrix matrix = new Matrix();
|
||||
matrix.setScale(mFinishTransaction.mScaleX, mFinishTransaction.mScaleY);
|
||||
if (mFinishTransaction.mRotation != 0) {
|
||||
matrix.postRotate(mFinishTransaction.mRotation);
|
||||
}
|
||||
pendingTransaction.setMatrix(taskSurface, matrix, new float[9])
|
||||
.setPosition(taskSurface,
|
||||
mFinishTransaction.mPositionX, mFinishTransaction.mPositionY)
|
||||
.setWindowCrop(taskSurface, mFinishTransaction.getWindowCrop())
|
||||
.setCornerRadius(taskSurface, mFinishTransaction.mCornerRadius);
|
||||
mTask.mLastRecentsAnimationBounds.set(mFinishBounds);
|
||||
mFinishTransaction = null;
|
||||
} else {
|
||||
pendingTransaction
|
||||
.setPosition(taskSurface, mFinishBounds.left, mFinishBounds.top)
|
||||
.setWindowCrop(taskSurface, mFinishBounds);
|
||||
}
|
||||
PictureInPictureSurfaceTransaction.apply(mFinishTransaction,
|
||||
mTask.mSurfaceControl, pendingTransaction);
|
||||
mTask.setLastRecentsAnimationTransaction(mFinishTransaction);
|
||||
mFinishTransaction = null;
|
||||
pendingTransaction.apply();
|
||||
mFinishBounds.setEmpty();
|
||||
} else if (!mTask.isAttached()) {
|
||||
// Apply the task's pending transaction in case it is detached and its transaction
|
||||
// is not reachable.
|
||||
@@ -1220,7 +1200,7 @@ public class RecentsAnimationController implements DeathRecipient {
|
||||
}
|
||||
pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible);
|
||||
pw.println("mLocalBounds=" + mLocalBounds);
|
||||
pw.println("mFinishBounds=" + mFinishBounds);
|
||||
pw.println("mFinishTransaction=" + mFinishTransaction);
|
||||
pw.println("mBounds=" + mBounds);
|
||||
pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible);
|
||||
}
|
||||
|
||||
@@ -2137,9 +2137,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
||||
rootTask.setLastNonFullscreenBounds(task.mLastNonFullscreenBounds);
|
||||
rootTask.setBounds(task.getBounds());
|
||||
|
||||
// Move reparent bounds from original task to the new one.
|
||||
rootTask.mLastRecentsAnimationBounds.set(task.mLastRecentsAnimationBounds);
|
||||
task.mLastRecentsAnimationBounds.setEmpty();
|
||||
// Move the last recents animation transaction from original task to the new one.
|
||||
if (task.mLastRecentsAnimationTransaction != null) {
|
||||
rootTask.setLastRecentsAnimationTransaction(
|
||||
task.mLastRecentsAnimationTransaction);
|
||||
task.clearLastRecentsAnimationTransaction();
|
||||
}
|
||||
|
||||
// There are multiple activities in the task and moving the top activity should
|
||||
// reveal/leave the other activities in their original task.
|
||||
@@ -2148,7 +2151,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
||||
r.reparent(rootTask, MAX_VALUE, reason);
|
||||
|
||||
// Ensure the leash of new task is in sync with its current bounds after reparent.
|
||||
rootTask.maybeApplyLastRecentsAnimationBounds();
|
||||
rootTask.maybeApplyLastRecentsAnimationTransaction();
|
||||
|
||||
// In the case of this activity entering PIP due to it being moved to the back,
|
||||
// the old activity would have a TRANSIT_TASK_TO_BACK transition that needs to be
|
||||
|
||||
@@ -182,6 +182,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
@@ -211,6 +212,7 @@ import android.view.SurfaceControl;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManager.TransitionOldType;
|
||||
import android.window.ITaskOrganizer;
|
||||
import android.window.PictureInPictureSurfaceTransaction;
|
||||
import android.window.StartingWindowInfo;
|
||||
import android.window.TaskSnapshot;
|
||||
import android.window.WindowContainerToken;
|
||||
@@ -470,14 +472,14 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
int mMinWidth;
|
||||
int mMinHeight;
|
||||
|
||||
// The bounds of the target when recents animation is finished.
|
||||
// The surface transition of the target when recents animation is finished.
|
||||
// This is originally introduced to carry out the current surface control position and window
|
||||
// crop when a multi-activity task enters pip with autoEnterPip enabled. In such case,
|
||||
// the surface control of the task will be animated in Launcher and then the top activity is
|
||||
// reparented to pinned root task.
|
||||
// Do not forget to reset this to null after reparenting.
|
||||
// Do not forget to reset this after reparenting.
|
||||
// TODO: remove this once the recents animation is moved to the Shell
|
||||
final Rect mLastRecentsAnimationBounds = new Rect();
|
||||
PictureInPictureSurfaceTransaction mLastRecentsAnimationTransaction;
|
||||
|
||||
static final int LAYER_RANK_INVISIBLE = -1;
|
||||
// Ranking (from top) of this task among all visible tasks. (-1 means it's not visible)
|
||||
@@ -7665,14 +7667,22 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
reparent(newParent, onTop ? POSITION_TOP : POSITION_BOTTOM);
|
||||
}
|
||||
|
||||
void maybeApplyLastRecentsAnimationBounds() {
|
||||
if (!mLastRecentsAnimationBounds.isEmpty()) {
|
||||
getPendingTransaction()
|
||||
.setPosition(mSurfaceControl, mLastRecentsAnimationBounds.left,
|
||||
mLastRecentsAnimationBounds.top)
|
||||
.setWindowCrop(mSurfaceControl, mLastRecentsAnimationBounds.width(),
|
||||
mLastRecentsAnimationBounds.height());
|
||||
mLastRecentsAnimationBounds.setEmpty();
|
||||
void setLastRecentsAnimationTransaction(
|
||||
@NonNull PictureInPictureSurfaceTransaction transaction) {
|
||||
mLastRecentsAnimationTransaction = new PictureInPictureSurfaceTransaction(transaction);
|
||||
}
|
||||
|
||||
void clearLastRecentsAnimationTransaction() {
|
||||
mLastRecentsAnimationTransaction = null;
|
||||
// reset also the transform introduced by mLastRecentsAnimationTransaction
|
||||
getPendingTransaction().setMatrix(mSurfaceControl, Matrix.IDENTITY_MATRIX, new float[9]);
|
||||
}
|
||||
|
||||
void maybeApplyLastRecentsAnimationTransaction() {
|
||||
if (mLastRecentsAnimationTransaction != null) {
|
||||
PictureInPictureSurfaceTransaction.apply(mLastRecentsAnimationTransaction,
|
||||
mSurfaceControl, getPendingTransaction());
|
||||
mLastRecentsAnimationTransaction = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user