Skip to content

Commit 22768ea

Browse files
committed
fixed emulator init issues, messages
1 parent 032bb9b commit 22768ea

File tree

6 files changed

+320
-289
lines changed

6 files changed

+320
-289
lines changed

src/processing/mode/android/AVD.java

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,20 @@ protected void refreshWearImages(final AndroidSDK sdk) throws IOException {
225225

226226
protected void getImages(final ArrayList<String> images, final AndroidSDK sdk,
227227
final String imageTag) throws IOException {
228+
final String[] cmd = new String[] {
229+
sdk.getAvdManagerPath(),
230+
"create", "avd",
231+
"-n", "dummy",
232+
"-k", "dummy"
233+
};
234+
228235
// Dummy avdmanager creation command to get the list of installed images
229236
// TODO : Find a better way to get the list of installed images
230-
ProcessBuilder pb = new ProcessBuilder(
231-
sdk.getAvdManagerPath(),
232-
"create", "avd",
233-
"-n", "dummy",
234-
"-k", "dummy"
235-
);
237+
ProcessBuilder pb = new ProcessBuilder(cmd);
238+
239+
//if (Base.DEBUG) {
240+
System.out.println(processing.core.PApplet.join(cmd, " "));
241+
//}
236242

237243
Map<String, String> env = pb.environment();
238244
env.clear();
@@ -246,9 +252,10 @@ protected void getImages(final ArrayList<String> images, final AndroidSDK sdk,
246252
output.addTarget(new LineProcessor() {
247253
@Override
248254
public void processLine(String line) {
255+
System.out.println("DUMMY ---> " + line);
249256
if (images != null && line.contains(AndroidBuild.TARGET_PLATFORM) &&
250257
line.contains(imageTag))
251-
System.out.println("IMAGE ---> " + line);
258+
System.out.println(" added!");
252259
images.add(line);
253260
}
254261
}).start();
@@ -290,17 +297,23 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
290297
if (!androidFolder.exists()) androidFolder.mkdir();
291298
File avdPath = new File(androidFolder, "avd/" + name);
292299

293-
ProcessBuilder pb = new ProcessBuilder(
294-
sdk.getAvdManagerPath(),
295-
"create", "avd",
296-
"-n", name,
297-
"-k", getSdkId(),
298-
"-c", DEFAULT_SDCARD_SIZE,
299-
"-d", device,
300-
"-p", avdPath.getAbsolutePath(),
301-
"-f"
302-
);
303-
300+
final String[] cmd = new String[] {
301+
sdk.getAvdManagerPath(),
302+
"create", "avd",
303+
"-n", name,
304+
"-k", getSdkId(),
305+
"-c", DEFAULT_SDCARD_SIZE,
306+
"-d", device,
307+
"-p", avdPath.getAbsolutePath(),
308+
"-f"
309+
};
310+
311+
ProcessBuilder pb = new ProcessBuilder(cmd);
312+
313+
//if (Base.DEBUG) {
314+
System.out.println(processing.core.PApplet.join(cmd, " "));
315+
//}
316+
304317
// avdmanager create avd -n "Wear-Processing-0254" -k "system-images;android-25;google_apis;x86" -c 64M
305318

306319
// Set the list to null so that exists() will check again
@@ -380,7 +393,7 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
380393
AndroidUtil.showMessage(AVD_LOAD_TITLE, AVD_LOAD_MESSAGE);
381394
return false;
382395
}
383-
if (wearAVD.hasWearImages(sdk)) {
396+
if (!wearAVD.hasWearImages(sdk)) {
384397
boolean res = AndroidSDK.locateSysImage(window, mode, true);
385398
if (!res) {
386399
return false;
@@ -399,7 +412,7 @@ static public boolean ensureProperAVD(final Frame window, final AndroidMode mode
399412
AndroidUtil.showMessage(AVD_LOAD_TITLE, AVD_LOAD_MESSAGE);
400413
return false;
401414
}
402-
if (mobileAVD.hasImages(sdk)) {
415+
if (!mobileAVD.hasImages(sdk)) {
403416
boolean res = AndroidSDK.locateSysImage(window, mode, false);
404417
if (!res) {
405418
return false;

0 commit comments

Comments
 (0)