Skip to content

Commit c613cf1

Browse files
authored
Merge pull request #380 from rupak0577/avdmanager
Wait for emulator to complete booting
2 parents a5984ad + 149c08e commit c613cf1

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

src/processing/mode/android/AndroidRunner.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public class AndroidRunner implements DeviceListener {
4545
protected PrintStream sketchErr;
4646
protected PrintStream sketchOut;
4747

48-
protected boolean showedSlowEmuWarning = false;
49-
5048
public AndroidRunner(AndroidBuild build, RunnerListener listener) {
5149
this.build = build;
5250
this.listener = listener;
@@ -98,18 +96,6 @@ public boolean launch(Future<Device> deviceFuture, int comp, boolean emu) {
9896
// this stopped working with Android SDK tools revision 17
9997
if (!device.installApp(build, listener)) {
10098
listener.statusError("Lost connection with " + devStr + " while installing. Try again.");
101-
if (emu && !showedSlowEmuWarning) {
102-
showedSlowEmuWarning = true;
103-
// More detailed message when using the emulator, to following discussion in
104-
// https://code.google.com/p/android/issues/detail?id=104305
105-
Messages.showWarning("Cannot run the sketch yet...",
106-
"This is common when the emulator is booting up for the first time.\n" +
107-
"Just try again once the emulator is ready, or set the\n" +
108-
"ADB_INSTALL_TIMEOUT environmental variable to have a\n" +
109-
"longer timeout, for example 5 minutes or more.\n\n"+
110-
"Once the emulator is running, don't close until you are done\n" +
111-
"working with Processing.\n");
112-
}
11399
Devices.killAdbServer(); // see above
114100
return false;
115101
}

src/processing/mode/android/EmulatorController.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ synchronized public void launch(File sdkToolsPath, boolean wear)
6969
// https://developer.android.com/studio/run/emulator-commandline.html
7070
String avdName = AVD.getName(wear);
7171

72-
String portString = AVD.getPreferredPort(wear);
72+
final String portString = AVD.getPreferredPort(wear);
7373

7474
// We let the emulator decide what's better for hardware acceleration:
7575
// https://developer.android.com/studio/run/emulator-acceleration.html#accel-graphics
@@ -143,12 +143,11 @@ public void run() {
143143
}
144144
Thread.sleep(2000);
145145
//System.out.println("done sleeping");
146-
for (final String device : Devices.list()) {
147-
if (device.contains("emulator")) {
148-
//System.err.println("EmulatorController: Emulator booted.");
149-
setState(State.RUNNING);
150-
return;
151-
}
146+
ProcessResult result = AndroidSDK.runADB("-s", "emulator-" + portString,
147+
"shell", "getprop", "dev.bootcomplete");
148+
if (result.getStdout().equals("1\n")) {
149+
setState(State.RUNNING);
150+
return;
152151
}
153152
}
154153
System.err.println("EmulatorController: Emulator never booted. " + state);

0 commit comments

Comments
 (0)