Periodic wipe of the personalization dict.
Bug: 12216453 Change-Id: Ie59dd19c044e9b1eb9b8bd805366200737ea506a
This commit is contained in:
parent
05113c1847
commit
ba07df7fc1
3 changed files with 17 additions and 1 deletions
|
@ -139,4 +139,8 @@
|
|||
<dimen name="config_accessibility_edge_slop">8dp</dimen>
|
||||
|
||||
<integer name="config_user_dictionary_max_word_length">48</integer>
|
||||
|
||||
<!-- Personalization configuration -->
|
||||
<!-- -1 means periocical wipe of the personalization dict is disabled. -->
|
||||
<integer name="config_personalization_dict_wipe_interval_in_days">-1</integer>
|
||||
</resources>
|
||||
|
|
|
@ -282,7 +282,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
|
|||
@Override
|
||||
public void run() {
|
||||
if (mDictionaryWriter == null) {
|
||||
mBinaryDictionary.close();
|
||||
if (mBinaryDictionary != null) {
|
||||
mBinaryDictionary.close();
|
||||
}
|
||||
final File file = getDictFile();
|
||||
if (file.exists() && !FileUtils.deleteRecursively(file)) {
|
||||
Log.e(TAG, "Can't remove a file: " + file.getName());
|
||||
|
|
|
@ -93,6 +93,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
|
||||
private static final String PREF_LAST_USED_PERSONALIZATION_TOKEN =
|
||||
"pref_last_used_personalization_token";
|
||||
private static final String PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME =
|
||||
"pref_last_used_personalization_dict_wiped_time";
|
||||
public static final String PREF_SEND_FEEDBACK = "send_feedback";
|
||||
public static final String PREF_ABOUT_KEYBOARD = "about_keyboard";
|
||||
|
||||
|
@ -372,6 +374,14 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
return StringUtils.hexStringToByteArray(tokenStr);
|
||||
}
|
||||
|
||||
public void writeLastPersonalizationDictWipedTime(final long timestamp) {
|
||||
mPrefs.edit().putLong(PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME, timestamp).apply();
|
||||
}
|
||||
|
||||
public long readLastPersonalizationDictGeneratedTime() {
|
||||
return mPrefs.getLong(PREF_LAST_PERSONALIZATION_DICT_WIPED_TIME, 0);
|
||||
}
|
||||
|
||||
public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) {
|
||||
prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue