Update ime touch exclude region for hosting display

If IME for an application is situated on a different display,
then we need to update corresponding display content's touch
exclude region.

Bug: 36515606
Test: Manual, b/37911363
Change-Id: I43785de6f26adf88e9a76b9144b39f66f232a646
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index d85552a..300f5c5 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1793,7 +1793,13 @@
             // events to be intercepted and used to change focus. This would likely cause a
             // disappearance of the input method.
             inputMethod.getTouchableRegion(mTmpRegion);
-            mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION);
+            if (inputMethod.getDisplayId() == mDisplayId) {
+                mTouchExcludeRegion.op(mTmpRegion, Op.UNION);
+            } else {
+                // IME is on a different display, so we need to update its tap detector.
+                // TODO(multidisplay): Remove when IME will always appear on same display.
+                inputMethod.getDisplayContent().setTouchExcludeRegion(null /* focusedTask */);
+            }
         }
         for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) {
             WindowState win = mTapExcludedWindows.get(i);