Try to address Mac problem with emulator launch

This commit is contained in:
jdf
2010-02-27 18:43:31 +00:00
parent 858ce64d17
commit b57bec0cf8
@@ -1,22 +1,9 @@
package processing.app.tools.android;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import processing.app.Preferences;
public class EmulatorController {
private static final ExecutorService threads = Executors
.newSingleThreadExecutor(new ThreadFactory() {
public Thread newThread(final Runnable r) {
final Thread t = new Thread(r);
t.setDaemon(true);
t.setName("EmulatorController " + t.getId());
return t;
}
});
class EmulatorController {
static void launch() throws IOException {
String portString = Preferences.get("android.emulator.port");
if (portString == null) {
@@ -39,21 +26,11 @@ public class EmulatorController {
final String[] cmd = new String[] {
"emulator", "-avd", AVD.ECLAIR.name, "-port", portString, "-netfast",
"-no-boot-anim" };
threads.execute(new Runnable() {
public void run() {
try {
System.err.println("Launching emulator");
final Process p = Runtime.getRuntime().exec(cmd);
// "emulator: ERROR: the user data image is used by another emulator. aborting"
// make sure that the streams are drained properly
p.getInputStream().close();
p.getErrorStream().close();
// new StreamPump(p.getInputStream()).addTarget(System.out).start();
// new StreamPump(p.getErrorStream()).addTarget(System.err).start();
} catch (final IOException e) {
e.printStackTrace(System.err);
}
}
});
System.err.println("Launching emulator");
final Process p = Runtime.getRuntime().exec(cmd);
// "emulator: ERROR: the user data image is used by another emulator. aborting"
// make sure that the streams are drained properly
new StreamPump(p.getInputStream()).addTarget(System.out).start();
new StreamPump(p.getErrorStream()).addTarget(System.err).start();
}
}