Already a lot of time I’m afraid to turn off the standard buffering with the size of 4096 bytes of InputStream, which is installed in Linux-like systems. There is a stdbuf command, but there is no such command for the terminal in android, you need to somehow connect it separately.

I need to process exactly in real time, in not until 4096 byte has accumulated in the process. Need to work if the line already has 18 bytes. More specifically, this is the command getevent event0, which displays the data about clicking on the screen. In any terminal with root access data is displayed for this command immediately.

I met such a post on the English-language branch at https://stackoverflow.com/questions/31296374/resolved-android-interactive-shell-runtime-getruntime-exec But I can’t figure it out until the end what I understood ... I don’t understand something further, what's what ... I can’t reach the author of the post ...

public class TouchEventThread2 extends Thread { DataOutputStream dos1, dos2; Process process1, process2; String cmd = "getevent /dev/input/event0"; @Override public void run() { process(process1, dos1); process(process2, dos2); boolean firstProcess = true; while (true) { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } if (true) { if (firstProcess) { cmd("getevent /dev/input/event0", dos2); cmd("quit", dos1); } else { cmd("getevent /dev/input/event0", dos1); cmd("quit", dos2); } firstProcess = !firstProcess; } } } public void process (Process process, DataOutputStream dos) { try { process = new ProcessBuilder(new String[]{"su", "-c", "sh"}).start(); dos = new DataOutputStream(process.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } } public void cmd (String cmd, DataOutputStream dos) { try { dos.writeBytes(cmd + "\n"); dos.flush(); } catch (IOException e) { e.printStackTrace(); } } } 
  • show your code - Pioneer
  • @ Pioneer docs.google.com/document/d/... All I understood ... - bonny
  • Does anyone have a thought to solve the problem? - bonny
  • Guys, we need thoughts to resolve the issue. @ Pioneer - bonny
  • It's impossible to get through to @VasileM - bonny

0