am 099dd3f2: Merge "Better release build reporting"

* commit '099dd3f277bcf43326b9e23642edf77a35b5dd94':
  Better release build reporting
main
Kurt Partridge 2013-04-10 15:55:20 -07:00 committed by Android Git Automerger
commit 3e1f652c2c
1 changed files with 21 additions and 4 deletions

View File

@ -81,6 +81,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.regex.Pattern;
/** /**
* Logs the use of the LatinIME keyboard. * Logs the use of the LatinIME keyboard.
@ -1065,7 +1066,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
new LogStatement("LatinImeOnStartInputViewInternal", false, false, "uuid", new LogStatement("LatinImeOnStartInputViewInternal", false, false, "uuid",
"packageName", "inputType", "imeOptions", "fieldId", "display", "model", "packageName", "inputType", "imeOptions", "fieldId", "display", "model",
"prefs", "versionCode", "versionName", "outputFormatVersion", "logEverything", "prefs", "versionCode", "versionName", "outputFormatVersion", "logEverything",
"isUsingDevelopmentOnlyDiagnosticsDebug"); "isDevTeamBuild");
public static void latinIME_onStartInputViewInternal(final EditorInfo editorInfo, public static void latinIME_onStartInputViewInternal(final EditorInfo editorInfo,
final SharedPreferences prefs) { final SharedPreferences prefs) {
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
@ -1087,13 +1088,29 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
Integer.toHexString(editorInfo.imeOptions), editorInfo.fieldId, Integer.toHexString(editorInfo.imeOptions), editorInfo.fieldId,
Build.DISPLAY, Build.MODEL, prefs, versionCode, versionName, Build.DISPLAY, Build.MODEL, prefs, versionCode, versionName,
OUTPUT_FORMAT_VERSION, IS_LOGGING_EVERYTHING, OUTPUT_FORMAT_VERSION, IS_LOGGING_EVERYTHING,
ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS_DEBUG); researchLogger.isDevTeamBuild());
} catch (NameNotFoundException e) { } catch (final NameNotFoundException e) {
e.printStackTrace(); 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. * Log a change in preferences.
* *