Is it possible to simulate touch from the background application (or service) or to run sh script (that simulate touch)?
It is needed for testing android system without USB or other connection to PC, thats why I can't (or don' know how) use Monkey or other autotest tools.
Added info:
I found the way to run shell commands with root (tested devices rooted):
Unable to execute sendevent shell command through the android code (create touch simulation).
Writing file on system partition (run commands with root permissions)
Also I get events to simulate touch.
As a result I have:
//sendevent commands to simulate touch (verify it work from cmd)
String[] touchEvent = { "sendevent /dev/input/event0 0 0 0
",
"sendevent /dev/input/event6 3 53 499
",
"sendevent /dev/input/event6 3 54 680
",
"sendevent /dev/input/event6 3 58 40
",
"sendevent /dev/input/event6 3 48 3
",
"sendevent /dev/input/event6 3 57 0
",
"sendevent /dev/input/event6 0 2 0
",
"sendevent /dev/input/event6 0 0 0
",
"sendevent /dev/input/event6 0 2 0
",
"sendevent /dev/input/event6 0 0 0
",
"sendevent /dev/input/event0 3 0 2
",
"sendevent /dev/input/event0 0 0 0
"};
try{
Thread.sleep(2000);
Process root = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(root.getOutputStream());
for(int i = 0; i < touchEvent.length; i++){
Log.i(TAG, touchEvent[i]);
os.writeBytes(touchEvent[i]);
os.flush();
}
root.waitFor();
} catch (IOException e) {
Log.e(TAG, "Runtime problems
");
e.printStackTrace();
} catch (SecurityException se){
se.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
I have no any exceptions, but it is not touch simulates.
Can anybody help to solve this problem?
If there is another way to do it with android ndk or daemon on C, please tell me about it.
Thanks.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…