无法在adb shell中执行'cd'

时间:2016-08-26 07:18:06

标签: java android shell

我正在尝试在cd /sys/class/power_supply/battery && cat uevent中执行ADB SHELL命令,并在信息中编织ArrayList。但是,它无法工作,返回空。虽然当我执行ls替换cd /sys/class/power_supply/battery && cat uevent时,ArrayList会被填充。虽然可以使用terminal应用轻松访问该路径! 有什么问题?

ArrayList<String> info = new ArrayList<>();

    try {
        Process process = Runtime.getRuntime().exec("adb shell");
        process.waitFor();
        process = Runtime.getRuntime().exec("cd /sys/class/power_supply/battery && cat uevent");
        BufferedReader buf = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while ((line=buf.readLine())!=null) {
            info.add(line);
        }
    } catch (Exception e) {

    }

    Log.i("INFORMATION",info.toString());
}

0 个答案:

没有答案