Revert "Don't remove starting window for visible app."

This reverts commit 2c596d57535a1d8c327457931dfc835608b677a4.

Reason: Causes starting window leaks

Test: Open 9gag, click home immediately again
Test: go/wm-smoke
Change-Id: I136cbcf66b680c782ab0e039c383e8d189a0b6e3
Fixes: 64154208
Bug: 62443388
diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java
index 4a04af5..e9696d2 100644
--- a/services/core/java/com/android/server/wm/AppWindowContainerController.java
+++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java
@@ -611,23 +611,7 @@
         return mContainer.getTask().getConfiguration().orientation == snapshot.getOrientation();
     }
 
-    /**
-     * Remove starting window if the app is currently hidden. It is possible the starting window is
-     * part of its app exit transition animation in which case we delay hiding the app token. The
-     * method allows for removal when window manager has set the app token to hidden.
-     */
-    public void removeHiddenStartingWindow() {
-        synchronized (mWindowMap) {
-            if (!mContainer.hidden) {
-                if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Starting window app still visible."
-                        + " Ignoring remove request.");
-                return;
-            }
-            removeStartingWindow();
-        }
-    }
-
-    void removeStartingWindow() {
+    public void removeStartingWindow() {
         synchronized (mWindowMap) {
             if (mContainer.startingWindow == null) {
                 if (mContainer.startingData != null) {
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index c4ff455..43ba094 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -448,7 +448,6 @@
                     mChildren.get(i).mWinAnimator.hide("immediately hidden");
                 }
                 SurfaceControl.closeTransaction();
-                removeStartingWindow();
             }
 
             if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) {
@@ -526,12 +525,6 @@
         return super.checkCompleteDeferredRemoval();
     }
 
-    private void removeStartingWindow() {
-        if (startingData != null && getController() != null) {
-            getController().removeStartingWindow();
-        }
-    }
-
     void onRemovedFromDisplay() {
         if (mRemovingFromDisplay) {
             return;
@@ -559,7 +552,9 @@
         if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, "removeAppToken: "
                 + this + " delayed=" + delayed + " Callers=" + Debug.getCallers(4));
 
-        removeStartingWindow();
+        if (startingData != null && getController() != null) {
+            getController().removeStartingWindow();
+        }
 
         // If this window was animating, then we need to ensure that the app transition notifies
         // that animations have completed in WMS.handleAnimatingStoppedAndTransitionLocked(), so