Fix IMMS#mInputShown state inconsistency.

The goal of this CL is to keep IMMS#mInputShown consistent with the
actual visibility of the software keyboard.  Doing it indeed fixes many
user-visible inconsistency, especially when a physical keyboards is
attached.

It turned out that there are much more cases where IMMS#mInputShown
should have been updated.  Basically every time when the software
keyboard is shown or hiden by non-user actions, IMMS#mInputShown was not
updated to the new state.  Typical cases are:
 - the IME shows its Emoji keyboard when the ALT key is pressed.
 - the system hides software keyboard when physical keyboard is
   connected.

With this CL, all known issues will disapper by updating
IMMS#mInputShown in IMMS#setImeWindowStatus().

Note that this CL depends on following preparation CLs directly or
indirectly.
- I7002ff063e490928309e9a9a0f6557ce3d12e6aa
- I1e50ee42838a1bf64a612da4904aa93458d44ea4
- I3decaf37198e5864a1763a059df4a36ebc70c5a7
- Id156c85535a221235737ea6dcc15a67f1c4b9f71
- I9f797d07ba02363fab58ceb9aecb3cc11fbc407e
- I60963f1474457ff37cca85e262460dca8105acff

Simply cherry-picking this CL into L branch is supposed to be
insufficient to fix all the issues and would result in different
regressions indeed.

BUG: 18722991
BUG: 20763994
BUG: 20764441
BUG: 20926844
Change-Id: I20ae2749a93bc33840df560aa71d4635e9ec849a
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 9511f54..e856a93 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -1695,6 +1695,7 @@
                     vis = 0;
                 }
                 mImeWindowVis = vis;
+                mInputShown = ((mImeWindowVis & InputMethodService.IME_VISIBLE) != 0);
                 mBackDisposition = backDisposition;
                 final boolean iconVisibility = ((vis & (InputMethodService.IME_ACTIVE)) != 0)
                         && (mWindowManagerService.isHardKeyboardAvailable()