diff options
author | 2013-07-29 02:49:06 -0700 | |
---|---|---|
committer | 2013-07-29 02:49:06 -0700 | |
commit | 7755379ebd540e39cc6799a41cf38fda29e857cb (patch) | |
tree | 646c896ba0ef75985ebc5a9aaf875811dc1bbc27 | |
parent | 92faf405e528ca2541b4c2ea9c3c7b2cfb7dd457 (diff) | |
parent | d9f0c1e02065d457dc004fc26054fa75432e6661 (diff) | |
download | latinime-7755379ebd540e39cc6799a41cf38fda29e857cb.tar.gz latinime-7755379ebd540e39cc6799a41cf38fda29e857cb.tar.xz latinime-7755379ebd540e39cc6799a41cf38fda29e857cb.zip |
am d9f0c1e0: Merge "Fix an NPE"
* commit 'd9f0c1e02065d457dc004fc26054fa75432e6661':
Fix an NPE
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 19 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputTestsBase.java | 4 |
2 files changed, 18 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b28406bad..fe27ebfb5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -155,7 +155,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private SuggestionStripView mSuggestionStripView; // Never null private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; - @UsedForTesting Suggest mSuggest; + private Suggest mSuggest; private CompletionInfo[] mApplicationSpecifiedCompletions; private AppWorkaroundsUtils mAppWorkAroundsUtils = new AppWorkaroundsUtils(); @@ -2243,7 +2243,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private SuggestedWords getSuggestedWords(final int sessionId) { final Keyboard keyboard = mKeyboardSwitcher.getKeyboard(); - if (keyboard == null || mSuggest == null) { + final Suggest suggest = mSuggest; + if (keyboard == null || suggest == null) { return SuggestedWords.EMPTY; } // Get the word on which we should search the bigrams. If we are composing a word, it's @@ -2253,7 +2254,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final String prevWord = mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators, mWordComposer.isComposingWord() ? 2 : 1); - return mSuggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(), + return suggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(), mSettings.getBlockPotentiallyOffensive(), mSettings.getCurrent().mCorrectionEnabled, sessionId); } @@ -2857,6 +2858,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return mSuggestedWords.size() > 0 ? mSuggestedWords.getWord(0) : null; } + // DO NOT USE THIS for any other purpose than testing. This is information private to LatinIME. + @UsedForTesting + /* package for test */ boolean isCurrentlyWaitingForMainDictionary() { + return mSuggest.isCurrentlyWaitingForMainDictionary(); + } + + // DO NOT USE THIS for any other purpose than testing. This is information private to LatinIME. + @UsedForTesting + /* package for test */ boolean hasMainDictionary() { + return mSuggest.hasMainDictionary(); + } + public void debugDumpStateAndCrashWithException(final String context) { final StringBuilder s = new StringBuilder(mAppWorkAroundsUtils.toString()); s.append("\nAttributes : ").append(mSettings.getCurrent().mInputAttributes) diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index d1ce104b4..eb4f706cc 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -225,7 +225,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected void waitForDictionaryToBeLoaded() { int remainingAttempts = 300; - while (remainingAttempts > 0 && mLatinIME.mSuggest.isCurrentlyWaitingForMainDictionary()) { + while (remainingAttempts > 0 && mLatinIME.isCurrentlyWaitingForMainDictionary()) { try { Thread.sleep(200); } catch (InterruptedException e) { @@ -234,7 +234,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { --remainingAttempts; } } - if (!mLatinIME.mSuggest.hasMainDictionary()) { + if (!mLatinIME.hasMainDictionary()) { throw new RuntimeException("Can't initialize the main dictionary"); } } |