参考Android源码:
https://code.google.com/p/cyanogen-updater/source/browse/trunk/src/cmupdaterapp/utils/SysUtils.java#19
在Android shell模式下输入 getprop 就能获取系统属性值
如果Rom是miUI那么就会有以下字段.
[ro.miui.ui.version.code]: [3]
[ro.miui.ui.version.name]: [V5]
[ro.miui.ui.version.name]: [V5]
那么只要用一下代码获取就能知道是不是UI了.
getSystemProperty("ro.miui.ui.version.name")
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(TAG, "Unable to read sysprop " + propName, ex);
return null;
}
finally
{
if(input != null)
{
try
{
input.close();
}
catch (IOException e)
{
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
通过分析Android源码和使用shell命令`getprop`,可以判断设备是否运行MIUI系统,并获取MIUI的具体版本信息。参考CyanogenUpdater项目的SysUtils.java文件,在系统属性值中查找特定字段来识别MIUI。
783

被折叠的 条评论
为什么被折叠?



