我正在编写一个应用程序,需要区分Android Stock ROM和其他ROM如SenseUI等。
如何在我的应用程序中执行此操作?
谢谢。
我发现使用 getprop
查询ro.product.brand
正好会产生我需要的东西。
/**
* Returns the ROM manufacturer.
*
* @return The ROM manufacturer, or NULL if not found.
*/
public static String getROMManufacturer() {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop ro.product.brand");
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
}
catch (IOException ex) {
Log.e(TAG, "Unable to read sysprop ro.product.brand", ex);
return null;
}
finally {
if (input != null) {
try {
input.close();
}
catch (IOException e) {
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
对于股票ROM,我们得到的价值是谷歌
例如,对于SenseUI,我们将取回HTC
上述方法将返回唯一的谷歌或HTC等...
我希望它也帮助了其他人。