am 7c996475: Merge "[TestPrep3] Add helper method to retrive dictionary"
* commit '7c996475d8531af413c09d4ece51423b96edd172': [TestPrep3] Add helper method to retrive dictionarymain
commit
4d13c6667d
|
@ -93,6 +93,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
mSuggest = suggest;
|
mSuggest = suggest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary getDictionary() {
|
||||||
|
if (mSuggest == null || !mSuggest.hasMainDictionary()) return null;
|
||||||
|
return mSuggest.getMainDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
public void resetWordCounter() {
|
public void resetWordCounter() {
|
||||||
mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams;
|
mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams;
|
||||||
}
|
}
|
||||||
|
@ -137,18 +142,15 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
if (mNumWordsUntilSafeToSample > 0) {
|
if (mNumWordsUntilSafeToSample > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mSuggest == null || !mSuggest.hasMainDictionary()) {
|
// Reload the dictionary in case it has changed (e.g., because the user has changed
|
||||||
|
// languages).
|
||||||
|
final Dictionary dictionary = getDictionary();
|
||||||
|
if (dictionary == null) {
|
||||||
// Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
|
// Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
|
||||||
// word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
|
// word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
|
||||||
// contents to potentially pose a privacy risk.
|
// contents to potentially pose a privacy risk.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Reload the dictionary in case it has changed (e.g., because the user has changed
|
|
||||||
// languages).
|
|
||||||
final Dictionary dictionary = mSuggest.getMainDictionary();
|
|
||||||
if (dictionary == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check each word in the buffer. If any word poses a privacy threat, we cannot upload
|
// Check each word in the buffer. If any word poses a privacy threat, we cannot upload
|
||||||
// the complete buffer contents in detail.
|
// the complete buffer contents in detail.
|
||||||
|
|
Loading…
Reference in New Issue