Fix unusual NPE after onDestroy

Bug: 11673978
Change-Id: I4d5268312911685ff1ca9483a62442a1a9686c62
This commit is contained in:
Tadashi G. Takaoka 2013-11-15 17:34:45 +09:00 committed by The Android Automerger
parent db86a6f271
commit ea8f8da1ac

View File

@ -725,8 +725,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
LatinImeLogger.commit();
LatinImeLogger.onDestroy();
if (mInputUpdater != null) {
mInputUpdater.onDestroy();
mInputUpdater = null;
mInputUpdater.quitLooper();
}
super.onDestroy();
}
@ -1824,13 +1823,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
}
private static final class InputUpdater implements Handler.Callback {
static final class InputUpdater implements Handler.Callback {
private final Handler mHandler;
private final LatinIME mLatinIme;
private final Object mLock = new Object();
private boolean mInBatchInput; // synchronized using {@link #mLock}.
private InputUpdater(final LatinIME latinIme) {
InputUpdater(final LatinIME latinIme) {
final HandlerThread handlerThread = new HandlerThread(
InputUpdater.class.getSimpleName());
handlerThread.start();
@ -1947,7 +1946,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
.sendToTarget();
}
private void onDestroy() {
void quitLooper() {
mHandler.removeMessages(MSG_GET_SUGGESTED_WORDS);
mHandler.removeMessages(MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
mHandler.getLooper().quit();