Fix NPE happening in unit tests.
Change-Id: I2fc0dba53e18883755ff77351c152a9d3534c92b
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index ab7e66a..217b0b1 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1747,9 +1747,10 @@
@UsedForTesting
/* package for test */ DistracterFilter createDistracterFilter() {
- return new DistracterFilter(this /* Context */,
+ // Return an empty distracter filter when this method is called before onCreate().
+ return (mRichImm != null) ? new DistracterFilter(this /* Context */,
mRichImm.getMyEnabledInputMethodSubtypeList(
- true /* allowsImplicitlySelectedSubtypes */));
+ true /* allowsImplicitlySelectedSubtypes */)) : new DistracterFilter();
}
public void dumpDictionaryForDebug(final String dictName) {