From 107d9dd5c01e727eaae62195e94128722fc05afc Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 21 May 2010 14:00:37 +0900 Subject: [PATCH] Fix the valid length of a logged data Change-Id: I94abccd9585edc42555ab3ffaed35f09cdfadd44 --- .../inputmethod/latin/LatinImeLogger.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java index 54778b9ef..dcd1962c0 100644 --- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java +++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java @@ -141,6 +141,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang } private void addCountEntry(long time) { + if (sDBG) { + Log.d(TAG, "Log counts. (4)"); + } mLogBuffer.add(new LogEntry (time, ID_DELETE_COUNT, new String[] {String.valueOf(mDeleteCount)})); mLogBuffer.add(new LogEntry (time, ID_INPUT_COUNT, @@ -153,14 +156,21 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang mInputCount = 0; mWordCount = 0; mActualCharCount = 0; + mLastTimeCountEntry = time; } private void addThemeIdEntry(long time) { + if (sDBG) { + Log.d(TAG, "Log theme Id. (1)"); + } mLogBuffer.add(new LogEntry (time, ID_THEME_ID, new String[] {mThemeId})); } private void flushPrivacyLogSafely() { + if (sDBG) { + Log.d(TAG, "Log theme Id. (" + mPrivacyLogBuffer.size() + ")"); + } long now = System.currentTimeMillis(); Collections.sort(mPrivacyLogBuffer); for (LogEntry l: mPrivacyLogBuffer) { @@ -178,7 +188,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang private void addData(int tag, Object data) { switch (tag) { case ID_DELETE_COUNT: - if (mLastTimeActive - mLastTimeCountEntry > MINIMUMCOUNTINTERVAL + if (((mLastTimeActive - mLastTimeCountEntry) > MINIMUMCOUNTINTERVAL) || (mDeleteCount == 0 && mInputCount == 0)) { addCountEntry(mLastTimeActive); addThemeIdEntry(mLastTimeActive); @@ -186,7 +196,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang mDeleteCount += (Integer)data; break; case ID_INPUT_COUNT: - if (mLastTimeActive - mLastTimeCountEntry > MINIMUMCOUNTINTERVAL + if (((mLastTimeActive - mLastTimeCountEntry) > MINIMUMCOUNTINTERVAL) || (mDeleteCount == 0 && mInputCount == 0)) { addCountEntry(mLastTimeActive); addThemeIdEntry(mLastTimeActive); @@ -197,9 +207,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang case ID_AUTOSUGGESTION: ++mWordCount; String[] dataStrings = (String[]) data; - if (dataStrings.length != 3) { + if (dataStrings.length < 2) { if (sDBG) { - Log.e(TAG, "The length of string array is invalid."); + Log.e(TAG, "The length of logged string array is invalid."); } break; } @@ -216,9 +226,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang case ID_AUTOSUGGESTIONCANCELED: --mWordCount; dataStrings = (String[]) data; - if (dataStrings.length != 3) { + if (dataStrings.length < 2) { if (sDBG) { - Log.e(TAG, "The length of string array is invalid."); + Log.e(TAG, "The length of logged string array is invalid."); } break; } @@ -241,6 +251,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang } private void commitInternal() { + if (sDBG) { + Log.d(TAG, "Commit (" + mLogBuffer.size() + ")"); + } flushPrivacyLogSafely(); long now = System.currentTimeMillis(); addCountEntry(now);