gpt4 book ai didi

android - 如何确定应用程序是否在库存 ROM 上运行

转载 作者:行者123 更新时间:2023-11-29 00:24:25 27 4
gpt4 key购买 nike

我正在编写一个需要区分 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,我们得到的值是 google
以 SenseUI 为例,我们将取回 HTC

以上方法只会返回googleHTC等...

我希望它对其他人也有帮助。

关于android - 如何确定应用程序是否在库存 ROM 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20772763/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com