我已经成功地为Beagleboard xM rev C构建了Gingerbread 2.3.4。现在我想在init.rc运行后的脚本中检查Linux内核版本名称。在Linux中,我们可以使用命令uname -r找到相同的信息。但是在Android内核中没有发现这个命令。有人能帮我提供一些示例脚本来完成同样的功能吗?
/proc目录中有一个版本文件。在shell中尝试输入cat /proc/version
,它会显示关于您的内核的信息。
public static String getKernelVersion() {
try {
Process p = Runtime.getRuntime().exec("uname -a");
InputStream is = null;
if (p.waitFor() == 0) {
is = p.getInputStream();
} else {
is = p.getErrorStream();
}
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = br.readLine();
Log.i("Kernel Version", line);
br.close();
return line;
} catch (Exception ex) {
return "ERROR: " + ex.getMessage();
}
}
adb shell cat /proc/version
或者借助于
System.getProperty("os.version");
'uname -r' 命令也应该可以工作
uname -a
是什么意思? - James Poulose