如何找出谁的ROM提供者? [英] How to find out who the ROM provider is?
问题描述
我在我的应用程序,其中包括对调试有用信息的自动错误报告工具。
I have an automatic bug reporting facility in my app that includes useful information for debugging.
这是我想有一件事是ROM提供者。我特别想知道,如果用户正在运行一个定制ROM并且,preferably即使有版本号。
One thing that I would like to include is the ROM provider. In particular I would like to know if the user is running a custom ROM and which, preferably even with the version number.
不知道如何以编程方式获取这些信息?
Any idea how to retrieve this information programmatically?
---从金廷(见下文)摘自
--- Taken from the Quintin (see below)
<一个href="http://$c$c.google.com/p/cyanogen-updater/source/browse/trunk/src/cmupdaterapp/utils/SysUtils.java#19">http://$c$c.google.com/p/cyanogen-updater/source/browse/trunk/src/cmupdaterapp/utils/SysUtils.java#19:
public static String getReadableModVersion() {
String modVer = getSystemProperty(Constants.SYS_PROP_MOD_VERSION);
return (modVer == null || modVer.length() == 0 ? "Unknown" : modVer);
}
由此,不变的是这样的:
Whereby the constant is this:
public static final String SYS_PROP_MOD_VERSION = "ro.modversion";
这里是getSystemProperty();
And here is the getSystemProperty();
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;
}
可能有人用CM ROM能为我跑呢?
Could anybody with a CM ROM can run this for me?
顺便说一句。小心,这是GPL的code。我个人不能使用它。 任何容易或者非GPL的方式?
Btw. Careful, this is GPL code. I for one can not use it. Any easier or non-GPL way?
推荐答案
有code在的氰更新项目具有此功能,但我觉得ROM信息由ROM开发者提供的,所以我不知道这是否会普遍的道具文件中提供。我没有调查这彻底,但你可以看看源和看着办吧。
There is code in the Cyanogen-Updater project that has this functionality, although I think the rom information is provided by a prop file provided by the rom developer so i'm not sure if it will work universally. I haven't investigated this thoroughly, but you can take a look at the source and figure it out.
这篇关于如何找出谁的ROM提供者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!