将 'iwconfig' 放在 shell 脚本中,您可以直接从 android 运行进程,处理 stdout 直到完成。此示例执行 shell name=./bin/pars_submit。
public String getFfmpeg(@QueryParam("infil1") String infil1,
@QueryParam("infil2") String infil2, @QueryParam("otfil") String otfil,
@QueryParam("t") String time) {
String outfil = "dummy.mp4";
List<String> command = new ArrayList<String>();
command.add("vendor/bin/pars_submit");
command.add(infil1);
command.add(infil2);
command.add(otfil);
command.add(time);
System.out.println("Starting process " +command.toString());
ProcessBuilder builder = new ProcessBuilder(command);
Map<String, String> environ = builder.environment();
// for(Entry<String, String> entry : environ.entrySet()){
// System.out.println("ENV " +entry.getKey() + " " +entry.getValue());
// }
// builder.redirectErrorStream(true);
Process process = null;
try {
process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
//System.out.println(line);
outfil=line;
}
// int exitVal = process.waitFor();
// System.out.println("Process exitValue: " + exitVal);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
if (process != null) {
process.destroy();
process = null;
}
}
return outfil;
}