From 0c44ff52ccfbafa1bfa5dbd49be773dd8e922678 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 25 Sep 2009 14:52:55 -0700 Subject: Sync DDMS/Traceview/Android version on the repository source. All apps now read source.properties located in SDK/tools to know which version they. This is used in about box display and in ping usage. Change-Id: I6620c3eb703c32bfcdfd96e6a27bffc7a123b974 --- .../src/com/android/traceview/MainWindow.java | 48 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'traceview/src') diff --git a/traceview/src/com/android/traceview/MainWindow.java b/traceview/src/com/android/traceview/MainWindow.java index 5800f81..00fcc8b 100644 --- a/traceview/src/com/android/traceview/MainWindow.java +++ b/traceview/src/com/android/traceview/MainWindow.java @@ -30,14 +30,16 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import java.io.File; -import java.io.IOException; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; import java.nio.channels.FileChannel; import java.util.HashMap; +import java.util.Properties; public class MainWindow extends ApplicationWindow { - + private final static String PING_NAME = "Traceview"; private final static String PING_VERSION = "1.0"; @@ -99,10 +101,10 @@ public class MainWindow extends ApplicationWindow { /** * Convert the old two-file format into the current concatenated one. - * + * * @param base Base path of the two files, i.e. base.key and base.data * @return Path to a temporary file that will be deleted on exit. - * @throws IOException + * @throws IOException */ private static String makeTempTraceFile(String base) throws IOException { // Make a temporary file that will go away on exit and prepare to @@ -127,13 +129,45 @@ public class MainWindow extends ApplicationWindow { // Return the path of the temp file. return temp.getPath(); } - + + /** + * Returns the tools revision number. + */ + private static String getRevision() { + Properties p = new Properties(); + try{ + String toolsdir = System.getProperty("com.android.traceview.toolsdir"); //$NON-NLS-1$ + File sourceProp; + if (toolsdir == null || toolsdir.length() == 0) { + sourceProp = new File("source.properties"); //$NON-NLS-1$ + } else { + sourceProp = new File(toolsdir, "source.properties"); //$NON-NLS-1$ + } + p.load(new FileInputStream(sourceProp)); + String revision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ + if (revision != null && revision.length() > 0) { + return revision; + } + } catch (FileNotFoundException e) { + // couldn't find the file? don't ping. + } catch (IOException e) { + // couldn't find the file? don't ping. + } + + return null; + } + + public static void main(String[] args) { TraceReader reader = null; boolean regression = false; - + // ping the usage server - SdkStatsService.ping(PING_NAME, PING_VERSION, null); + + String revision = getRevision(); + if (revision != null) { + SdkStatsService.ping(PING_NAME, revision, null); + } // Process command line arguments int argc = 0; -- cgit v1.1