aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/research')
-rw-r--r--java/src/com/android/inputmethod/research/MotionEventReader.java3
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java25
2 files changed, 24 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/research/MotionEventReader.java b/java/src/com/android/inputmethod/research/MotionEventReader.java
index e1cc2da73..fbfd9b531 100644
--- a/java/src/com/android/inputmethod/research/MotionEventReader.java
+++ b/java/src/com/android/inputmethod/research/MotionEventReader.java
@@ -22,6 +22,7 @@ import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerProperties;
+import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.define.ProductionFlag;
import java.io.BufferedReader;
@@ -64,6 +65,7 @@ public class MotionEventReader {
return replayData;
}
+ @UsedForTesting
static class ReplayData {
final ArrayList<Integer> mActions = new ArrayList<Integer>();
final ArrayList<PointerProperties[]> mPointerPropertiesArrays
@@ -134,6 +136,7 @@ public class MotionEventReader {
* },
* </pre>
*/
+ @UsedForTesting
/* package for test */ void readLogStatement(final JsonReader jsonReader,
final ReplayData replayData) throws IOException {
String logStatementType = null;
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index e0bd37c1e..5aaced036 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -81,6 +81,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import java.util.regex.Pattern;
/**
* Logs the use of the LatinIME keyboard.
@@ -1065,7 +1066,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
new LogStatement("LatinImeOnStartInputViewInternal", false, false, "uuid",
"packageName", "inputType", "imeOptions", "fieldId", "display", "model",
"prefs", "versionCode", "versionName", "outputFormatVersion", "logEverything",
- "isUsingDevelopmentOnlyDiagnosticsDebug");
+ "isDevTeamBuild");
public static void latinIME_onStartInputViewInternal(final EditorInfo editorInfo,
final SharedPreferences prefs) {
final ResearchLogger researchLogger = getInstance();
@@ -1087,13 +1088,29 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
Integer.toHexString(editorInfo.imeOptions), editorInfo.fieldId,
Build.DISPLAY, Build.MODEL, prefs, versionCode, versionName,
OUTPUT_FORMAT_VERSION, IS_LOGGING_EVERYTHING,
- ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
+ researchLogger.isDevTeamBuild());
+ } catch (final NameNotFoundException e) {
+ Log.e(TAG, "NameNotFound", e);
}
}
}
+ // TODO: Update this heuristic pattern to something more reliable. Developer builds tend to
+ // have the developer name and year embedded.
+ private static final Pattern developerBuildRegex = Pattern.compile("[A-Za-z]\\.20[1-9]");
+ private boolean isDevTeamBuild() {
+ try {
+ final PackageInfo packageInfo;
+ packageInfo = mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(),
+ 0);
+ final String versionName = packageInfo.versionName;
+ return !(developerBuildRegex.matcher(versionName).find());
+ } catch (final NameNotFoundException e) {
+ Log.e(TAG, "Could not determine package name", e);
+ return false;
+ }
+ }
+
/**
* Log a change in preferences.
*