From 328c71952d7004f9307424c4d36ffc348f78d641 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Thu, 4 Aug 2011 16:27:52 -0700 Subject: Add eclipse version to usage stat ping. Change-Id: I14dba0dd7cb900c2e700e4da055aee7bb7d1f9cd --- .../src/com/android/sdkstats/SdkStatsService.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'sdkstats') diff --git a/sdkstats/src/com/android/sdkstats/SdkStatsService.java b/sdkstats/src/com/android/sdkstats/SdkStatsService.java index f750413..1e2b418 100644 --- a/sdkstats/src/com/android/sdkstats/SdkStatsService.java +++ b/sdkstats/src/com/android/sdkstats/SdkStatsService.java @@ -115,7 +115,8 @@ public class SdkStatsService { * @param display an optional {@link Display} object to use, or null, if a new one should be * created. */ - public static void ping(final String app, final String version, final Display display) { + public static void ping(final String app, final String version, final String eclipseVersion, + final Display display) { // Unique, randomly assigned ID for this installation. PreferenceStore prefs = getPreferenceStore(); if (prefs != null) { @@ -125,9 +126,9 @@ public class SdkStatsService { // ask the user whether he/she wants to opt-out. // This will call doPing in the Display thread after the dialog closes. - getUserPermissionAndPing(app, version, prefs, display); + getUserPermissionAndPing(app, version, eclipseVersion, prefs, display); } else { - doPing(app, version, prefs); + doPing(app, version, eclipseVersion, prefs); } } } @@ -188,9 +189,11 @@ public class SdkStatsService { * Pings the usage stats server, as long as the prefs contain the opt-in boolean * @param app name to report in the ping * @param version to report in the ping + * @param eclipseVersion optional version of eclipse. * @param prefs the preference store where the opt-in value and ping times are store */ - private static void doPing(final String app, String version, PreferenceStore prefs) { + private static void doPing(final String app, String version, final String eclipseVersion, + PreferenceStore prefs) { // Validate the application and version input. final String normalVersion = normalizeVersion(app, version); @@ -224,7 +227,7 @@ public class SdkStatsService { @Override public void run() { try { - actuallySendPing(app, normalVersion, id); + actuallySendPing(app, normalVersion, eclipseVersion, id); } catch (IOException e) { e.printStackTrace(); } @@ -238,11 +241,12 @@ public class SdkStatsService { * * @param app name to report in the ping * @param version to report in the ping (dotted numbers, no more than four) + * @param eclipseVersion optional version of eclipse. * @param id of the local installation * @throws IOException if the ping failed */ @SuppressWarnings("deprecation") - private static void actuallySendPing(String app, String version, long id) + private static void actuallySendPing(String app, String version, String eclipseVersion, long id) throws IOException { // Detect and report the host OS. String os = System.getProperty("os.name"); //$NON-NLS-1$ @@ -274,7 +278,9 @@ public class SdkStatsService { "/service/update?as=androidsdk_" + app + //$NON-NLS-1$ "&id=" + Long.toHexString(id) + //$NON-NLS-1$ "&version=" + version + //$NON-NLS-1$ - "&os=" + os); //$NON-NLS-1$ + "&os=" + os + //$NON-NLS-1$ + (eclipseVersion != null ? + "&eclipse=" + eclipseVersion : "")); //$NON-NLS-1$ //$NON-NLS-2$ // Discard the actual response, but make sure it reads OK HttpURLConnection conn = (HttpURLConnection) url.openConnection(); @@ -308,10 +314,10 @@ public class SdkStatsService { /** * Prompt the user for whether they want to opt out of reporting, and then calls - * {@link #doPing(String, String, PreferenceStore)} + * {@link #doPing(String, String, String, PreferenceStore)} */ private static void getUserPermissionAndPing(final String app, final String version, - final PreferenceStore prefs, Display display) { + final String eclipseVersion, final PreferenceStore prefs, Display display) { boolean dispose = false; if (display == null) { display = new Display(); @@ -396,7 +402,7 @@ public class SdkStatsService { prefs.setValue(PING_OPT_IN, permission[0]); try { prefs.save(); - doPing(app, version, prefs); + doPing(app, version, eclipseVersion, prefs); } catch (IOException ioe) { } @@ -452,7 +458,7 @@ public class SdkStatsService { * @return normalized dotted quad version */ private static String normalizeVersion(String app, String version) { - // Application name must contain only word characters (no punctuaation) + // Application name must contain only word characters (no punctuation) if (!app.matches("\\w+")) { throw new IllegalArgumentException("Bad app name: " + app); } -- cgit v1.1