Merge "log through group level abstractions"

main
Kurt Partridge 2012-03-21 20:30:35 -07:00 committed by Android (Google) Code Review
commit 19b8a73efa
3 changed files with 64 additions and 57 deletions

View File

@ -54,7 +54,6 @@ import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeUtils; import com.android.inputmethod.latin.SubtypeUtils;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils.LogGroup;
import java.util.Locale; import java.util.Locale;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -70,9 +69,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
SuddenJumpingTouchEventHandler.ProcessMotionEvent { SuddenJumpingTouchEventHandler.ProcessMotionEvent {
private static final String TAG = LatinKeyboardView.class.getSimpleName(); private static final String TAG = LatinKeyboardView.class.getSimpleName();
// TODO: Kill process when the usability study mode was changed.
private static final boolean ENABLE_USABILITY_STUDY_LOG = LatinImeLogger.sUsabilityStudy;
/** Listener for {@link KeyboardActionListener}. */ /** Listener for {@link KeyboardActionListener}. */
private KeyboardActionListener mKeyboardActionListener; private KeyboardActionListener mKeyboardActionListener;
@ -672,6 +668,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final int index = me.getActionIndex(); final int index = me.getActionIndex();
final int id = me.getPointerId(index); final int id = me.getPointerId(index);
final int x, y; final int x, y;
final float size = me.getSize(index);
final float pressure = me.getPressure(index);
if (mMoreKeysPanel != null && id == mMoreKeysPanelPointerTrackerId) { if (mMoreKeysPanel != null && id == mMoreKeysPanelPointerTrackerId) {
x = mMoreKeysPanel.translateX((int)me.getX(index)); x = mMoreKeysPanel.translateX((int)me.getX(index));
y = mMoreKeysPanel.translateY((int)me.getY(index)); y = mMoreKeysPanel.translateY((int)me.getY(index));
@ -679,32 +677,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
x = (int)me.getX(index); x = (int)me.getX(index);
y = (int)me.getY(index); y = (int)me.getY(index);
} }
if (ENABLE_USABILITY_STUDY_LOG) { if (LatinImeLogger.sUsabilityStudy) {
final String eventTag; if (action != MotionEvent.ACTION_MOVE) {
switch (action) { // Skip ACTION_MOVE events as they are logged below
case MotionEvent.ACTION_UP: UsabilityStudyLogUtils.getInstance().writeMotionEvent(action, eventTime, id, x,
eventTag = "[Up]"; y, size, pressure);
break;
case MotionEvent.ACTION_DOWN:
eventTag = "[Down]";
break;
case MotionEvent.ACTION_POINTER_UP:
eventTag = "[PointerUp]";
break;
case MotionEvent.ACTION_POINTER_DOWN:
eventTag = "[PointerDown]";
break;
case MotionEvent.ACTION_MOVE: // Skip this as being logged below
eventTag = "";
break;
default:
eventTag = "[Action" + action + "]";
break;
}
if (!TextUtils.isEmpty(eventTag)) {
UsabilityStudyLogUtils.getInstance().write(LogGroup.MOTION_EVENT,
eventTag + eventTime + "," + id + "," + x + "," + y + ","
+ me.getSize(index) + "," + me.getPressure(index));
} }
} }
@ -764,11 +741,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
py = (int)me.getY(i); py = (int)me.getY(i);
} }
tracker.onMoveEvent(px, py, eventTime); tracker.onMoveEvent(px, py, eventTime);
if (ENABLE_USABILITY_STUDY_LOG) { if (LatinImeLogger.sUsabilityStudy) {
UsabilityStudyLogUtils.getInstance().write( UsabilityStudyLogUtils.getInstance().writeMotionEvent(action, eventTime, id,
LogGroup.MOTION_EVENT, px, py, size, pressure);
"[Move]" + eventTime + "," + me.getPointerId(i) + "," + px + "," + py
+ "," + me.getSize(i) + "," + me.getPressure(i));
} }
} }
} else { } else {

View File

@ -68,6 +68,7 @@ import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboardView; import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
import com.android.inputmethod.latin.suggestions.SuggestionsView; import com.android.inputmethod.latin.suggestions.SuggestionsView;
import java.io.FileDescriptor; import java.io.FileDescriptor;
@ -1266,6 +1267,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mDeleteCount = 0; mDeleteCount = 0;
} }
mLastKeyTime = when; mLastKeyTime = when;
if (LatinImeLogger.sUsabilityStudy) {
UsabilityStudyLogUtils.getInstance().writeKeyEvent(primaryCode, x, y);
}
final KeyboardSwitcher switcher = mKeyboardSwitcher; final KeyboardSwitcher switcher = mKeyboardSwitcher;
// The space state depends only on the last character pressed and its own previous // The space state depends only on the last character pressed and its own previous
// state. Here, we revert the space state to neutral if the key is actually modifying // state. Here, we revert the space state to neutral if the key is actually modifying

View File

@ -31,7 +31,9 @@ import android.os.Process;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -138,9 +140,6 @@ public class Utils {
// TODO: accept code points // TODO: accept code points
public void push(char c, int x, int y) { public void push(char c, int x, int y) {
if (!mEnabled) return; if (!mEnabled) return;
if (mUsabilityStudy) {
UsabilityStudyLogUtils.getInstance().writeChar(c, x, y);
}
mCharBuf[mEnd] = c; mCharBuf[mEnd] = c;
mXBuf[mEnd] = x; mXBuf[mEnd] = x;
mYBuf[mEnd] = y; mYBuf[mEnd] = y;
@ -279,30 +278,57 @@ public class Utils {
} }
} }
public static void writeBackSpace(int x, int y) { public void writeMotionEvent(final int action, final long eventTime, final int id,
UsabilityStudyLogUtils.getInstance().write( final int x, final int y, final float size, final float pressure) {
LogGroup.KEY, "<backspace>\t" + x + "\t" + y); final String eventTag;
switch (action) {
case MotionEvent.ACTION_CANCEL: eventTag = "[Cancel]"; break;
case MotionEvent.ACTION_UP: eventTag = "[Up]"; break;
case MotionEvent.ACTION_DOWN: eventTag = "[Down]"; break;
case MotionEvent.ACTION_POINTER_UP: eventTag = "[PointerUp]"; break;
case MotionEvent.ACTION_POINTER_DOWN: eventTag = "[PointerDown]"; break;
case MotionEvent.ACTION_MOVE: eventTag = "[Move]"; break;
case MotionEvent.ACTION_OUTSIDE: eventTag = "[Outside]"; break;
default: eventTag = "[Action" + action + "]"; break;
}
if (!TextUtils.isEmpty(eventTag)) {
StringBuilder sb = new StringBuilder();
sb.append(eventTag);
sb.append('\t'); sb.append(eventTime);
sb.append('\t'); sb.append(id);
sb.append('\t'); sb.append(x);
sb.append('\t'); sb.append(y);
sb.append('\t'); sb.append(size);
sb.append('\t'); sb.append(pressure);
write(LogGroup.MOTION_EVENT, sb.toString());
}
} }
public void writeChar(char c, int x, int y) { public void writeKeyEvent(int code, int x, int y) {
String inputChar = String.valueOf(c); final StringBuilder sb = new StringBuilder();
switch (c) { sb.append(Keyboard.printableCode(code));
case '\n': sb.append('\t'); sb.append(x);
inputChar = "<enter>"; sb.append('\t'); sb.append(y);
break; write(LogGroup.KEY, sb.toString());
case '\t':
inputChar = "<tab>"; // TODO: replace with a cleaner flush+retrieve mechanism
break;
case ' ':
inputChar = "<space>";
break;
}
UsabilityStudyLogUtils.getInstance().write(LogGroup.KEY,
inputChar + "\t" + x + "\t" + y);
LatinImeLogger.onPrintAllUsabilityStudyLogs(); LatinImeLogger.onPrintAllUsabilityStudyLogs();
} }
public void write(final LogGroup logGroup, final String log) { public void writeCorrection(String subgroup, String before, String after, int position) {
final StringBuilder sb = new StringBuilder();
sb.append(subgroup);
sb.append('\t'); sb.append(before);
sb.append('\t'); sb.append(after);
sb.append('\t'); sb.append(position);
write(LogGroup.CORRECTION, sb.toString());
}
public void writeStateChange(String subgroup, String details) {
write(LogGroup.STATE_CHANGE, subgroup + "\t" + details);
}
private void write(final LogGroup logGroup, final String log) {
mLoggingHandler.post(new Runnable() { mLoggingHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {