Skip the exit animation when the IME is destroyed.

Bug: 4529563

Change-Id: I6fb2ea3601e1cc6fa8858d006819698dcabdd5ca
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 7d3cd92..af591d3 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -687,6 +687,10 @@
         mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener(
                 mInsetsComputer);
         if (mWindowAdded) {
+            // Disable exit animation for the current IME window
+            // to avoid the race condition between the exit and enter animations
+            // when the current IME is being switched to another one.
+            mWindow.getWindow().setWindowAnimations(0);
             mWindow.dismiss();
         }
     }