0

我正在尝试从我的代码中读取 /sys/kernel/debug/tracing/trace 文件的内容,但我无法这样做。我尝试使用 mount -o rw,remount -t debugfs nodev /sys/kernel/debug 进行安装并且还完成了 chmod -R 777 /sys/kernel/debug

          File myFile = new File("/sys/kernel/debug/tracing/trace");
    FileInputStream fIn = null;
    try {
        fIn = new FileInputStream(myFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    BufferedReader myReader = new BufferedReader(
            new InputStreamReader(fIn));
    String aDataRow;
    try {
        while ((aDataRow = myReader.readLine()) != null) {
            // Toast.makeText(getBaseContext(), aDataRow, Toast.LENGTH_LONG).show();
            t.setText(aDataRow);
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
4

1 回答 1

0

您需要在程序中使用“su”命令。

Process process = Runtime.getRuntime().exec(new String[] { "su", "-c", "cat /sys/kernel/debug/tracing/trace" });
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;

            while ((line = reader.readLine()) != null) {
于 2015-05-01T23:09:56.663 回答