am f96e0f07: Merge "Periodic wipe of the personalization dict."

* commit 'f96e0f07af8230a43d733ee7a19c08c205197037':
  Periodic wipe of the personalization dict.
main
Keisuke Kuroyanagi 2014-01-10 01:42:00 -08:00 committed by Android Git Automerger
commit 75950a7867
3 changed files with 17 additions and 1 deletions

View File

@ -139,4 +139,8 @@
<dimen name="config_accessibility_edge_slop">8dp</dimen> <dimen name="config_accessibility_edge_slop">8dp</dimen>
<integer name="config_user_dictionary_max_word_length">48</integer> <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> </resources>

View File

@ -282,7 +282,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
@Override @Override
public void run() { public void run() {
if (mDictionaryWriter == null) { if (mDictionaryWriter == null) {
mBinaryDictionary.close(); if (mBinaryDictionary != null) {
mBinaryDictionary.close();
}
final File file = getDictFile(); final File file = getDictFile();
if (file.exists() && !FileUtils.deleteRecursively(file)) { if (file.exists() && !FileUtils.deleteRecursively(file)) {
Log.e(TAG, "Can't remove a file: " + file.getName()); Log.e(TAG, "Can't remove a file: " + file.getName());

View File

@ -93,6 +93,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
private static final String PREF_LAST_USED_PERSONALIZATION_TOKEN = private static final String PREF_LAST_USED_PERSONALIZATION_TOKEN =
"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_SEND_FEEDBACK = "send_feedback";
public static final String PREF_ABOUT_KEYBOARD = "about_keyboard"; public static final String PREF_ABOUT_KEYBOARD = "about_keyboard";
@ -372,6 +374,14 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return StringUtils.hexStringToByteArray(tokenStr); 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) { public static void writeEmojiRecentKeys(final SharedPreferences prefs, String str) {
prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply(); prefs.edit().putString(PREF_EMOJI_RECENT_KEYS, str).apply();
} }