Transfer IME target right away if old target was home

In most cases we want to let the old window be the IME target until it's
finished closing. That is to prevent flicker when switching between
windows that both show the IME. However, when home is the old IME target,
we want to immediately change the target to the new window since the
app is opening.

Test: Open app from home that opens IME when launched
Fixes: 159846344
Change-Id: Ib826b53415b1b1affde76e609d999e1b6f2d2b79
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 5e36880..4ce7202 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -3422,9 +3422,10 @@
                 "Proposed new IME target: " + target + " for display: " + getDisplayId());
 
         // Now, a special case -- if the last target's window is in the process of exiting, but
-        // not removed, keep on the last target to avoid IME flicker.
+        // not removed, keep on the last target to avoid IME flicker. The exception is if the
+        // current target is home since we want opening apps to become the IME target right away.
         if (curTarget != null && !curTarget.mRemoved && curTarget.isDisplayedLw()
-                && curTarget.isClosing()) {
+                && curTarget.isClosing() && !curTarget.isActivityTypeHome()) {
             if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, "Not changing target till current window is"
                     + " closing and not removed");
             return curTarget;