Merge change 21988 into donut
* changes: Add OS version to ping service (win/mac only)
This commit is contained in:
@@ -44,6 +44,8 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** Utility class to send "ping" usage reports to the server. */
|
||||
public class SdkStatsService {
|
||||
@@ -239,8 +241,16 @@ public class SdkStatsService {
|
||||
String os = System.getProperty("os.name"); // $NON-NLS-1$
|
||||
if (os.startsWith("Mac OS")) { // $NON-NLS-1$
|
||||
os = "mac"; // $NON-NLS-1$
|
||||
String osVers = getVersion();
|
||||
if (osVers != null) {
|
||||
os = os + "-" + osVers; // $NON-NLS-1$
|
||||
}
|
||||
} else if (os.startsWith("Windows")) { // $NON-NLS-1$
|
||||
os = "win"; // $NON-NLS-1$
|
||||
String osVers = getVersion();
|
||||
if (osVers != null) {
|
||||
os = os + "-" + osVers; // $NON-NLS-1$
|
||||
}
|
||||
} else if (os.startsWith("Linux")) { // $NON-NLS-1$
|
||||
os = "linux"; // $NON-NLS-1$
|
||||
} else {
|
||||
@@ -271,6 +281,24 @@ public class SdkStatsService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the os if it is defined as X.Y, or null otherwise.
|
||||
* <p/>
|
||||
* Example of returned versions can be found at http://lopica.sourceforge.net/os.html
|
||||
* <p/>
|
||||
* This method removes any exiting micro versions.
|
||||
*/
|
||||
private static String getVersion() {
|
||||
Pattern p = Pattern.compile("(\\d+)\\.(\\d+).*"); // $NON-NLS-1$
|
||||
String osVers = System.getProperty("os.version"); // $NON-NLS-1$
|
||||
Matcher m = p.matcher(osVers);
|
||||
if (m.matches()) {
|
||||
return m.group(1) + "." + m.group(2); // $NON-NLS-1$
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user for whether they want to opt out of reporting.
|
||||
* @return whether the user allows reporting (they do not opt out).
|
||||
|
||||
Reference in New Issue
Block a user