Remove personalization dicts for multilingual users.

Bug: 13067743
Change-Id: I1f50cb137b6054dc9442237586b70fc0aa2bf427
This commit is contained in:
Keisuke Kuroyanagi 2014-02-19 21:00:27 +09:00
parent 920c40fe45
commit d102eb80da
3 changed files with 26 additions and 13 deletions

View file

@ -512,7 +512,6 @@ public class DictionaryFacilitatorForSuggest {
}
}
@UsedForTesting
public void clearUserHistoryDictionary() {
if (mUserHistoryDictionary == null) {
return;

View file

@ -534,17 +534,28 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
private void refreshPersonalizationDictionarySession() {
final Suggest suggest = mInputLogic.mSuggest;
final boolean shouldKeepUserHistoryDictionaries;
final boolean shouldKeepPersonalizationDictionaries;
if (mSettings.getCurrent().mUsePersonalizedDicts) {
if (mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes()) {
final DictionaryFacilitatorForSuggest dictionaryFacilitator =
(mInputLogic.mSuggest == null) ?
null : mInputLogic.mSuggest.mDictionaryFacilitator;
PersonalizationDictionarySessionRegistrar.init(this, dictionaryFacilitator);
} else {
PersonalizationDictionarySessionRegistrar.close(this);
}
shouldKeepUserHistoryDictionaries = true;
// TODO: Eliminate this restriction
shouldKeepPersonalizationDictionaries =
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes();
} else {
PersonalizationHelper.removeAllPersonalizedDictionaries(this);
shouldKeepUserHistoryDictionaries = false;
shouldKeepPersonalizationDictionaries = false;
}
if (!shouldKeepUserHistoryDictionaries) {
// Remove user history dictionaries.
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
if (suggest != null) {
suggest.mDictionaryFacilitator.clearUserHistoryDictionary();
}
}
if (!shouldKeepPersonalizationDictionaries) {
// Remove personalization dictionaries.
PersonalizationHelper.removeAllPersonalizationDictionaries(this);
PersonalizationDictionarySessionRegistrar.resetAll(this);
}
}

View file

@ -93,13 +93,16 @@ public class PersonalizationHelper {
}
}
public static void removeAllPersonalizedDictionaries(final Context context) {
removeAllDictionaries(context, sLangUserHistoryDictCache,
UserHistoryDictionary.NAME);
public static void removeAllPersonalizationDictionaries(final Context context) {
removeAllDictionaries(context, sLangPersonalizationDictCache,
PersonalizationDictionary.NAME);
}
public static void removeAllUserHistoryDictionaries(final Context context) {
removeAllDictionaries(context, sLangUserHistoryDictCache,
UserHistoryDictionary.NAME);
}
private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries(
final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap,
final String dictNamePrefix) {