如何从 java 代码打开模拟器 shell 以确定系统调用事件?

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

我想用 strace 工具收集 android 应用程序的系统调用事件 首先我用午餐模拟器,然后我在 linux 下一个命令行中的终端中写入:

adb -s emulator-5554 shell

模拟器后shell我想写strace命令如图:

来自 trminal 它对我来说工作正常但是当我写 java 代码时

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

它没有用任何人都可以帮助我在 eclipse 中编写这个 java 代码 请注意图片

adb shell命令打开一个新的shell,其中执行strace。您的命令的 Java 版本在默认 shell 中执行了这两个命令。因此你必须将它们结合起来:

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