Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 552a4b84 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Add UsabilityStudyLogUtils.writeMotionEvent"

parents 567e7f05 30977a15
Loading
Loading
Loading
Loading
+2 −43
Original line number Diff line number Diff line
@@ -117,9 +117,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
        PointerTracker.DrawingProxy, MoreKeysPanel.Controller {
    private static final String TAG = MainKeyboardView.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}. */
    private KeyboardActionListener mKeyboardActionListener;

@@ -1069,8 +1066,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
        final int y = (int)me.getY(index);

        // TODO: This might be moved to the tracker.processMotionEvent() call below.
        if (ENABLE_USABILITY_STUDY_LOG && action != MotionEvent.ACTION_MOVE) {
            writeUsabilityStudyLog(me, action, eventTime, index, id, x, y);
        if (LatinImeLogger.sUsabilityStudy) {
            UsabilityStudyLogUtils.writeMotionEvent(me);
        }
        // TODO: This should be moved to the tracker.processMotionEvent() call below.
        // Currently the same "move" event is being logged twice.
@@ -1131,15 +1128,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
                final int px = (int)me.getX(i);
                final int py = (int)me.getY(i);
                tracker.onMoveEvent(px, py, eventTime, me);
                if (ENABLE_USABILITY_STUDY_LOG) {
                    writeUsabilityStudyLog(me, action, eventTime, i, pointerId, px, py);
                }
                // TODO: This seems to be no longer necessary, and confusing because it leads to
                // duplicate MotionEvents being recorded.
                // if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
                //     ResearchLogger.mainKeyboardView_processMotionEvent(
                //             me, action, eventTime, i, pointerId, px, py);
                // }
            }
        } else {
            final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
@@ -1149,35 +1137,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
        return true;
    }

    private static void writeUsabilityStudyLog(final MotionEvent me, final int action,
            final long eventTime, final int index, final int id, final int x, final int y) {
        final String eventTag;
        switch (action) {
        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;
        default:
            eventTag = "[Action" + action + "]";
            break;
        }
        final float size = me.getSize(index);
        final float pressure = me.getPressure(index);
        UsabilityStudyLogUtils.getInstance().write(
                eventTag + eventTime + "," + id + "," + x + "," + y + "," + size + "," + pressure);
    }

    public void cancelAllOngoingEvents() {
        mKeyTimerHandler.cancelAllMessages();
        mDrawingHandler.cancelAllMessages();
+38 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
import android.util.Log;
import android.view.MotionEvent;

import com.android.inputmethod.latin.LatinImeLogger;

@@ -109,6 +110,43 @@ public final class UsabilityStudyLogUtils {
        LatinImeLogger.onPrintAllUsabilityStudyLogs();
    }

    public static void writeMotionEvent(final MotionEvent me) {
        final int action = me.getActionMasked();
        final long eventTime = me.getEventTime();
        final int pointerCount = me.getPointerCount();
        for (int index = 0; index < pointerCount; index++) {
            final int id = me.getPointerId(index);
            final int x = (int)me.getX(index);
            final int y = (int)me.getY(index);
            final float size = me.getSize(index);
            final float pressure = me.getPressure(index);

            final String eventTag;
            switch (action) {
            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;
            default:
                eventTag = "[Action" + action + "]";
                break;
            }
            getInstance().write(eventTag + eventTime + "," + id + "," + x + "," + y + "," + size
                    + "," + pressure);
        }
    }

    public void write(final String log) {
        mLoggingHandler.post(new Runnable() {
            @Override