summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/inputmethod
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2015-05-12 01:43:27 -0700
committerYohei Yukawa <yukawa@google.com>2015-05-12 01:43:27 -0700
commit97c381304207013fd95c7806df4dcca0c69006c0 (patch)
tree980183a3d3192b8e34f2ae607a3b3203955d4616 /core/java/android/view/inputmethod
parente1a1d2e85a3f0626ae13322998fd45a1eb4a49d7 (diff)
downloadframeworks_base-97c381304207013fd95c7806df4dcca0c69006c0.zip
frameworks_base-97c381304207013fd95c7806df4dcca0c69006c0.tar.gz
frameworks_base-97c381304207013fd95c7806df4dcca0c69006c0.tar.bz2
Update IME focus when the active view is losing the focus.
Despite the fact that IMM#focusOut() are called from many focus mangement logics, the reality is that IMM#focusOut() has done nothing more than 6 years. This would not a big problem as long as IMM#focusIn() is called immediately after IMM#focusOut(). However, situations where only IMM#focusOut() is called, following fields continue keeping object references. - IMM#mServedView - IMM#mNextServedView - IMM#mServedInputConnection - IMM#mServedInputConnectionWrapper Even worse, if the IME is showing software keyboard, it will not be dismissed. With this CL, IMM#focusOut() starts cleaning up the active IME session when the associated view loses focus. This CL also removes IMM#mCurRootView because it is indeed necessary for above change. The problem when only introducing above change can be understood as follows. 1. IMM#mCurRootView is correctly set from ViewRootImpl. 2. IMM#focusIn() is called. InputConnection is established. 3. IMM#focusOut() is called, which triggers IMM#finishInputLocked() because of above change, which internally clears IMM#mCurRootView. 4. IMM#focusIn() is called but IMM#mCurRootView is still null. Because of this the focus-in event is ignored and the software keyboard does not show up anymore. In this CL, we simply check view.hasWindowFocus() instead. As far as I've tested, this change looks to be working well. Bug: 20820914 Change-Id: Ib4bd70ce0305a6bde6a929bcc6ad20a2b8402a97
Diffstat (limited to 'core/java/android/view/inputmethod')
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java36
1 files changed, 7 insertions, 29 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 040fd37..fc2b42a 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -281,12 +281,7 @@ public final class InputMethodManager {
boolean mFullscreenMode;
// -----------------------------------------------------------
-
- /**
- * This is the root view of the overall window that currently has input
- * method focus.
- */
- View mCurRootView;
+
/**
* This is the view that should currently be served by an input method,
* regardless of the state of setting that up.
@@ -816,7 +811,6 @@ public final class InputMethodManager {
* Disconnect any existing input connection, clearing the served view.
*/
void finishInputLocked() {
- mCurRootView = null;
mNextServedView = null;
if (mServedView != null) {
if (DEBUG) Log.v(TAG, "FINISH INPUT: " + mServedView);
@@ -1300,10 +1294,9 @@ public final class InputMethodManager {
void focusInLocked(View view) {
if (DEBUG) Log.v(TAG, "focusIn: " + view);
- if (mCurRootView != view.getRootView()) {
- // This is a request from a window that isn't in the window with
- // IME focus, so ignore it.
- if (DEBUG) Log.v(TAG, "Not IME target window, ignoring");
+ if (!view.hasWindowFocus()) {
+ // This is a request from a window that doesn't have window focus, so ignore it.
+ if (DEBUG) Log.v(TAG, "Not focused window, ignoring");
return;
}
@@ -1320,16 +1313,9 @@ public final class InputMethodManager {
if (DEBUG) Log.v(TAG, "focusOut: " + view
+ " mServedView=" + mServedView
+ " winFocus=" + view.hasWindowFocus());
- 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);
- }
+ if (mServedView == view && view.hasWindowFocus()) {
+ mNextServedView = null;
+ scheduleCheckFocusLocked(view);
}
}
}
@@ -1452,13 +1438,6 @@ public final class InputMethodManager {
}
}
- /** @hide */
- public void startGettingWindowFocus(View rootView) {
- synchronized (mH) {
- mCurRootView = rootView;
- }
- }
-
/**
* Report the current selection range.
*
@@ -2166,7 +2145,6 @@ public final class InputMethodManager {
+ " mBindSequence=" + mBindSequence
+ " mCurId=" + mCurId);
p.println(" mCurMethod=" + mCurMethod);
- p.println(" mCurRootView=" + mCurRootView);
p.println(" mServedView=" + mServedView);
p.println(" mNextServedView=" + mNextServedView);
p.println(" mServedConnecting=" + mServedConnecting);