Avoid potential recursion of surface placement

WindowSurfacePlacer#mInLayout can guard the case of calling
RootWindowContainer#performSurfacePlacement recursively.
But it requires the caller to use WindowSurfacePlacer instead
of the inner method.

Bug: 234840614
Bug: 237481770
Test: CtsWindowManagerDeviceTestCases
Change-Id: Ie87646da2848cc988e3ea51644e86e2a88c2fd3a
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index db730e0..e498708 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -779,6 +779,10 @@
         return leakedSurface || killedApps;
     }
 
+    /**
+     * This method should only be called from {@link WindowSurfacePlacer}. Otherwise the recursion
+     * check and {@link WindowSurfacePlacer#isInLayout()} won't take effect.
+     */
     void performSurfacePlacement() {
         Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "performSurfacePlacement");
         try {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index d31dfee..1f81cf3 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5611,7 +5611,7 @@
                             mWindowsInsetsChanged = 0;
                             // We need to update resizing windows and dispatch the new insets state
                             // to them.
-                            mRoot.performSurfacePlacement();
+                            mWindowPlacerLocked.performSurfacePlacement();
                         }
                     }
                     break;