- 获得手机root权限
adb shell
su
cd system
cat build.prop
可找到第三方rom系统的版本,比如ro.build.version.emui=EmotionUI_2.0
,这里我们需要的是第三方rom系统的key,如例子中的ro.build.version.emui
.
- 如何在代码中获得版本呢?即要获得
EmotionUI_2.0
.参考参考Android源码:
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(
new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
Log.e("dingyi", "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e("dingyi", "Exception while closing InputStream", e);
}
}
}
return line;
}
调用getSystemProperty("ro.build.version.emui")
即可获得第三方rom系统版本号
网友评论