我正在编写一个需要区分 Android Stock ROM 和 SenseUI 等其他 ROM 的应用程序。
我怎样才能在我的应用程序中做到这一点?
谢谢。
我正在编写一个需要区分 Android Stock ROM 和 SenseUI 等其他 ROM 的应用程序。
我怎样才能在我的应用程序中做到这一点?
谢谢。
我发现ro.product.brand
使用查询getprop
产生的正是我所需要的。
/**
* 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,我们取回的值是google
对于 SenseUI 例如,我们将取回HTC
上述方法将返回唯一的google或HTC等...
我希望它也对其他人有所帮助。