Fix stuck exiting windows

When a window was marked as exiting because in WS.removeIfPossible
applyAnimationLocked returned true just because AWT was in
mClosing/OpeningApps for the transition, the window wasn't removed
if there was no animation running for the app transition.

Fix this by also calling the animation finished callback when not
running an animation, because other code parts rely on that being
called.

Test: Change language, swipe up, make sure no stuck window
Test: AppWindowTokenTests
Change-Id: I9cfd0c4090a258bc90ba5cf7d71795b6fce7f8ef
Fixes: 72811863
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index fef615d..1f71b8f 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -450,6 +450,12 @@
 
         if (isReallyAnimating()) {
             delayed = true;
+        } else {
+
+            // We aren't animating anything, but exiting windows rely on the animation finished
+            // callback being called in case the AppWindowToken was pretending to be animating,
+            // which we might have done because we were in closing/opening apps list.
+            onAnimationFinished();
         }
 
         for (int i = mChildren.size() - 1; i >= 0 && !delayed; i--) {
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index fc5e33a..3256762 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -454,7 +454,7 @@
             AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
             if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now opening app" + wtoken);
 
-            if (!wtoken.setVisibility(animLp, true, transit, false, voiceInteraction)){
+            if (!wtoken.setVisibility(animLp, true, transit, false, voiceInteraction)) {
                 // This token isn't going to be animating. Add it to the list of tokens to
                 // be notified of app transition complete since the notification will not be
                 // sent be the app window animator.