aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdkuilib
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2012-06-02 14:54:18 -0700
committerRaphael Moll <ralf@android.com>2012-06-02 14:54:18 -0700
commitfaebce1cc09653321a12b8472fd02b79dad95c58 (patch)
treec69d1994d1a255cef04a51eb4349a236addc9f4c /sdkmanager/libs/sdkuilib
parent929e008c80c5f0d2cf875f44231634ced002f1f1 (diff)
downloadsdk-faebce1cc09653321a12b8472fd02b79dad95c58.zip
sdk-faebce1cc09653321a12b8472fd02b79dad95c58.tar.gz
sdk-faebce1cc09653321a12b8472fd02b79dad95c58.tar.bz2
ADT: NPE when capturing emulator output.
This can happen when starting an emulator from the AVD selector (or the AVD Manager window.) Change-Id: I6f5098bddc0fa54d89c164e98c51cd80509bbaf7
Diffstat (limited to 'sdkmanager/libs/sdkuilib')
-rw-r--r--sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java
index 72488a3..3a76b2a 100644
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java
@@ -1091,7 +1091,7 @@ public final class AvdSelector {
final ProgressTask progress = new ProgressTask(mTable.getShell(),
"Starting Android Emulator");
progress.start(new ITask() {
- ITaskMonitor mMonitor = null;
+ volatile ITaskMonitor mMonitor = null;
@Override
public void run(final ITaskMonitor monitor) {
@@ -1115,16 +1115,12 @@ public final class AvdSelector {
new IProcessOutput() {
@Override
public void out(@Nullable String line) {
- if (line != null) {
- filterStdOut(line);
- }
+ filterStdOut(line);
}
@Override
public void err(@Nullable String line) {
- if (line != null) {
- filterStdErr(line);
- }
+ filterStdErr(line);
}
});
@@ -1150,6 +1146,11 @@ public final class AvdSelector {
}
private void filterStdOut(String line) {
+ ITaskMonitor m = mMonitor;
+ if (line == null || m == null) {
+ return;
+ }
+
// Skip some non-useful messages.
if (line.indexOf("NSQuickDrawView") != -1) { //$NON-NLS-1$
// Discard the MacOS warning:
@@ -1162,22 +1163,27 @@ public final class AvdSelector {
if (line.toLowerCase().indexOf("error") != -1 || //$NON-NLS-1$
line.indexOf("qemu: fatal") != -1) { //$NON-NLS-1$
// Sometimes the emulator seems to output errors on stdout. Catch these.
- mMonitor.logError("%1$s", line); //$NON-NLS-1$
+ m.logError("%1$s", line); //$NON-NLS-1$
return;
}
- mMonitor.log("%1$s", line); //$NON-NLS-1$
+ m.log("%1$s", line); //$NON-NLS-1$
}
private void filterStdErr(String line) {
+ ITaskMonitor m = mMonitor;
+ if (line == null || m == null) {
+ return;
+ }
+
if (line.indexOf("emulator: device") != -1 || //$NON-NLS-1$
line.indexOf("HAX is working") != -1) { //$NON-NLS-1$
// These are not errors. Output them as regular stdout messages.
- mMonitor.log("%1$s", line); //$NON-NLS-1$
+ m.log("%1$s", line); //$NON-NLS-1$
return;
}
- mMonitor.logError("%1$s", line); //$NON-NLS-1$
+ m.logError("%1$s", line); //$NON-NLS-1$
}
});
}