Skip to content

Commit 2682573

Browse files
committed
testing haxm install
1 parent 0d7c1c8 commit 2682573

File tree

3 files changed

+50
-25
lines changed

3 files changed

+50
-25
lines changed

src/processing/mode/android/AndroidEditor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ public void actionPerformed(ActionEvent e) {
657657
item.addActionListener(new ActionListener() {
658658
public void actionPerformed(ActionEvent e) {
659659
// editor.statusNotice("Resetting the Android Debug Bridge server.");
660-
Devices.killAdbServer();
660+
// Devices.killAdbServer();
661+
SysImageDownloader.installHAXM();
661662
}
662663
});
663664
androidMenu.add(item);

src/processing/mode/android/EmulatorController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.io.IOException;
2626
import java.util.concurrent.CountDownLatch;
2727

28-
import processing.app.Base;
2928
import processing.app.Platform;
3029
import processing.app.Preferences;
3130
import processing.app.exec.*;
@@ -92,7 +91,8 @@ synchronized public void launch(File sdkToolsPath, boolean wear, boolean gpu) th
9291
}
9392

9493
// https://developer.android.com/studio/run/emulator-acceleration.html#accel-graphics
95-
String gpuFlag = gpu ? "auto" : "off";
94+
// String gpuFlag = gpu ? "auto" : "off";
95+
String gpuFlag = "auto";
9696

9797
File emulatorPath = Platform.isWindows() ? new File(sdkToolsPath, "emulator.exe") :
9898
new File(sdkToolsPath, "emulator");

src/processing/mode/android/SysImageDownloader.java

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import processing.app.Platform;
3030
import processing.app.Preferences;
31+
import processing.app.exec.LineProcessor;
32+
import processing.app.exec.StreamPump;
3133
import processing.app.ui.Toolkit;
3234
import processing.core.PApplet;
3335

@@ -381,28 +383,7 @@ public void run() {
381383
} else {
382384
// x86
383385
Preferences.set("android.system.image.type", "x86");
384-
File haxmFolder = AndroidSDK.getHAXMInstallerFolder();
385-
if (haxmFolder.exists() && !Platform.isLinux()) {
386-
AndroidUtil.showMessage(HAXM_INSTALL_TITLE, HAXM_INSTALL_MESSAGE);
387-
388-
File exec = new File(haxmFolder, "HAXM installation");
389-
System.out.println(exec.getAbsolutePath() + " " + exec.exists());
390-
391-
ProcessBuilder pb;
392-
if (Platform.isWindows())
393-
pb = new ProcessBuilder("cmd.exe", "/c", "start", "silent_install.bat");
394-
else
395-
pb = new ProcessBuilder(exec.getAbsolutePath());
396-
397-
// pb.directory(haxmFolder);
398-
try {
399-
pb.start().waitFor();
400-
} catch (InterruptedException e) {
401-
e.printStackTrace();
402-
} catch (IOException e) {
403-
e.printStackTrace();
404-
}
405-
}
386+
installHAXM();
406387
}
407388
downloadTask = new DownloadTask();
408389
downloadTask.addPropertyChangeListener(this);
@@ -418,6 +399,49 @@ public boolean cancelled() {
418399
public boolean getResult() {
419400
return result;
420401
}
402+
403+
static public void installHAXM() {
404+
File haxmFolder = AndroidSDK.getHAXMInstallerFolder();
405+
if (haxmFolder.exists() && !Platform.isLinux()) {
406+
AndroidUtil.showMessage(HAXM_INSTALL_TITLE, HAXM_INSTALL_MESSAGE);
407+
408+
File exec = new File(haxmFolder, "HAXM installation");
409+
System.out.println(exec.getAbsolutePath() + " " + exec.exists());
410+
411+
ProcessBuilder pb;
412+
if (Platform.isWindows())
413+
pb = new ProcessBuilder("cmd.exe", "/c", "start", "silent_install.bat");
414+
else
415+
pb = new ProcessBuilder(exec.getAbsolutePath());
416+
pb.redirectErrorStream(true);
417+
418+
pb.directory(haxmFolder);
419+
Process process = null;
420+
try {
421+
process = pb.start();
422+
} catch (IOException e) {
423+
e.printStackTrace();
424+
}
425+
426+
if (process != null) {
427+
try {
428+
StreamPump output = new StreamPump(process.getInputStream(), "HAXM: ");
429+
output.addTarget(new LineProcessor() {
430+
@Override
431+
public void processLine(String line) {
432+
System.out.println("HAXM: " + line);
433+
}
434+
}).start();
435+
436+
process.waitFor();
437+
} catch (final InterruptedException ie) {
438+
ie.printStackTrace();
439+
} finally {
440+
process.destroy();
441+
}
442+
}
443+
}
444+
}
421445

422446
private void createLayout() {
423447
Container outer = getContentPane();

0 commit comments

Comments
 (0)