diff --git a/core/java/android/view/RemoteAnimationTarget.java b/core/java/android/view/RemoteAnimationTarget.java index 3f71d4d837a1d..046232a8afafe 100644 --- a/core/java/android/view/RemoteAnimationTarget.java +++ b/core/java/android/view/RemoteAnimationTarget.java @@ -208,6 +208,15 @@ public class RemoteAnimationTarget implements Parcelable { */ public final @WindowManager.LayoutParams.WindowType int windowType; + /** + * {@code true} if its parent is also a {@link RemoteAnimationTarget} in the same transition. + * + * For example, when a TaskFragment is resizing while one of its children is open/close, both + * windows will be animation targets. This value will be {@code true} for the child, so that + * the handler can choose to handle it differently. + */ + public boolean hasAnimatingParent; + public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent, Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position, Rect localBounds, Rect screenSpaceBounds, @@ -265,6 +274,7 @@ public class RemoteAnimationTarget implements Parcelable { taskInfo = in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR); allowEnterPip = in.readBoolean(); windowType = in.readInt(); + hasAnimatingParent = in.readBoolean(); } @Override @@ -292,6 +302,7 @@ public class RemoteAnimationTarget implements Parcelable { dest.writeTypedObject(taskInfo, 0 /* flags */); dest.writeBoolean(allowEnterPip); dest.writeInt(windowType); + dest.writeBoolean(hasAnimatingParent); } public void dump(PrintWriter pw, String prefix) { @@ -311,6 +322,7 @@ public class RemoteAnimationTarget implements Parcelable { pw.print(prefix); pw.print("taskInfo="); pw.println(taskInfo); pw.print(prefix); pw.print("allowEnterPip="); pw.println(allowEnterPip); pw.print(prefix); pw.print("windowType="); pw.print(windowType); + pw.print(prefix); pw.print("hasAnimatingParent="); pw.print(hasAnimatingParent); } public void dumpDebug(ProtoOutputStream proto, long fieldId) { diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index a7d28ce1b0530..c45b661f06fbc 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -9265,14 +9265,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A task.getBounds(), Type.systemBars(), false /* ignoreVisibility */).toRect(); InsetUtils.addInsets(insets, getLetterboxInsets()); - return new RemoteAnimationTarget(task.mTaskId, record.getMode(), - record.mAdapter.mCapturedLeash, !fillsParent(), + final RemoteAnimationTarget target = new RemoteAnimationTarget(task.mTaskId, + record.getMode(), record.mAdapter.mCapturedLeash, !fillsParent(), new Rect(), insets, getPrefixOrderIndex(), record.mAdapter.mPosition, record.mAdapter.mLocalBounds, record.mAdapter.mRootTaskBounds, task.getWindowConfiguration(), false /*isNotInRecents*/, record.mThumbnailAdapter != null ? record.mThumbnailAdapter.mCapturedLeash : null, record.mStartBounds, task.getTaskInfo(), checkEnterPictureInPictureAppOpsState()); + target.hasAnimatingParent = record.hasAnimatingParent(); + return target; } @Override diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index 6b57ede1cd262..b90f937ca56ec 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -436,6 +436,19 @@ class RemoteAnimationController implements DeathRecipient { int getMode() { return mMode; } + + /** Whether its parent is also an animation target in the same transition. */ + boolean hasAnimatingParent() { + // mOpeningApps and mClosingApps are only activities, so only need to check + // mChangingContainers. + for (int i = mDisplayContent.mChangingContainers.size() - 1; i >= 0; i--) { + if (mWindowContainer.isDescendantOf( + mDisplayContent.mChangingContainers.valueAt(i))) { + return true; + } + } + return false; + } } class RemoteAnimationAdapterWrapper implements AnimationAdapter {