am 98534dc0: Add missing null checks for getOwnerInstance()

* commit '98534dc065a828525129dc23aaca3ebd8834514c':
  Add missing null checks for getOwnerInstance()
main
Ken Wakasa 2014-02-27 23:59:59 -08:00 committed by Android Git Automerger
commit 966c913b41
1 changed files with 33 additions and 11 deletions

View File

@ -172,7 +172,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
public void onCreate() { public void onCreate() {
final Resources res = getOwnerInstance().getResources(); final LatinIME latinIme = getOwnerInstance();
if (latinIme == null) {
return;
}
final Resources res = latinIme.getResources();
mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions); mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state); mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state);
mDoubleSpacePeriodTimeout = mDoubleSpacePeriodTimeout =
@ -182,6 +186,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override @Override
public void handleMessage(final Message msg) { public void handleMessage(final Message msg) {
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme == null) {
return;
}
final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher; final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher;
switch (msg.what) { switch (msg.what) {
case MSG_UPDATE_SUGGESTION_STRIP: case MSG_UPDATE_SUGGESTION_STRIP:
@ -239,7 +246,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
public void postResumeSuggestions() { public void postResumeSuggestions() {
if (!getOwnerInstance().mSettings.getCurrent().isSuggestionStripVisible()) { final LatinIME latinIme = getOwnerInstance();
if (latinIme == null) {
return;
}
if (!latinIme.mSettings.getCurrent().isSuggestionStripVisible()) {
return; return;
} }
removeMessages(MSG_RESUME_SUGGESTIONS); removeMessages(MSG_RESUME_SUGGESTIONS);
@ -326,6 +337,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
resetPendingImsCallback(); resetPendingImsCallback();
mIsOrientationChanging = true; mIsOrientationChanging = true;
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme == null) {
return;
}
if (latinIme.isInputViewShown()) { if (latinIme.isInputViewShown()) {
latinIme.mKeyboardSwitcher.saveKeyboardState(); latinIme.mKeyboardSwitcher.saveKeyboardState();
} }
@ -362,10 +376,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mPendingSuccessiveImsCallback = true; mPendingSuccessiveImsCallback = true;
} }
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme != null) {
executePendingImsCallback(latinIme, editorInfo, restarting); executePendingImsCallback(latinIme, editorInfo, restarting);
latinIme.onStartInputInternal(editorInfo, restarting); latinIme.onStartInputInternal(editorInfo, restarting);
} }
} }
}
public void onStartInputView(final EditorInfo editorInfo, final boolean restarting) { public void onStartInputView(final EditorInfo editorInfo, final boolean restarting) {
if (hasMessages(MSG_PENDING_IMS_CALLBACK) if (hasMessages(MSG_PENDING_IMS_CALLBACK)
@ -381,11 +397,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
PENDING_IMS_CALLBACK_DURATION); PENDING_IMS_CALLBACK_DURATION);
} }
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme != null) {
executePendingImsCallback(latinIme, editorInfo, restarting); executePendingImsCallback(latinIme, editorInfo, restarting);
latinIme.onStartInputViewInternal(editorInfo, restarting); latinIme.onStartInputViewInternal(editorInfo, restarting);
mAppliedEditorInfo = editorInfo; mAppliedEditorInfo = editorInfo;
} }
} }
}
public void onFinishInputView(final boolean finishingInput) { public void onFinishInputView(final boolean finishingInput) {
if (hasMessages(MSG_PENDING_IMS_CALLBACK)) { if (hasMessages(MSG_PENDING_IMS_CALLBACK)) {
@ -393,10 +411,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHasPendingFinishInputView = true; mHasPendingFinishInputView = true;
} else { } else {
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme != null) {
latinIme.onFinishInputViewInternal(finishingInput); latinIme.onFinishInputViewInternal(finishingInput);
mAppliedEditorInfo = null; mAppliedEditorInfo = null;
} }
} }
}
public void onFinishInput() { public void onFinishInput() {
if (hasMessages(MSG_PENDING_IMS_CALLBACK)) { if (hasMessages(MSG_PENDING_IMS_CALLBACK)) {
@ -404,11 +424,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHasPendingFinishInput = true; mHasPendingFinishInput = true;
} else { } else {
final LatinIME latinIme = getOwnerInstance(); final LatinIME latinIme = getOwnerInstance();
if (latinIme != null) {
executePendingImsCallback(latinIme, null, false); executePendingImsCallback(latinIme, null, false);
latinIme.onFinishInputInternal(); latinIme.onFinishInputInternal();
} }
} }
} }
}
static final class SubtypeState { static final class SubtypeState {
private InputMethodSubtype mLastActiveSubtype; private InputMethodSubtype mLastActiveSubtype;