Android; using exec(“bugreport”)

2019-09-05 06:41发布

Is it possible to read the output of the terminal command adb #bugreport from within the application?

I tried the following but I couldn't manage to get any output.

Process process = Runtime.getRuntime().exec("bugreport");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
// Test result
Log.d(TAG, "Line: "+bufferedReader.readLine());

I know it works with exec("logcat"), but I prefer the output of bugreport as it contains more information.

1条回答
forever°为你锁心
2楼-- · 2019-09-05 07:03

A while ago I found the solution to this problem;

"bugreport" is a adb command it cannot be executed via the regular shell. But since adb just outputs: "logcat", "dumpsys" and "dumpstate" these commands can be run individually to achieve the same result.

Additional info: http://developer.android.com/guide/developing/tools/adb.html#commandsummary

查看更多
登录 后发表回答