diff options
| author | Craig Mautner <cmautner@google.com> | 2013-03-15 11:38:44 -0700 |
|---|---|---|
| committer | Craig Mautner <cmautner@google.com> | 2013-03-15 11:38:44 -0700 |
| commit | e4bbb1cc451c7ebdad9f92968732fc4f6c21a70c (patch) | |
| tree | 16173d2d812b1ff818d008739ce3f411f603839d /core/java/android/inputmethodservice/InputMethodService.java | |
| parent | b38258f357a7857ce5d53caad0af9c38053ab071 (diff) | |
Catch BadTokenException and continue.
BadTokenException is a normal consequence of swapping IMEs while there
is a DO_SHOW_SOFT_INPUT message in the IIMethodWrapper queue. This
race condition cannot be avoided without an unacceptable lock down of
InputMethodManagerService.
Fixes bug 8387663.
Fixes bug 8263462.
Change-Id: I2c21573cf972145ab08e66604cdb9344139a3f31
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 288cefff55df..5a9cde170b70 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -39,7 +39,6 @@ import android.text.method.MovementMethod; import android.util.Log; import android.util.PrintWriterPrinter; import android.util.Printer; -import android.util.Slog; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -49,6 +48,7 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowManager; +import android.view.WindowManager.BadTokenException; import android.view.animation.AnimationUtils; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; @@ -352,7 +352,6 @@ public class InputMethodService extends AbstractInputMethodService { * Take care of attaching the given window token provided by the system. */ public void attachToken(IBinder token) { - Slog.i(TAG, "attachToken: Existing token=" + mToken + " new token=" + token); if (mToken == null) { mToken = token; mWindow.setToken(token); @@ -419,11 +418,16 @@ public class InputMethodService extends AbstractInputMethodService { * Handle a request by the system to show the soft input area. */ public void showSoftInput(int flags, ResultReceiver resultReceiver) { - if (true || DEBUG) Slog.v(TAG, "showSoftInput()"); + if (DEBUG) Log.v(TAG, "showSoftInput()"); boolean wasVis = isInputViewShown(); mShowInputFlags = 0; if (onShowInputRequested(flags, false)) { - showWindow(true); + try { + showWindow(true); + } catch (BadTokenException e) { + if (DEBUG) Log.v(TAG, "BadTokenException: IME is done."); + mWindowVisible = false; + } } // If user uses hard keyboard, IME button should always be shown. boolean showing = onEvaluateInputViewShown(); @@ -1390,7 +1394,7 @@ public class InputMethodService extends AbstractInputMethodService { } public void showWindow(boolean showInput) { - if (true || DEBUG) Slog.v(TAG, "Showing window: showInput=" + showInput + if (DEBUG) Log.v(TAG, "Showing window: showInput=" + showInput + " mShowInputRequested=" + mShowInputRequested + " mWindowAdded=" + mWindowAdded + " mWindowCreated=" + mWindowCreated |
