Merge "Fix an NPE"
commit
d9f0c1e020
|
@ -155,7 +155,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private SuggestionStripView mSuggestionStripView;
|
private SuggestionStripView mSuggestionStripView;
|
||||||
// Never null
|
// Never null
|
||||||
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
|
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
|
||||||
@UsedForTesting Suggest mSuggest;
|
private Suggest mSuggest;
|
||||||
private CompletionInfo[] mApplicationSpecifiedCompletions;
|
private CompletionInfo[] mApplicationSpecifiedCompletions;
|
||||||
private AppWorkaroundsUtils mAppWorkAroundsUtils = new AppWorkaroundsUtils();
|
private AppWorkaroundsUtils mAppWorkAroundsUtils = new AppWorkaroundsUtils();
|
||||||
|
|
||||||
|
@ -2243,7 +2243,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
private SuggestedWords getSuggestedWords(final int sessionId) {
|
private SuggestedWords getSuggestedWords(final int sessionId) {
|
||||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
if (keyboard == null || mSuggest == null) {
|
final Suggest suggest = mSuggest;
|
||||||
|
if (keyboard == null || suggest == null) {
|
||||||
return SuggestedWords.EMPTY;
|
return SuggestedWords.EMPTY;
|
||||||
}
|
}
|
||||||
// Get the word on which we should search the bigrams. If we are composing a word, it's
|
// 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 =
|
final String prevWord =
|
||||||
mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators,
|
mConnection.getNthPreviousWord(mSettings.getCurrent().mWordSeparators,
|
||||||
mWordComposer.isComposingWord() ? 2 : 1);
|
mWordComposer.isComposingWord() ? 2 : 1);
|
||||||
return mSuggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(),
|
return suggest.getSuggestedWords(mWordComposer, prevWord, keyboard.getProximityInfo(),
|
||||||
mSettings.getBlockPotentiallyOffensive(),
|
mSettings.getBlockPotentiallyOffensive(),
|
||||||
mSettings.getCurrent().mCorrectionEnabled, sessionId);
|
mSettings.getCurrent().mCorrectionEnabled, sessionId);
|
||||||
}
|
}
|
||||||
|
@ -2857,6 +2858,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return mSuggestedWords.size() > 0 ? mSuggestedWords.getWord(0) : null;
|
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) {
|
public void debugDumpStateAndCrashWithException(final String context) {
|
||||||
final StringBuilder s = new StringBuilder(mAppWorkAroundsUtils.toString());
|
final StringBuilder s = new StringBuilder(mAppWorkAroundsUtils.toString());
|
||||||
s.append("\nAttributes : ").append(mSettings.getCurrent().mInputAttributes)
|
s.append("\nAttributes : ").append(mSettings.getCurrent().mInputAttributes)
|
||||||
|
|
|
@ -225,7 +225,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
|
||||||
|
|
||||||
protected void waitForDictionaryToBeLoaded() {
|
protected void waitForDictionaryToBeLoaded() {
|
||||||
int remainingAttempts = 300;
|
int remainingAttempts = 300;
|
||||||
while (remainingAttempts > 0 && mLatinIME.mSuggest.isCurrentlyWaitingForMainDictionary()) {
|
while (remainingAttempts > 0 && mLatinIME.isCurrentlyWaitingForMainDictionary()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -234,7 +234,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
|
||||||
--remainingAttempts;
|
--remainingAttempts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mLatinIME.mSuggest.hasMainDictionary()) {
|
if (!mLatinIME.hasMainDictionary()) {
|
||||||
throw new RuntimeException("Can't initialize the main dictionary");
|
throw new RuntimeException("Can't initialize the main dictionary");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue