Parse args, start threads.
// In order to have the AWT/SWT bridge work on Leopard, we do this little hack.
String os = System.getProperty("os.name"); //$NON-NLS-1$
if (os.startsWith("Mac OS")) { //$NON-NLS-1$
RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
System.setProperty(
"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
PrefsDialog.init();
Log.d("ddms", "Initializing");
// the "ping" argument means to check in with the server and exit
// the application name and version number must also be supplied
if (args.length >= 3 && args[0].equals("ping")) {
SdkStatsService.ping(args[1], args[2]);
return;
} else if (args.length > 0) {
Log.e("ddms", "Unknown argument: " + args[0]);
System.exit(1);
}
// ddms itself is wanted: send a ping for ourselves
SdkStatsService.ping("ddms", VERSION); //$NON-NLS-1$
DebugPortManager.setProvider(DebugPortProvider.getInstance());
// create the three main threads
UIThread ui = UIThread.getInstance();
try {
ui.runUI();
} 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);