diff options
| author | 2023-06-08 11:29:04 -0700 | |
|---|---|---|
| committer | 2023-06-08 13:40:20 -0700 | |
| commit | a45bcc33f454a61a722f464f36f886e6572cbc1a (patch) | |
| tree | 2dd64839cd70a8d02f2ab0a6315dd4ce2e6c332c | |
| parent | cec1c35e34810212382f277319849af33ad5ff6c (diff) | |
Preserve the leash reference in PipTaskOrganizer
Make sure to not lose the reference to updated leash
upon user manually entering PiP with another PiP window
present.
Also remove the leash of the previous PiP window.
This will also avoid calling onExitPipFinished() twice,
since it is already being called through onTaskVanished()
in the case of overriding an existing PiP.
Bug: 285231679
Test: manually reproduce the steps in the bug
Change-Id: I581759a5ae121779e7151007be133f0f5c6f9ee5
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java index dc0a2943d394..7b8e4778ec98 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java @@ -1014,24 +1014,17 @@ public class PipTransition extends PipTransitionController { private void resetPrevPip(@NonNull TransitionInfo.Change prevPipTaskChange, @NonNull SurfaceControl.Transaction startTransaction) { final SurfaceControl leash = prevPipTaskChange.getLeash(); - final Rect bounds = prevPipTaskChange.getEndAbsBounds(); - final Point offset = prevPipTaskChange.getEndRelOffset(); - bounds.offset(-offset.x, -offset.y); - - startTransaction.setWindowCrop(leash, null); - startTransaction.setMatrix(leash, 1, 0, 0, 1); - startTransaction.setCornerRadius(leash, 0); - startTransaction.setPosition(leash, bounds.left, bounds.top); - - if (mHasFadeOut && prevPipTaskChange.getTaskInfo().isVisible()) { - if (mPipAnimationController.getCurrentAnimator() != null) { - mPipAnimationController.getCurrentAnimator().cancel(); - } - startTransaction.setAlpha(leash, 1); - } + startTransaction.remove(leash); + mHasFadeOut = false; mCurrentPipTaskToken = null; - mPipOrganizer.onExitPipFinished(prevPipTaskChange.getTaskInfo()); + + // clean-up the state in PipTaskOrganizer if the PipTaskOrganizer#onTaskAppeared() hasn't + // been called yet with its leash reference now pointing to a new SurfaceControl not + // matching the leash of the pip we are removing. + if (mPipOrganizer.getSurfaceControl() == leash) { + mPipOrganizer.onExitPipFinished(prevPipTaskChange.getTaskInfo()); + } } @Override |