From 0f61aa6470c2ac6c8cae6c356bb7ce658b71b5ac Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 25 Sep 2009 14:52:55 -0700 Subject: [PATCH] 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 --- .../ddms/app/src/com/android/ddms/AboutDialog.java | 6 ++- tools/ddms/app/src/com/android/ddms/Main.java | 45 ++++++++++++++---- tools/ddms/app/src/com/android/ddms/UIThread.java | 9 ++-- .../app/src/com/android/sdkmanager/Main.java | 4 +- .../sdkmanager/internal/repository/AboutPage.java | 52 ++++++++++++++++++--- .../sdkmanager/internal/repository/logo.png | Bin 0 -> 2381 bytes tools/traceview/etc/traceview | 23 +-------- tools/traceview/etc/traceview.bat | 2 +- .../src/com/android/traceview/MainWindow.java | 48 ++++++++++++++++--- 9 files changed, 137 insertions(+), 52 deletions(-) create mode 100644 tools/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png diff --git a/tools/ddms/app/src/com/android/ddms/AboutDialog.java b/tools/ddms/app/src/com/android/ddms/AboutDialog.java index 2910e5ee..e946aee7 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 d545ed9e..050519f5 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 49d07b09..c98b3f14 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 62365997..fa2870dc 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 49aad299..742a065f 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 0000000000000000000000000000000000000000..0f1670d7f66024e689442e8cd1829863a0ca3fef GIT binary patch literal 2381 zcmV-T39|NyP)WFvb`|2qqeZ_=g5G@$rv@m=FOC zYJ$Af;1#U$Xt6Ka>y=!4*So$%#+lvO-PuQ>E#Yo^oq-{@vk!JZ`HjWG13c2f0*=A_M30bY`XyILDFAhqJ-gUn1qm|dgzvM@U zJ6zh?YLJc1>wKX9KKJtQ^7*g+NEY`nYZsu$a%7$1le@3<9P)MdpUVe?tiejavHU}U zkK|Rw-ny>x!i`;d*-PJK(j!0{b@}h^uXnWc9Pvel{>hPtxN}2@8{)_!ZA>0T;LcnS zExqrlu0@5LcG?BDU80V46mp>LLHP z@g6KMc^Ulq_0kZ%Va=g$eN^w6bDj2}Up&{cyDBnFSfo6Vf4RPI?;cBvb8$d zpqGXQ8a+mivPEKU5b2^0tk6VbPE@u^{x=j2c#>WJNH%DHbg0dxQwjwT(o@6?KK+Aq zlEH;}ik9=UfczaC31wKM@6$@7e@fv0Me89uQynx-tJktH>y!nMFWvzt^A>;S61o;np0*!O`q*V5mcLP8gfR z2a|KOTIOzo@rJ075$7P~a~b(J>QMHfj+Gg}J4y@YZ+$(nj%zL!B7KHODkKHkKa@uNdG*j7`o01MYW7o_x43M>KP3?rmP;xWKg+Ko}$j`1~YcVX$TgOVINOO874M$ws ze*5NiExgT5OC{+rIV=6TnGP4^S5NK@W__THL;cnA#NBD$pd6vTs#oi|%YnF8;{pHyj-9v!7ioJ01 z^4rkfNAr=l%sxXYK%tb>Xl$OYWU;yT5X^S^p{(#3X@~+E7-{FEWdkgm|BAE}8ElhF zsf>>^BOkKT^PsVFAB#3*E2eF>^L}U#ABUqCw!o8B2hDeWtY?x_9<(KU`AR$bPO6|K zD`fYBTIWNhuR&ACSMW#2J~`^3F)#yEU9P_ zy@VFro0SVsPs<^ZLZvP!2u5U(6zsVc7p(HX2IYnIFnTkts>RyMPo?mVH%|(#z+Iyz zEXr|M3ub2)4X1(Q7Of)EZ3;arLmGW$5O?jfnCUFV>ze(_*J+P{FZ?HNE+I>;snHo zJ9JDn?X{>?=vZRSijk@Cue1Op;5nhKGDF(h!pERHdRDd2qZhUk3vSarszO%fQEVpvA?v2Qu^x&IPi>6xxt9HGXbjgXW7xcs#_pl-s7H(`;+W3ScxI#{64NNPwP@MJqq<6cs6O@kI4z zdOE|~Xfqn;#%P?|3yZ!BZ-{Jd&2|OdOv1L#;yHC)O5C={x9J*KzwH@V 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; -- 2.11.0