Merge "Don't kill LatinIME if the spellchecker crashes."

This commit is contained in:
Jean Chalard 2011-09-15 00:13:45 -07:00 committed by Android (Google) Code Review
commit b568a627b4

View file

@ -327,6 +327,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
@Override
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
final int suggestionsLimit) {
try {
final String text = textInfo.getText();
if (shouldFilterOut(text)) return EMPTY_SUGGESTIONS_INFO;
@ -343,7 +344,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
proximities = new int[] { character };
} else {
proximities = Arrays.copyOfRange(SpellCheckerProximityInfo.PROXIMITY,
proximityIndex, proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
proximityIndex,
proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
}
composer.add(character, proximities,
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
@ -388,6 +390,15 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
| (result.mLooksLikeTypo
? SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO : 0);
return new SuggestionsInfo(flags, result.mSuggestions);
} catch (RuntimeException e) {
// Don't kill the keyboard if there is a bug in the spell checker
if (DBG) {
throw e;
} else {
Log.e(TAG, "Exception while spellcheking: " + e);
return EMPTY_SUGGESTIONS_INFO;
}
}
}
}
}