Merge "Make IMM more robust to spurious window focus-in" into nyc-dev am: 50c33d1ca1

am: ef68474698

* commit 'ef684746980061bb5950ae2505229648d9f146d6':
  Make IMM more robust to spurious window focus-in

Change-Id: I77ae5953aa9afc64ef1cd3252d6d2ff936890b62
This commit is contained in:
Yohei Yukawa
2016-05-25 05:02:09 +00:00
committed by android-build-merger

View File

@@ -1277,6 +1277,28 @@ public final class InputMethodManager {
return true;
}
}
} else {
if (startInputReason
== InputMethodClient.START_INPUT_REASON_WINDOW_FOCUS_GAIN) {
// We are here probably because of an obsolete window-focus-in message sent
// to windowGainingFocus. Since IMMS determines whether a Window can have
// IME focus or not by using the latest window focus state maintained in the
// WMS, this kind of race condition cannot be avoided. One obvious example
// would be that we have already received a window-focus-out message but the
// UI thread is still handling previous window-focus-in message here.
// TODO: InputBindResult should have the error code.
if (DEBUG) Log.w(TAG, "startInputOrWindowGainedFocus failed. "
+ "Window focus may have already been lost. "
+ "win=" + windowGainingFocus + " view=" + dumpViewInfo(view));
if (!mActive) {
// mHasBeenInactive is a latch switch to forcefully refresh IME focus
// state when an inactive (mActive == false) client is gaining window
// focus. In case we have unnecessary disable the latch due to this
// spurious wakeup, we re-enable the latch here.
// TODO: Come up with more robust solution.
mHasBeenInactive = true;
}
}
}
if (mCurMethod != null && mCompletions != null) {
try {