From b464667b771b1d976359e7cd8b83f52d6245774c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Tue, 24 May 2022 01:33:59 +0000 Subject: [PATCH] Reset original task surface after reparenting to PiP Currently if the shell transitions are disabled (default), the auto-enter pip will trigger an animation via Recents, animating the original task surface and populating the mLastRecentsAnimationTransaction. As we reparent that activity into the pip window, we also reset the state of the original task surface in clearLastRecentsAnimationTransaction. When shell transitions are enabled, the auto-enter pip does not animate via the same mechanism and the mLastRecentsAnimationTransaction is null. We still animate the original task surface but nothing resets it after the activity is being reparented. This CL fixes that second scenario by applying a reset transform to the original task surface even if there was no recents animation transaction. Bug: 232981505 Test: manual, open ApiDemos, autoenter pip, return to full screen via pip menu Change-Id: Ibc42c1277e045bf5042678340b9d68428cb2e626 --- .../java/com/android/server/wm/RootWindowContainer.java | 3 +++ services/core/java/com/android/server/wm/Task.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 9b44960d3e4c1..3d0639978e634 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -2048,6 +2048,9 @@ class RootWindowContainer extends WindowContainer task.mLastRecentsAnimationTransaction, task.mLastRecentsAnimationOverlay); task.clearLastRecentsAnimationTransaction(false /* forceRemoveOverlay */); + } else { + // Reset the original task surface + task.resetSurfaceControlTransforms(); } // The organized TaskFragment is becoming empty because this activity is reparented diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 6b3981a0c1cc6..f6fdcfecd0a7d 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5985,8 +5985,13 @@ class Task extends TaskFragment { mLastRecentsAnimationTransaction = null; mLastRecentsAnimationOverlay = null; // reset also the crop and transform introduced by mLastRecentsAnimationTransaction - getPendingTransaction().setMatrix(mSurfaceControl, Matrix.IDENTITY_MATRIX, new float[9]) + resetSurfaceControlTransforms(); + } + + void resetSurfaceControlTransforms() { + getSyncTransaction().setMatrix(mSurfaceControl, Matrix.IDENTITY_MATRIX, new float[9]) .setWindowCrop(mSurfaceControl, null) + .setShadowRadius(mSurfaceControl, 0) .setCornerRadius(mSurfaceControl, 0); }