diff --git a/tools/ddms/app/src/com/android/ddms/AboutDialog.java b/tools/ddms/app/src/com/android/ddms/AboutDialog.java index 2910e5ee9..e946aee7e 100644 --- a/tools/ddms/app/src/com/android/ddms/AboutDialog.java +++ b/tools/ddms/app/src/com/android/ddms/AboutDialog.java @@ -124,7 +124,11 @@ public class AboutDialog extends Dialog { // Text lines label = new Label(textArea, SWT.NONE); - label.setText("Dalvik Debug Monitor v" + Main.VERSION); + if (Main.sRevision != null && Main.sRevision.length() > 0) { + label.setText("Dalvik Debug Monitor Revision " + Main.sRevision); + } else { + label.setText("Dalvik Debug Monitor"); + } label = new Label(textArea, SWT.NONE); label.setText("Copyright 2007, The Android Open Source Project"); label = new Label(textArea, SWT.NONE); diff --git a/tools/ddms/app/src/com/android/ddms/Main.java b/tools/ddms/app/src/com/android/ddms/Main.java index d545ed9e2..050519f51 100644 --- a/tools/ddms/app/src/com/android/ddms/Main.java +++ b/tools/ddms/app/src/com/android/ddms/Main.java @@ -21,10 +21,15 @@ import com.android.ddmlib.DebugPortManager; import com.android.ddmlib.Log; import com.android.sdkstats.SdkStatsService; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; +import java.util.Properties; /** @@ -32,8 +37,7 @@ import java.lang.management.RuntimeMXBean; */ public class Main { - /** User visible version number. */ - public static final String VERSION = "0.8.1"; + public static String sRevision; public Main() { } @@ -67,7 +71,7 @@ public class Main { "JAVA_STARTED_ON_FIRST_THREAD_" + (rt.getName().split("@"))[0], //$NON-NLS-1$ "1"); //$NON-NLS-1$ } - + Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler()); // load prefs and init the default values @@ -85,8 +89,12 @@ public class Main { System.exit(1); } - // ddms itself is wanted: send a ping for ourselves - SdkStatsService.ping("ddms", VERSION, null); //$NON-NLS-1$ + // get the ddms parent folder location + String ddmsParentLocation = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$ + + // we're past the point where ddms can be called just to send a ping, so we can + // ping for ddms itself. + ping(ddmsParentLocation); DebugPortManager.setProvider(DebugPortProvider.getInstance()); @@ -94,17 +102,38 @@ public class Main { UIThread ui = UIThread.getInstance(); try { - ui.runUI(); + ui.runUI(ddmsParentLocation); } finally { PrefsDialog.save(); - + AndroidDebugBridge.terminate(); } Log.d("ddms", "Bye"); - + // this is kinda bad, but on MacOS the shutdown doesn't seem to finish because of // a thread called AWT-Shutdown. This will help while I track this down. System.exit(0); } + + public static void ping(String ddmsParentLocation) { + Properties p = new Properties(); + try{ + File sourceProp; + if (ddmsParentLocation != null && ddmsParentLocation.length() > 0) { + sourceProp = new File(ddmsParentLocation, "source.properties"); //$NON-NLS-1$ + } else { + sourceProp = new File("source.properties"); //$NON-NLS-1$ + } + p.load(new FileInputStream(sourceProp)); + sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$ + if (sRevision != null && sRevision.length() > 0) { + SdkStatsService.ping("ddms", sRevision, null); //$NON-NLS-1$ + } + } catch (FileNotFoundException e) { + // couldn't find the file? don't ping. + } catch (IOException e) { + // couldn't find the file? don't ping. + } + } } diff --git a/tools/ddms/app/src/com/android/ddms/UIThread.java b/tools/ddms/app/src/com/android/ddms/UIThread.java index 49d07b099..c98b3f144 100644 --- a/tools/ddms/app/src/com/android/ddms/UIThread.java +++ b/tools/ddms/app/src/com/android/ddms/UIThread.java @@ -404,8 +404,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener { /** * Create SWT objects and drive the user interface event loop. + * @param location location of the folder that contains ddms. */ - public void runUI() { + public void runUI(String ddmsParentLocation) { Display.setAppName("ddms"); mDisplay = new Display(); final Shell shell = new Shell(mDisplay); @@ -445,9 +446,9 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener { ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell)); // [try to] ensure ADB is running - String adbLocation = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$ - if (adbLocation != null && adbLocation.length() != 0) { - adbLocation += File.separator + "adb"; //$NON-NLS-1$ + String adbLocation; + if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) { + adbLocation = ddmsParentLocation + File.separator + "adb"; //$NON-NLS-1$ } else { adbLocation = "adb"; //$NON-NLS-1$ } diff --git a/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java b/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java index 623659977..fa2870dcb 100644 --- a/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/tools/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -42,10 +42,10 @@ import java.util.Map; /** * Main class for the 'android' application. */ -class Main { +public class Main { /** Java property that defines the location of the sdk/tools directory. */ - private final static String TOOLSDIR = "com.android.sdkmanager.toolsdir"; + public final static String TOOLSDIR = "com.android.sdkmanager.toolsdir"; /** Java property that defines the working directory. On Windows the current working directory * is actually the tools dir, in which case this is used to get the original CWD. */ private final static String WORKDIR = "com.android.sdkmanager.workdir"; diff --git a/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java b/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java index 49aad2992..742a065f3 100755 --- a/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java +++ b/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java @@ -17,16 +17,20 @@ package com.android.sdkmanager.internal.repository; +import com.android.sdkmanager.*; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -/* - * TODO list - * - Change version to be a constant pulled from somewhere. - */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; public class AboutPage extends Composite { @@ -45,11 +49,21 @@ public class AboutPage extends Composite { } private void createContents(Composite parent) { - parent.setLayout(new GridLayout(1, false)); + parent.setLayout(new GridLayout(2, false)); + + Label logo = new Label(parent, SWT.NONE); + InputStream imageStream = this.getClass().getResourceAsStream("logo.png"); + + if (imageStream != null) { + Image img = new Image(parent.getShell().getDisplay(), imageStream); + logo.setImage(img); + } mLabel = new Label(parent, SWT.NONE); - mLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1)); - mLabel.setText("Android SDK Updater.\n\nVersion 0.1.\n\nCopyright (C) 2009 The Android Open Source Project."); + mLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); + mLabel.setText(String.format( + "Android SDK Updater.\nRevision %1$s\nCopyright (C) 2009 The Android Open Source Project.", + getRevision())); } @Override @@ -69,4 +83,28 @@ public class AboutPage extends Composite { // End of hiding from SWT Designer //$hide<<$ + + private String getRevision() { + Properties p = new Properties(); + try{ + String toolsdir = System.getProperty(Main.TOOLSDIR); + 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) { + 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 "?"; + } } diff --git a/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png b/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png new file mode 100644 index 000000000..0f1670d7f Binary files /dev/null and b/tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png differ diff --git a/tools/traceview/etc/traceview b/tools/traceview/etc/traceview index 8f52e7742..3d1771fbc 100755 --- a/tools/traceview/etc/traceview +++ b/tools/traceview/etc/traceview @@ -14,27 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# This script assumes that the path to this script is something like: -# -# /somepath/outdir/archdir/hostdir/bindir/traceview -# -# where "somepath" is some pathname (like "/work/android/device/") -# "outdir" is a subdirectory (like "out") -# "archdir" is a subdirectory (like "linux-x86-release") -# "hostdir" is a subdirectory (like "host") -# "bindir" is a subdirectory (like "bin") -# -# e.g. /work/android/device/out/linux-x86-release/host/bin/traceview -# -# and that the following directories also exist: -# -# /somepath/outdir/archdir/hostdir/lib/ -# /somepath/outdir/archdir/hostdir/framework/ -# -# where: -# "lib", and "framework" are at the same level as "bindir", -# and are the literal names. - # Set up prog to be the path of this script, including following symlinks, # and set up progdir to be the fully-qualified pathname of its directory. prog="$0" @@ -118,4 +97,4 @@ else exit 1 fi -exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -jar "$jarpath" "$@" +exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -Dcom.android.traceview.toolsdir="$progdir" -jar "$jarpath" "$@" diff --git a/tools/traceview/etc/traceview.bat b/tools/traceview/etc/traceview.bat index 2da8a3b6b..02fbe8561 100755 --- a/tools/traceview/etc/traceview.bat +++ b/tools/traceview/etc/traceview.bat @@ -55,4 +55,4 @@ if exist %swt_path% goto SetPath :SetPath set javaextdirs=%swt_path%;%frameworkdir% -call java -Djava.ext.dirs=%javaextdirs% -jar %jarpath% %* +call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %* diff --git a/tools/traceview/src/com/android/traceview/MainWindow.java b/tools/traceview/src/com/android/traceview/MainWindow.java index 5800f81cf..00fcc8b79 100644 --- a/tools/traceview/src/com/android/traceview/MainWindow.java +++ b/tools/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;