From ab6dc87a430948f097af87765076210c55fd56f0 Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 13 Jan 2010 13:03:44 +0000 Subject: [PATCH] another take on pavarotti --- android/todo.txt | 2 ++ app/src/processing/app/tools/android/Device.java | 15 +++++++++------ .../processing/app/tools/android/Pavarotti.java | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/android/todo.txt b/android/todo.txt index 6ca97a204..59abda4b1 100644 --- a/android/todo.txt +++ b/android/todo.txt @@ -1,5 +1,7 @@ 0176 (private) X begin the merge of the new A3D, remove old OpenGL code +_ Android tools on Windows are broken due to naming changes in r4 SDK +_ http://dev.processing.org/bugs/show_bug.cgi?id=1432 _ add method to set the icon (and package name?) diff --git a/app/src/processing/app/tools/android/Device.java b/app/src/processing/app/tools/android/Device.java index 21784b0ab..6e87c4e64 100644 --- a/app/src/processing/app/tools/android/Device.java +++ b/app/src/processing/app/tools/android/Device.java @@ -143,16 +143,18 @@ public class Device { "-t", target, "-c", "64M" }; - Process p = Runtime.getRuntime().exec(cmd); - StringRedirectThread error = new StringRedirectThread(p.getErrorStream()); - StringRedirectThread output = new StringRedirectThread(p.getInputStream()); + Pavarotti p = new Pavarotti(cmd); +// Process p = Runtime.getRuntime().exec(cmd); +// StringRedirectThread error = new StringRedirectThread(p.getErrorStream()); +// StringRedirectThread output = new StringRedirectThread(p.getInputStream()); try { int result = p.waitFor(); if (result == 0) { // mumble the result into the console //PApplet.println(output.getLines()); - for (String s : output.getLines()) { + //for (String s : output.getLines()) { + for (String s : p.getOutputLines()) { System.out.println(s); } return true; @@ -161,10 +163,11 @@ public class Device { System.out.println("Attempted: '" + PApplet.join(cmd, " ") + "'"); // Include the stdout stuff since lots of these tools die with an // error, but use stdout to print their sadness instead of stderr - for (String s : output.getLines()) { + //for (String s : output.getLines()) { + for (String s : p.getOutputLines()) { System.out.println(s); } - for (String s : error.getLines()) { + for (String s : p.getErrorLines()) { System.err.println(s); } } diff --git a/app/src/processing/app/tools/android/Pavarotti.java b/app/src/processing/app/tools/android/Pavarotti.java index db75f11da..d5900c62d 100644 --- a/app/src/processing/app/tools/android/Pavarotti.java +++ b/app/src/processing/app/tools/android/Pavarotti.java @@ -21,7 +21,9 @@ package processing.app.tools.android; +import java.io.File; import java.io.IOException; +import java.util.Map; import processing.core.PApplet; @@ -41,7 +43,18 @@ public class Pavarotti { public Pavarotti(String[] cmd) throws IOException { this.cmd = cmd; - process = Runtime.getRuntime().exec(cmd); + ProcessBuilder pb = new ProcessBuilder(cmd); + + // Make sure the ANDROID_SDK variable is set + Map env = pb.environment(); + env.put("ANDROID_SDK", Android.sdkPath); + // Also make sure that the tools are included in the PATH + String path = env.get("PATH"); + String toolsPath = Android.sdkPath + File.separator + "tools"; + env.put("PATH", path + File.pathSeparator + toolsPath); + + process = pb.start(); + //process = Runtime.getRuntime().exec(cmd); error = new StringRedirectThread(process.getErrorStream()); output = new StringRedirectThread(process.getInputStream()); }