Merge "Avoid conflict surface reset on auto-enter-pip" into sc-v2-dev am: fdf6eedb10

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

Change-Id: Ieaaa85134e0f31cc322d63d4974aee8e3596ec6e
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenUnfoldController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenUnfoldController.java
index fc1b704..aa3868c 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenUnfoldController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenUnfoldController.java
@@ -16,6 +16,7 @@
 
 package com.android.wm.shell.fullscreen;
 
+import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
 import static android.util.MathUtils.lerp;
 import static android.view.Display.DEFAULT_DISPLAY;
 
@@ -163,7 +164,10 @@
     public void onTaskVanished(ActivityManager.RunningTaskInfo taskInfo) {
         AnimationContext animationContext = mAnimationContextByTaskId.get(taskInfo.taskId);
         if (animationContext != null) {
-            resetSurface(animationContext);
+            // PiP task has its own cleanup path, ignore surface reset to avoid conflict.
+            if (taskInfo.getWindowingMode() != WINDOWING_MODE_PINNED) {
+                resetSurface(animationContext);
+            }
             mAnimationContextByTaskId.remove(taskInfo.taskId);
         }