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

Commit 9bc29d78 authored by Kurt Partridge's avatar Kurt Partridge
Browse files

add more data collection points to ResearchLogger (attempt #2)

the new points are all at Log.x() positions; only those appearing directly
related to user input were added.

multi-project change with I159f5de2

this CL is the same as I618bcd07, which was reverted because of
incompatibilities with vendor branches.

Bug: 6188932
Change-Id: I999249dceb0c04f5a4ffbfff25caed09d24a2c52
parent 264045ef
Loading
Loading
Loading
Loading
+7 −18
Original line number Diff line number Diff line
@@ -555,6 +555,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
     * method on the base class if the subclass doesn't wish to handle the call.
     */
    protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.latinKeyboardView_onLongPress();
        }
        final int primaryCode = parentKey.mCode;
        if (parentKey.hasEmbeddedMoreKey()) {
            final int embeddedCode = KeySpecParser.getCode(getResources(), parentKey.mMoreKeys[0]);
@@ -695,17 +698,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
            }
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            if (ResearchLogger.sIsLogging) {
                // TODO: remove redundant calculations of size and pressure by
                // removing UsabilityStudyLog code once the ResearchLogger is mature enough
                final float size = me.getSize(index);
                final float pressure = me.getPressure(index);
                if (action != MotionEvent.ACTION_MOVE) {
                    // Skip ACTION_MOVE events as they are logged below
                    ResearchLogger.getInstance().logMotionEvent(action, eventTime, id, x, y,
                            size, pressure);
                }
            }
            ResearchLogger.latinKeyboardView_processMotionEvent(me, action, eventTime, index, id,
                    x, y);
        }

        if (mKeyTimerHandler.isInKeyRepeat()) {
@@ -773,13 +767,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                            + pointerSize + "," + pointerPressure);
                }
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    if (ResearchLogger.sIsLogging) {
                        // TODO: earlier comment about redundant calculations applies here too
                        final float pointerSize = me.getSize(i);
                        final float pointerPressure = me.getPressure(i);
                        ResearchLogger.getInstance().logMotionEvent(action, eventTime, pointerId,
                                px, py, pointerSize, pointerPressure);
                    }
                    ResearchLogger.latinKeyboardView_processMotionEvent(me, action, eventTime,
                            i, pointerId, px, py);
                }
            }
        } else {
+23 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.widget.TextView;

import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.ResearchLogger;
import com.android.inputmethod.latin.define.ProductionFlag;

import java.util.ArrayList;

@@ -235,6 +237,10 @@ public class PointerTracker {
                    + " ignoreModifier=" + ignoreModifierKey
                    + " enabled=" + key.isEnabled());
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.pointerTracker_callListenerOnPressAndCheckKeyboardLayoutChange(key,
                    ignoreModifierKey);
        }
        if (ignoreModifierKey) {
            return false;
        }
@@ -259,6 +265,10 @@ public class PointerTracker {
                    + " ignoreModifier=" + ignoreModifierKey + " altersCode=" + altersCode
                    + " enabled=" + key.isEnabled());
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.pointerTracker_callListenerOnCodeInput(key, x, y, ignoreModifierKey,
                    altersCode, code);
        }
        if (ignoreModifierKey) {
            return;
        }
@@ -284,6 +294,10 @@ public class PointerTracker {
                    + " sliding=" + withSliding + " ignoreModifier=" + ignoreModifierKey
                    + " enabled="+ key.isEnabled());
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.pointerTracker_callListenerOnRelease(key, primaryCode, withSliding,
                    ignoreModifierKey);
        }
        if (ignoreModifierKey) {
            return;
        }
@@ -295,6 +309,9 @@ public class PointerTracker {
    private void callListenerOnCancelInput() {
        if (DEBUG_LISTENER)
            Log.d(TAG, "onCancelInput");
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.pointerTracker_callListenerOnCancelInput();
        }
        mListener.onCancelInput();
    }

@@ -479,6 +496,9 @@ public class PointerTracker {
                if (DEBUG_MODE)
                    Log.w(TAG, "onDownEvent: ignore potential noise: time=" + deltaT
                            + " distance=" + distanceSquared);
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    ResearchLogger.pointerTracker_onDownEvent(deltaT, distanceSquared);
                }
                mKeyAlreadyProcessed = true;
                return;
            }
@@ -583,6 +603,9 @@ public class PointerTracker {
                        if (DEBUG_MODE)
                            Log.w(TAG, String.format("onMoveEvent: sudden move is translated to "
                                    + "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
                        if (ProductionFlag.IS_EXPERIMENTAL) {
                            ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY);
                        }
                        onUpEventInternal(lastX, lastY, eventTime);
                        onDownEventInternal(x, y, eventTime);
                    } else {
+5 −0
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.view.MotionEvent;

import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResearchLogger;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.define.ProductionFlag;

public class SuddenJumpingTouchEventHandler {
    private static final String TAG = SuddenJumpingTouchEventHandler.class.getSimpleName();
@@ -141,6 +143,9 @@ public class SuddenJumpingTouchEventHandler {
        if (handleSuddenJumping(me)) {
            if (DEBUG_MODE)
                Log.w(TAG, "onTouchEvent: ignore sudden jump " + me);
            if (ProductionFlag.IS_EXPERIMENTAL) {
                ResearchLogger.suddenJumpingTouchEventHandler_onTouchEvent(me);
            }
            return true;
        }
        return mView.processMotionEvent(me);
+12 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ package com.android.inputmethod.keyboard.internal;

import android.util.Log;

import com.android.inputmethod.latin.ResearchLogger;
import com.android.inputmethod.latin.define.ProductionFlag;

public class AlphabetShiftState {
    private static final String TAG = AlphabetShiftState.class.getSimpleName();
    private static final boolean DEBUG = false;
@@ -59,6 +62,9 @@ public class AlphabetShiftState {
        }
        if (DEBUG)
            Log.d(TAG, "setShifted(" + newShiftState + "): " + toString(oldState) + " > " + this);
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.alphabetShiftState_setShifted(newShiftState, oldState, this);
        }
    }

    public void setShiftLocked(boolean newShiftLockState) {
@@ -78,6 +84,9 @@ public class AlphabetShiftState {
        if (DEBUG)
            Log.d(TAG, "setShiftLocked(" + newShiftLockState + "): " + toString(oldState)
                    + " > " + this);
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.alphabetShiftState_setShiftLocked(newShiftLockState, oldState, this);
        }
    }

    public void setAutomaticShifted() {
@@ -85,6 +94,9 @@ public class AlphabetShiftState {
        mState = AUTOMATIC_SHIFTED;
        if (DEBUG)
            Log.d(TAG, "setAutomaticShifted: " + toString(oldState) + " > " + this);
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.alphabetShiftState_setAutomaticShifted(oldState, this);
        }
    }

    public boolean isShiftedOrShiftLocked() {
+45 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.text.TextUtils;
import android.util.Log;

import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.ResearchLogger;
import com.android.inputmethod.latin.define.ProductionFlag;

/**
 * Keyboard state machine.
@@ -139,6 +141,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onSaveKeyboardState: saved=" + state + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onSaveKeyboardState(this, state.toString());
        }
    }

    private void onRestoreKeyboardState() {
@@ -146,6 +151,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onRestoreKeyboardState: saved=" + state + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onRestoreKeyboardState(this, state.toString());
        }
        if (!state.mIsValid || state.mIsAlphabetMode) {
            setAlphabetKeyboard();
        } else {
@@ -178,6 +186,9 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode) + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_setShifted(this, shiftModeToString(shiftMode));
        }
        if (!mIsAlphabetMode) return;
        final int prevShiftMode;
        if (mAlphabetShiftState.isAutomaticShifted()) {
@@ -217,6 +228,9 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "setShiftLocked: shiftLocked=" + shiftLocked + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_setShiftLocked(this, shiftLocked);
        }
        if (!mIsAlphabetMode) return;
        if (shiftLocked && (!mAlphabetShiftState.isShiftLocked()
                || mAlphabetShiftState.isShiftLockShifted())) {
@@ -232,6 +246,9 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "toggleAlphabetAndSymbols: " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_toggleAlphabetAndSymbols(this);
        }
        if (mIsAlphabetMode) {
            mPrevMainKeyboardWasShiftLocked = mAlphabetShiftState.isShiftLocked();
            if (mPrevSymbolsKeyboardWasShifted) {
@@ -262,6 +279,10 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "setAlphabetKeyboard");
        }

        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_setAlphabetKeyboard();
        }
        mSwitchActions.setAlphabetKeyboard();
        mIsAlphabetMode = true;
        mIsSymbolShifted = false;
@@ -273,6 +294,9 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "setSymbolsKeyboard");
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_setSymbolsKeyboard();
        }
        mSwitchActions.setSymbolsKeyboard();
        mIsAlphabetMode = false;
        mIsSymbolShifted = false;
@@ -285,6 +309,9 @@ public class KeyboardState {
        if (DEBUG_ACTION) {
            Log.d(TAG, "setSymbolsShiftedKeyboard");
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_setSymbolsShiftedKeyboard();
        }
        mSwitchActions.setSymbolsShiftedKeyboard();
        mIsAlphabetMode = false;
        mIsSymbolShifted = true;
@@ -297,6 +324,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onPressKey: code=" + Keyboard.printableCode(code) + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onPressKey(code, this);
        }
        if (code == Keyboard.CODE_SHIFT) {
            onPressShift();
        } else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
@@ -314,6 +344,9 @@ public class KeyboardState {
            Log.d(TAG, "onReleaseKey: code=" + Keyboard.printableCode(code)
                    + " sliding=" + withSliding + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onReleaseKey(this, code, withSliding);
        }
        if (code == Keyboard.CODE_SHIFT) {
            onReleaseShift(withSliding);
        } else if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
@@ -345,6 +378,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onLongPressTimeout: code=" + Keyboard.printableCode(code) + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onLongPressTimeout(code, this);
        }
        if (mIsAlphabetMode && code == Keyboard.CODE_SHIFT) {
            if (mAlphabetShiftState.isShiftLocked()) {
                setShiftLocked(false);
@@ -363,6 +399,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onUpdateShiftState(this, autoCaps);
        }
        updateAlphabetShiftState(autoCaps);
    }

@@ -481,6 +520,9 @@ public class KeyboardState {
        if (DEBUG_EVENT) {
            Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onCancelInput(isSinglePointer, this);
        }
        // Switch back to the previous keyboard mode if the user cancels sliding input.
        if (isSinglePointer) {
            if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
@@ -512,6 +554,9 @@ public class KeyboardState {
                    + " single=" + isSinglePointer
                    + " autoCaps=" + autoCaps + " " + this);
        }
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.keyboardState_onCodeInput(code, isSinglePointer, autoCaps, this);
        }

        switch (mSwitchState) {
        case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL:
Loading