From 0b52ed02dfc8c61e1a999d9c236f64503f7919d1 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 29 May 2015 11:07:02 -0700 Subject: [PATCH] Revert "Rely on IMM#focusOut() to close input session." This reverts commit 41bb4953dad33b56b6d039d5bc87a574a0b70fe9. Ib1b037594ebbb4ad4cf2d59e21c7a8ca9d8dc930 caused Bug 21508503. Since it looks like a timing issue, many other applications could be affected potentially. Bug 21508503 implies that re-enabling IMM#focusOut() globally requires much more work than we thought. Probably the memory leak found in Bug 20820914 should be addressed in a more conservative way at the moment, e.g., by plumbing events from ViewGroup to IMMS. Bug: 21508503 Bug: 20820914 Change-Id: I2228ae0c48ad3d9e0b55875f0dcb5ef8c55b0c5f --- .../view/inputmethod/InputMethodManager.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 3f7bad626c813..f61e372c26b06 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1306,12 +1306,16 @@ public final class InputMethodManager { if (DEBUG) Log.v(TAG, "focusOut: " + view + " mServedView=" + mServedView + " winFocus=" + view.hasWindowFocus()); - // CAVEAT: We have ignored focusOut event in Android L MR-1 and prior. Need special - // care when changing the logic here because there are so many cases to be taken into - // consideration, e.g., WindowManager.LayoutParams.SOFT_INPUT_* flags. - if (mServedView == view && view.hasWindowFocus()) { - mNextServedView = null; - scheduleCheckFocusLocked(view); + if (mServedView != view) { + // The following code would auto-hide the IME if we end up + // with no more views with focus. This can happen, however, + // whenever we go into touch mode, so it ends up hiding + // at times when we don't really want it to. For now it + // seems better to just turn it all off. + if (false && view.hasWindowFocus()) { + mNextServedView = null; + scheduleCheckFocusLocked(view); + } } } }