How to open emulator shell from java code to determine system call events?

728 views Asked by At

I want to collect system call events to android applications with strace tool First I lunch emulator then I write in terminal in linux the next command line :

adb -s emulator-5554 shell

After emulator shell I want to write strace command as shown in the picture:

after emulator shell I want to write strace command as shown in the picture from trminal it works fine with me but when I write java code

Process p=Runtime.getRuntime().exec("adb -s emulator-5554 shell");
Process p1=Runtime.getRuntime().exec("strace -p 871");

It didn't work can any one help me to write this java code in eclipse please pay attention to the picture

1

There are 1 answers

4
Robert On BEST ANSWER

The adb shell command opens a new shell in which straceis executed. The Java version of your command executed both commands in the default shell. Hence you have to combine them:

Process p=Runtime.getRuntime().exec("adb -s emulator-5554 shell strace -p 871");