am e9c64558: [Rlog48] Better logging of MotionEvents
* commit 'e9c6455881060c9f43a15a499582118b2ac2fa65': [Rlog48] Better logging of MotionEventsmain
commit
05b6cda6ef
|
@ -18,6 +18,7 @@ package com.android.inputmethod.research;
|
|||
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.JsonWriter;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.inputmethod.CompletionInfo;
|
||||
|
||||
import com.android.inputmethod.keyboard.Key;
|
||||
|
@ -27,6 +28,9 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Routines for mapping classes and variables to JSON representations for logging.
|
||||
*/
|
||||
/* package */ class JsonUtils {
|
||||
private JsonUtils() {
|
||||
// This utility class is not publicly instantiable.
|
||||
|
@ -100,4 +104,54 @@ import java.util.Map;
|
|||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
|
||||
/* package */ static void writeJson(final MotionEvent me, final JsonWriter jsonWriter)
|
||||
throws IOException {
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name("pointerIds");
|
||||
jsonWriter.beginArray();
|
||||
final int pointerCount = me.getPointerCount();
|
||||
for (int index = 0; index < pointerCount; index++) {
|
||||
jsonWriter.value(me.getPointerId(index));
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
|
||||
jsonWriter.name("xyt");
|
||||
jsonWriter.beginArray();
|
||||
final int historicalSize = me.getHistorySize();
|
||||
for (int index = 0; index < historicalSize; index++) {
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name("t");
|
||||
jsonWriter.value(me.getHistoricalEventTime(index));
|
||||
jsonWriter.name("d");
|
||||
jsonWriter.beginArray();
|
||||
for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) {
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name("x");
|
||||
jsonWriter.value(me.getHistoricalX(pointerIndex, index));
|
||||
jsonWriter.name("y");
|
||||
jsonWriter.value(me.getHistoricalY(pointerIndex, index));
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name("t");
|
||||
jsonWriter.value(me.getEventTime());
|
||||
jsonWriter.name("d");
|
||||
jsonWriter.beginArray();
|
||||
for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) {
|
||||
jsonWriter.beginObject();
|
||||
jsonWriter.name("x");
|
||||
jsonWriter.value(me.getX(pointerIndex));
|
||||
jsonWriter.name("y");
|
||||
jsonWriter.value(me.getY(pointerIndex));
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
jsonWriter.endArray();
|
||||
jsonWriter.endObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.research;
|
|||
import android.content.SharedPreferences;
|
||||
import android.util.JsonWriter;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.inputmethod.CompletionInfo;
|
||||
|
||||
import com.android.inputmethod.keyboard.Key;
|
||||
|
@ -189,6 +190,8 @@ import java.util.Map;
|
|||
JsonUtils.writeJson((Key[]) value, jsonWriter);
|
||||
} else if (value instanceof SuggestedWords) {
|
||||
JsonUtils.writeJson((SuggestedWords) value, jsonWriter);
|
||||
} else if (value instanceof MotionEvent) {
|
||||
JsonUtils.writeJson((MotionEvent) value, jsonWriter);
|
||||
} else if (value == null) {
|
||||
jsonWriter.nullValue();
|
||||
} else {
|
||||
|
|
|
@ -643,7 +643,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mMainKeyboardView.invalidateAllKeys();
|
||||
}
|
||||
|
||||
|
||||
public void paintIndicator(KeyboardView view, Paint paint, Canvas canvas, int width,
|
||||
int height) {
|
||||
// TODO: Reimplement using a keyboard background image specific to the ResearchLogger
|
||||
|
@ -896,8 +895,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
*
|
||||
*/
|
||||
private static final LogStatement LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT =
|
||||
new LogStatement("MainKeyboardViewProcessMotionEvent", true, false, "action",
|
||||
"eventTime", "id", "x", "y", "size", "pressure");
|
||||
new LogStatement("MotionEvent", true, false, "action", "MotionEvent");
|
||||
public static void mainKeyboardView_processMotionEvent(final MotionEvent me, final int action,
|
||||
final long eventTime, final int index, final int id, final int x, final int y) {
|
||||
if (me != null) {
|
||||
|
@ -912,11 +910,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
case MotionEvent.ACTION_OUTSIDE: actionString = "OUTSIDE"; break;
|
||||
default: actionString = "ACTION_" + action; break;
|
||||
}
|
||||
final float size = me.getSize(index);
|
||||
final float pressure = me.getPressure(index);
|
||||
final ResearchLogger researchLogger = getInstance();
|
||||
researchLogger.enqueueEvent(LOGSTATEMENT_MAIN_KEYBOARD_VIEW_PROCESS_MOTION_EVENT,
|
||||
actionString, eventTime, id, x, y, size, pressure);
|
||||
actionString, MotionEvent.obtain(me));
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
// Subtract 1 from eventTime so the down event is included in the later
|
||||
// LogUnit, not the earlier (the test is for inequality).
|
||||
|
|
Loading…
Reference in New Issue