Close IME when attaching dock stack

So we don't end up with animation weirdness.

Bug: 28905720
Change-Id: I04124995dd99fa26d2e9be467c5976d7b20810a7
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 727bf5c..5d8fe7c 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -159,6 +159,7 @@
     static final int MSG_BIND_INPUT = 1010;
     static final int MSG_SHOW_SOFT_INPUT = 1020;
     static final int MSG_HIDE_SOFT_INPUT = 1030;
+    static final int MSG_HIDE_CURRENT_INPUT_METHOD = 1035;
     static final int MSG_ATTACH_TOKEN = 1040;
     static final int MSG_CREATE_SESSION = 1050;
 
@@ -2846,6 +2847,11 @@
                 }
                 args.recycle();
                 return true;
+            case MSG_HIDE_CURRENT_INPUT_METHOD:
+                synchronized (mMethodMap) {
+                    hideCurrentInputLocked(0, null);
+                }
+                return true;
             case MSG_ATTACH_TOKEN:
                 args = (SomeArgs)msg.obj;
                 try {
@@ -3880,6 +3886,12 @@
             mHandler.sendMessage(mHandler.obtainMessage(MSG_SWITCH_IME,
                     forwardDirection ? 1 : 0, 0));
         }
+
+        @Override
+        public void hideCurrentInputMethod() {
+            mHandler.removeMessages(MSG_HIDE_CURRENT_INPUT_METHOD);
+            mHandler.sendEmptyMessage(MSG_HIDE_CURRENT_INPUT_METHOD);
+        }
     }
 
     private static String imeWindowStatusToString(final int imeWindowVis) {