am 22f01a42: Add a functionality to clear and flush prediction dictionary

* commit '22f01a42fcd91dae2a4e723e2477a480a11daa8e':
  Add a functionality to clear and flush prediction dictionary
main
Satoshi Kataoka 2013-08-19 20:40:27 -07:00 committed by Android Git Automerger
commit bff4d24432
2 changed files with 21 additions and 0 deletions

View File

@ -411,4 +411,18 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona
public void unRegisterUpdateSession(PersonalizationDictionaryUpdateSession session) { public void unRegisterUpdateSession(PersonalizationDictionaryUpdateSession session) {
mSessions.remove(session); mSessions.remove(session);
} }
public void clearAndFlushDictionary() {
// Clear the node structure on memory
clearDictionary();
mBigramListLock.lock();
try {
// Clear the bigram list on memory
mBigramList.evictAll();
} finally {
mBigramListLock.unlock();
}
// Then flush the cleared state of the dictionary on disk.
flushPendingWrites();
}
} }

View File

@ -69,6 +69,13 @@ public abstract class PersonalizationDictionaryUpdateSession {
dictionary.unRegisterUpdateSession(this); dictionary.unRegisterUpdateSession(this);
} }
public void clearAndFlushPredictionDictionary(Context context) {
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
if (dictionary == null) {
return;
}
dictionary.clearAndFlushDictionary();
}
public void closeSession(Context context) { public void closeSession(Context context) {
unsetPredictionDictionary(); unsetPredictionDictionary();