Keep fixed rotation transformed surface position for animation leash

The orientation of the target window can be different than who controls
the leash. In order to let the animator use the leash without additional
transformation, the current position of surface needs to be preserved.

Also fix a flaky test due to the display was frozen.

Fixes: 153561756
Fixes: 154030098
Test: atest DisplayContentTests#testApplyTopFixedRotationTransform
      ActivityRecordTests#testActivityOnCancelFixedRotationTransform
Change-Id: I4b75e830b4d63143c6825f0fa5ccbf333b2ba6ff
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 7219164..77530fb 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -2304,14 +2304,18 @@
         }
     }
 
+    void resetSurfacePositionForAnimationLeash(Transaction t) {
+        t.setPosition(mSurfaceControl, 0, 0);
+        mLastSurfacePosition.set(0, 0);
+    }
+
     @Override
     public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) {
         mLastLayer = -1;
         reassignLayer(t);
 
         // Leash is now responsible for position, so set our position to 0.
-        t.setPosition(mSurfaceControl, 0, 0);
-        mLastSurfacePosition.set(0, 0);
+        resetSurfacePositionForAnimationLeash(t);
     }
 
     @Override