private void sendCommand(String cmd) {
Process process = null;
try {
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd);
os.writeBytes("exit\n");
os.flush();
os.close();
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
String cmd = "/system/bin/input tap 244 580\n";
sendCommand(cmd);
Log.d("Tap","first");
sendCommand(cmd);
Log.d("Tap","second");
09-06 01:09:43.878 13600-13600/com.example.na D/Tap: first
09-06 01:09:46.178 13600-13600/com.example.na D/Tap: second
It's really very slow, I wanted to emulate like a double tap with a delay of maybe 200MS inbetween two taps. but the fastest it can do is 3 seconds ..... Please advice.
Update - Tried this , still the delay between each tap is there, faster though.
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
cmd = "/system/bin/input tap 244 580\n";
os.writeBytes(cmd);
cmd = "/system/bin/input tap 244 580\n";
os.writeBytes(cmd);
os.writeBytes("exit\n");
os.flush();
os.close();
process.waitFor();