From 34ed5b0742b6173928a0a543f438ec9192bb6e51 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Tue, 17 Jun 2014 09:33:37 +0900 Subject: [PATCH] Fix: NPE when initializing AOSP keyboard. Bug: 15677822 Change-Id: Ibebb215a08795482c0f1eef965db06af57558906 --- .../PersonalizationDictionaryUpdater.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdater.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdater.java index 07bcf98cb..c97a0d232 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdater.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdater.java @@ -23,11 +23,14 @@ import android.content.Context; import com.android.inputmethod.latin.DictionaryFacilitator; public class PersonalizationDictionaryUpdater { + final Context mContext; + final DictionaryFacilitator mDictionaryFacilitator; + boolean mDictCleared = false; + public PersonalizationDictionaryUpdater(final Context context, final DictionaryFacilitator dictionaryFacilitator) { - // Clear and never update the personalization dictionary. - PersonalizationHelper.removeAllPersonalizationDictionaries(context); - dictionaryFacilitator.clearPersonalizationDictionary(); + mContext = context; + mDictionaryFacilitator = dictionaryFacilitator; } public Locale getLocale() { @@ -36,6 +39,12 @@ public class PersonalizationDictionaryUpdater { public void onLoadSettings(final boolean usePersonalizedDicts, final boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes) { + if (!mDictCleared) { + // Clear and never update the personalization dictionary. + PersonalizationHelper.removeAllPersonalizationDictionaries(mContext); + mDictionaryFacilitator.clearPersonalizationDictionary(); + mDictCleared = true; + } } public void onDestroy() {