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

Commit b79064cb authored by Ken Wakasa's avatar Ken Wakasa Committed by Android (Google) Code Review
Browse files

Merge "Optimization: Start making use of ProductionFlag.IS_EXPERIMENTAL for ResearchLogger"

parents 1ebebebc c166697e
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -52,6 +52,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.define.ProductionFlag;

import java.util.Locale;
import java.util.WeakHashMap;
@@ -694,6 +695,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                        + size + "," + pressure);
            }
        }
        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
@@ -701,8 +703,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                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.getInstance().logMotionEvent(action, eventTime, id, x, y,
                            size, pressure);
                }
            }
        }

@@ -770,6 +773,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                            + pointerId + "," + px + "," + py + ","
                            + pointerSize + "," + pointerPressure);
                }
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    if (ResearchLogger.sIsLogging) {
                        // TODO: earlier comment about redundant calculations applies here too
                        final float pointerSize = me.getSize(i);
@@ -778,6 +782,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
                                px, py, pointerSize, pointerPressure);
                    }
                }
            }
        } else {
            final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
            tracker.processMotionEvent(action, x, y, eventTime, this);
+8 −3
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.suggestions.SuggestionsView;

import java.io.FileDescriptor;
@@ -439,7 +440,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        mPrefs = prefs;
        LatinImeLogger.init(this, prefs);
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.init(this, prefs);
        }
        LanguageSwitcherProxy.init(this, prefs);
        InputMethodManagerCompatWrapper.init(this);
        SubtypeSwitcher.init(this);
@@ -1264,9 +1267,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        }
        mLastKeyTime = when;

        if (ProductionFlag.IS_EXPERIMENTAL) {
            if (ResearchLogger.sIsLogging) {
                ResearchLogger.getInstance().logKeyEvent(primaryCode, x, y);
            }
        }

        final KeyboardSwitcher switcher = mKeyboardSwitcher;
        // The space state depends only on the last character pressed and its own previous
+0 −4
Original line number Diff line number Diff line
@@ -80,8 +80,4 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang

    public static void onPrintAllUsabilityStudyLogs() {
    }

    public static boolean isResearcherPackage(Context context) {
        return false;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ import java.util.Date;
 * This class logs operations on the IME keyboard, including what the user has typed.
 * Data is stored locally in a file in app-specific storage.
 *
 * This functionality is off by default.
 * This functionality is off by default. See {@link ProductionFlag.IS_EXPERIMENTAL}.
 */
public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String TAG = ResearchLogger.class.getSimpleName();
+3 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.VibratorCompatWrapper;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethodcommon.InputMethodSettingsActivity;

import java.util.Locale;
@@ -238,17 +239,16 @@ public class Settings extends InputMethodSettingsActivity
            textCorrectionGroup.removePreference(dictionaryLink);
        }

        final boolean isResearcherPackage = LatinImeLogger.isResearcherPackage(this);
        final boolean showUsabilityStudyModeOption =
                res.getBoolean(R.bool.config_enable_usability_study_mode_option)
                        || isResearcherPackage || ENABLE_EXPERIMENTAL_SETTINGS;
                        || ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS;
        final Preference usabilityStudyPref = findPreference(PREF_USABILITY_STUDY_MODE);
        if (!showUsabilityStudyModeOption) {
            if (usabilityStudyPref != null) {
                miscSettings.removePreference(usabilityStudyPref);
            }
        }
        if (isResearcherPackage) {
        if (ProductionFlag.IS_EXPERIMENTAL) {
            if (usabilityStudyPref instanceof CheckBoxPreference) {
                CheckBoxPreference checkbox = (CheckBoxPreference)usabilityStudyPref;
                checkbox.setChecked(prefs.getBoolean(PREF_USABILITY_STUDY_MODE, true));
Loading