Fix issue #6499411: Characters not displayed (but suggestion bar is working)

The problem was that when dismissing the lock screen, the window manager
would briefly turn off force hiding when it started animating the transition
and then turn it back on until the transition was done.

This would cause it to briefly switch focus to the app behind and then
take focus off it.  The app would find out it got focus, and re-start
input on itself, asking the input method service to do so.  At this
point the input method service would ask the window manager if the
caller really had focus, and it may or may not be told no depending
on the timing.  If it is told no, then it doesn't allow the focus
switch to happen at that point, ignoring the new input connection,
and ultimately when focus does really switch the IME is left talking
with an old dead input connection.

I added some code to the input connection to make sure when we are
no longer using one that we mark it inactive and can't use it.  This
bug was especially difficult to track down because it would only
visibly break when a GC happened during this time, causing the weak
reference on the input connection to become null.  With this change
it will now always break (though in the scenario here only if you
hit the race condition correctly).

Change-Id: I81a6164dc140c548da1a9736e42cd253e8238a80
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index ff14568..b979057 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1667,7 +1667,8 @@
                 }
 
                 if (mCurFocusedWindow == windowToken) {
-                    Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client);
+                    Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
+                            + " attribute=" + attribute);
                     if (attribute != null) {
                         return startInputUncheckedLocked(cs, inputContext, attribute,
                                 controlFlags);