Hush a bunch of stderr debugging messages.

This commit is contained in:
jdf
2010-03-08 22:19:03 +00:00
parent aa2a23e707
commit e299769c0c
5 changed files with 32 additions and 44 deletions
@@ -14,17 +14,9 @@ import java.util.concurrent.FutureTask;
import processing.app.tools.android.EmulatorController.State;
/**
* <p>An AndroidEnvironment is an object that periodically polls for the existence
* of running Android devices, both emulated and hardware. You can register to
* be notified when devices are added to or removed from the environment. You
* can also ask for an emulator or a hardware device specifically.
*
* <pre> AndroidEnvironment env = new AndroidEnvironment();
* env.addPropertyChangeListener(...);
* env.initialize();
*
* AndroidDevice n1 = env.getHardware();</pre>
*
* <pre> AndroidEnvironment env = AndroidEnvironment.getInstance();
* AndroidDevice n1 = env.getHardware();
* AndroidDevice emu = env.getEmulator();</pre>
* @author Jonathan Feinberg &lt;jdf@pobox.com&gt;
*
*/
@@ -40,11 +32,11 @@ class AndroidEnvironment {
.newSingleThreadExecutor();
public static void killAdbServer() {
System.err.print("Shutting down any existing adb server...");
// System.err.print("Shutting down any existing adb server...");
System.err.flush();
try {
AndroidSDK.runADB("kill-server");
System.err.println("OK.");
// System.err.println("OK.");
} catch (final Exception e) {
System.err.println("failed.");
System.err.println();
@@ -53,7 +45,7 @@ class AndroidEnvironment {
}
private AndroidEnvironment() {
System.err.println("Starting up AndroidEnvironment");
// System.err.println("Starting up AndroidEnvironment");
killAdbServer();
Runtime.getRuntime().addShutdownHook(
new Thread("AndroidEnvironment Shutdown") {
@@ -65,7 +57,7 @@ class AndroidEnvironment {
}
private void shutdown() {
System.err.println("Shutting down AndroidEnvironment");
// System.err.println("Shutting down AndroidEnvironment");
for (final AndroidDevice device : new ArrayList<AndroidDevice>(devices
.values())) {
device.shutdown();
@@ -107,17 +99,17 @@ class AndroidEnvironment {
.println("That's weird. The emulator process seems to be running, but I don't know about it.");
}
while (!Thread.currentThread().isInterrupted()) {
System.err.println("AndroidEnvironment: looking for emulator in loop.");
System.err.println("AndroidEnvironment: emulatorcontroller state is "
+ emuController.getState());
// System.err.println("AndroidEnvironment: looking for emulator in loop.");
// System.err.println("AndroidEnvironment: emulatorcontroller state is "
// + emuController.getState());
if (emuController.getState() == State.NOT_RUNNING) {
System.err.println("Ouch. Emulator got killed, I think.");
return null;
}
emu = find(true);
if (emu != null) {
System.err.println("AndroidEnvironment: returning " + emu.getId()
+ " from loop.");
// System.err.println("AndroidEnvironment: returning " + emu.getId()
// + " from loop.");
return emu;
}
try {
@@ -184,17 +176,10 @@ class AndroidEnvironment {
addDevice(new AndroidDevice(this, deviceId));
}
}
synchronized (devices) {
for (final String deviceId : new ArrayList<String>(devices.keySet())) {
if (!activeDevices.contains(deviceId)) {
System.err.println("HEY THIS SHOULDN'T HAPPEN");
devices.get(deviceId).shutdown();
}
}
}
}
private void addDevice(final AndroidDevice device) {
// System.err.println("AndroidEnvironment: adding " + device.getId());
try {
device.initialize();
if (devices.put(device.getId(), device) != null) {
@@ -207,6 +192,7 @@ class AndroidEnvironment {
}
void deviceRemoved(final AndroidDevice device) {
// System.err.println("AndroidEnvironment: removing " + device.getId());
if (devices.remove(device.getId()) == null) {
throw new IllegalStateException("I didn't know about device "
+ device.getId() + "!");
@@ -23,7 +23,7 @@ class EmulatorController {
private void setState(final State state) {
this.state = state;
System.err.println("Emulator state: " + state);
// System.err.println("Emulator state: " + state);
}
/**
@@ -43,7 +43,7 @@ class EmulatorController {
Preferences.set("android.emulator.port", portString);
}
System.err.println("EmulatorController: Launching emulator");
// System.err.println("EmulatorController: Launching emulator");
// See http://developer.android.com/guide/developing/tools/emulator.html
final Process p = Runtime.getRuntime().exec(
@@ -62,12 +62,12 @@ class EmulatorController {
new Thread(new Runnable() {
public void run() {
try {
System.err.println("EmulatorController: Waiting for boot.");
// System.err.println("EmulatorController: Waiting for boot.");
while (state == State.WAITING_FOR_BOOT) {
Thread.sleep(2000);
for (final String device : AndroidEnvironment.listDevices()) {
if (device.contains("emulator")) {
System.err.println("EmulatorController: Emulator booted.");
// System.err.println("EmulatorController: Emulator booted.");
setState(State.RUNNING);
return;
}
@@ -75,7 +75,7 @@ class EmulatorController {
}
System.err.println("EmulatorController: Emulator never booted.");
} catch (final Exception e) {
System.err.println("While waiting for emulator to launch " + e);
System.err.println("While waiting for emulator to boot " + e);
p.destroy();
} finally {
latch.countDown();
@@ -86,11 +86,12 @@ class EmulatorController {
public void run() {
try {
try {
final int result = p.waitFor();
System.err
.println("Emulator process exited "
+ ((result == 0) ? "normally" : " with status " + result)
+ ".");
p.waitFor();
// final int result = p.waitFor();
// System.err
// .println("Emulator process exited "
// + ((result == 0) ? "normally" : " with status " + result)
// + ".");
} catch (final InterruptedException e) {
System.err.println("Emulator was interrupted.");
} finally {
@@ -59,8 +59,8 @@ class ProcessHelper {
final long startTime = System.currentTimeMillis();
final String prettyCommand = toString();
System.err.println("ProcessHelper: >>>>> " + Thread.currentThread().getId()
+ " " + prettyCommand);
// System.err.println("ProcessHelper: >>>>> " + Thread.currentThread().getId()
// + " " + prettyCommand);
final Process process = Runtime.getRuntime().exec(cmd);
ProcessRegistry.watch(process);
try {
@@ -69,9 +69,9 @@ class ProcessHelper {
try {
final int result = process.waitFor();
final long time = System.currentTimeMillis() - startTime;
System.err.println("ProcessHelper: <<<<< "
+ Thread.currentThread().getId() + " " + cmd[0] + " (" + time
+ "ms)");
// System.err.println("ProcessHelper: <<<<< "
// + Thread.currentThread().getId() + " " + cmd[0] + " (" + time
// + "ms)");
return new ProcessResult(prettyCommand, result, outWriter.toString(),
errWriter.toString(), time);
} catch (final InterruptedException e) {
@@ -15,7 +15,7 @@ public class ProcessRegistry {
synchronized (REGISTRY) {
for (final Process p : REGISTRY) {
try {
System.err.println("Cleaning up rogue process " + p);
// System.err.println("Cleaning up rogue process " + p);
p.destroy();
} catch (final Exception drop) {
}
@@ -99,5 +99,6 @@ class StreamPump implements Runnable {
public void processLine(final String line) {
// noop
}
};
}