diff options
author | 2013-01-10 10:51:17 -0800 | |
---|---|---|
committer | 2013-01-10 10:51:17 -0800 | |
commit | 700ce8df07eb242ce93f4f5e3e0ceb78473938ab (patch) | |
tree | fb9f105a96578dd6d2118b0dca810fd91b87e82f /java/src/com/android/inputmethod/research/ResearchLogger.java | |
parent | 4da2ed7a78c63284fa3869450a492ee7ae420ed9 (diff) | |
parent | 403c423940b197e56f4d203050341b7cd90ca0cd (diff) | |
download | latinime-700ce8df07eb242ce93f4f5e3e0ceb78473938ab.tar.gz latinime-700ce8df07eb242ce93f4f5e3e0ceb78473938ab.tar.xz latinime-700ce8df07eb242ce93f4f5e3e0ceb78473938ab.zip |
Merge "[Rlog56] Buffer words before pushing out LogUnit"
Diffstat (limited to 'java/src/com/android/inputmethod/research/ResearchLogger.java')
-rw-r--r-- | java/src/com/android/inputmethod/research/ResearchLogger.java | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index b61db272c..f464facf4 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -85,7 +85,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final String TAG = ResearchLogger.class.getSimpleName(); private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // Whether all n-grams should be logged. true will disclose private info. - private static final boolean IS_LOGGING_EVERYTHING = false + public static final boolean IS_LOGGING_EVERYTHING = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; // Whether the TextView contents are logged at the end of the session. true will disclose // private info. @@ -394,8 +394,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang commitCurrentLogUnit(); if (mMainLogBuffer != null) { - publishLogBuffer(mMainLogBuffer, mMainResearchLog, - IS_LOGGING_EVERYTHING /* isIncludingPrivateData */); + while (!mMainLogBuffer.isEmpty()) { + if ((mMainLogBuffer.isNGramSafe() || IS_LOGGING_EVERYTHING) && + mMainResearchLog != null) { + publishLogBuffer(mMainLogBuffer, mMainResearchLog, + true /* isIncludingPrivateData */); + mMainLogBuffer.resetWordCounter(); + } else { + mMainLogBuffer.shiftOutThroughFirstWord(); + } + } mMainResearchLog.close(null /* callback */); mMainLogBuffer = null; } @@ -702,8 +710,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } if (!mCurrentLogUnit.isEmpty()) { if (mMainLogBuffer != null) { - if ((mMainLogBuffer.isSafeToLog() || IS_LOGGING_EVERYTHING) - && mMainResearchLog != null) { + if ((mMainLogBuffer.isNGramSafe() || IS_LOGGING_EVERYTHING) && + mMainLogBuffer.isNGramComplete() && + mMainResearchLog != null) { publishLogBuffer(mMainLogBuffer, mMainResearchLog, true /* isIncludingPrivateData */); mMainLogBuffer.resetWordCounter(); @@ -714,6 +723,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang mFeedbackLogBuffer.shiftIn(mCurrentLogUnit); } mCurrentLogUnit = new LogUnit(); + } else { + if (DEBUG) { + Log.d(TAG, "Warning: tried to commit empty log unit."); + } } } @@ -756,8 +769,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang mFeedbackLogBuffer.unshiftIn(); } if (DEBUG) { - Log.d(TAG, "uncommitCurrentLogUnit back to " + (mCurrentLogUnit.hasWord() - ? ": '" + mCurrentLogUnit.getWord() + "'" : "")); + Log.d(TAG, "uncommitCurrentLogUnit (dump=" + dumpCurrentLogUnit + ") back to " + + (mCurrentLogUnit.hasWord() ? ": '" + mCurrentLogUnit.getWord() + "'" : "")); } } @@ -773,12 +786,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang isIncludingPrivateData); researchLog.publish(openingLogUnit, true /* isIncludingPrivateData */); LogUnit logUnit; - while ((logUnit = logBuffer.shiftOut()) != null) { + int numWordsToPublish = MainLogBuffer.N_GRAM_SIZE; + while ((logUnit = logBuffer.shiftOut()) != null && numWordsToPublish > 0) { if (DEBUG) { Log.d(TAG, "publishLogBuffer: " + (logUnit.hasWord() ? logUnit.getWord() : "<wordless>")); } researchLog.publish(logUnit, isIncludingPrivateData); + if (logUnit.getWord() != null) { + numWordsToPublish--; + } } final LogUnit closingLogUnit = new LogUnit(); closingLogUnit.addLogStatement(LOGSTATEMENT_LOG_SEGMENT_CLOSING, @@ -1254,9 +1271,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang public static void latinIME_revertCommit(final String committedWord, final String originallyTypedWord, final boolean isBatchMode) { final ResearchLogger researchLogger = getInstance(); - final LogUnit logUnit = researchLogger.mMainLogBuffer.peekLastLogUnit(); + // Assume that mCurrentLogUnit has been restored to contain the reverted word. + final LogUnit logUnit = researchLogger.mCurrentLogUnit; if (originallyTypedWord.length() > 0 && hasLetters(originallyTypedWord)) { if (logUnit != null) { + // Probably not necessary, but setting as a precaution in case the word isn't + // committed later. logUnit.setWord(originallyTypedWord); } } |