From 78bf41b89c8226870c5ab172d563aa1b16db1513 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Wed, 21 Mar 2012 17:10:19 +0900 Subject: [PATCH] Add additional structure to output logs to group entries by optional fields. The new format has time, time as int, and the new logGroup code (m=motionEvent, k=key, s=statechange, c=correction) followed by additional text whose format depends on the logGroup code. The additional text will be cleaned up in later CL's. 20120321-170548.067+0900 1332317148067 m [Down]143116235,0,691,378,0.40000004,0.435 20120321-170548.133+0900 1332317148133 m [Up]143116302,0,691,378,0.40000004,0.435 20120321-170548.146+0900 1332317148146 k 691 378 20120321-170602.485+0900 1332317162485 s [onStartInputView]com.socialnmobile.dictapps.notepad.color.note,2131624043,147457,1140850694 20120321-170606.508+0900 1332317166508 m [Down]143134679,0,40,154,0.4666667,0.64 20120321-170606.567+0900 1332317166567 m [Move]143134723,0,42,154,0.4666667,0.765 20120321-170606.577+0900 1332317166577 m [Move]143134746,0,44,154,0.4666667,0.775 20120321-170606.652+0900 1332317166652 m [Up]143134824,0,44,154,0.4666667,0.775 20120321-170606.662+0900 1332317166662 k A 40 154 20120321-170607.200+0900 1332317167200 m [Down]143135372,0,411,390,0.53333336,0.585 20120321-170607.311+0900 1332317167311 m [Up]143135483,0,411,390,0.53333336,0.585 20120321-170607.313+0900 1332317167313 c [----]A Bug: 6188932 Change-Id: I8694eb9016d8cf0389ef582f6c7d2820aa4d2c92 --- .../keyboard/LatinKeyboardView.java | 10 ++++--- .../com/android/inputmethod/latin/Utils.java | 28 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index b869059e4..da7d01af4 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -54,6 +54,7 @@ import com.android.inputmethod.latin.StringUtils; import com.android.inputmethod.latin.SubtypeUtils; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; +import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils.LogGroup; import java.util.Locale; import java.util.WeakHashMap; @@ -701,7 +702,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke break; } if (!TextUtils.isEmpty(eventTag)) { - UsabilityStudyLogUtils.getInstance().write( + UsabilityStudyLogUtils.getInstance().write(LogGroup.MOTION_EVENT, eventTag + eventTime + "," + id + "," + x + "," + y + "," + me.getSize(index) + "," + me.getPressure(index)); } @@ -764,9 +765,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } tracker.onMoveEvent(px, py, eventTime); if (ENABLE_USABILITY_STUDY_LOG) { - UsabilityStudyLogUtils.getInstance().write("[Move]" + eventTime + "," - + me.getPointerId(i) + "," + px + "," + py + "," - + me.getSize(i) + "," + me.getPressure(i)); + UsabilityStudyLogUtils.getInstance().write( + LogGroup.MOTION_EVENT, + "[Move]" + eventTime + "," + me.getPointerId(i) + "," + px + "," + py + + "," + me.getSize(i) + "," + me.getPressure(i)); } } } else { diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 509bd368d..36a3d3061 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -260,8 +260,25 @@ public class Utils { } } + /** + * Represents a category of logging events that share the same subfield structure. + */ + public static enum LogGroup { + MOTION_EVENT("m"), + KEY("k"), + CORRECTION("c"), + STATE_CHANGE("s"); + + private final String mLogString; + + private LogGroup(String logString) { + mLogString = logString; + } + } + public static void writeBackSpace(int x, int y) { - UsabilityStudyLogUtils.getInstance().write("\t" + x + "\t" + y); + UsabilityStudyLogUtils.getInstance().write( + LogGroup.KEY, "\t" + x + "\t" + y); } public void writeChar(char c, int x, int y) { @@ -277,11 +294,12 @@ public class Utils { inputChar = ""; break; } - UsabilityStudyLogUtils.getInstance().write(inputChar + "\t" + x + "\t" + y); + UsabilityStudyLogUtils.getInstance().write(LogGroup.KEY, + inputChar + "\t" + x + "\t" + y); LatinImeLogger.onPrintAllUsabilityStudyLogs(); } - public void write(final String log) { + public void write(final LogGroup logGroup, final String log) { mLoggingHandler.post(new Runnable() { @Override public void run() { @@ -289,8 +307,8 @@ public class Utils { final long currentTime = System.currentTimeMillis(); mDate.setTime(currentTime); - final String printString = String.format("%s\t%d\t%s\n", - mDateFormat.format(mDate), currentTime, log); + final String printString = String.format("%s\t%d\t%s\t%s\n", + mDateFormat.format(mDate), currentTime, logGroup.mLogString, log); if (LatinImeLogger.sDBG) { Log.d(USABILITY_TAG, "Write: " + log); }