[英]Check custom rom in android programmatically
我想在我的应用程序中检查该设备是否具有自定义 ROM。 有了这个,我在我的应用程序中启用和禁用了一些功能。 请帮我。
在您的代码中检查这些属性,然后将其与 Google 库存图片进行比较。
System.getProperty("os.version"); // OS version
android.os.Build.VERSION.SDK // API Level
android.os.Build.DEVICE // Device
android.os.Build.MODEL // Model
android.os.Build.PRODUCT // Product
几乎所有自定义 ROM 都已植根,因此您还可以检查设备是否已植根。 下面是检查root的代码。
public static boolean isRooted() {
// get from build info
String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys")) {
return true;
}
// check if /system/app/Superuser.apk is present
try {
File file = new File("/system/app/Superuser.apk");
if (file.exists()) {
return true;
}
} catch (Exception e1) {
// ignore
}
// try executing commands
return canExecuteCommand("/system/xbin/which su")
|| canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su");
}
// executes a command on the system
private static boolean canExecuteCommand(String command) {
boolean executedSuccesfully;
try {
Runtime.getRuntime().exec(command);
executedSuccesfully = true;
} catch (Exception e) {
executedSuccesfully = false;
}
return executedSuccesfully;
}
PS - 模拟器是有根设备。 在实际设备上测试
System.getProperty("os.version"); // OS version
android.os.Build.VERSION.SDK // API Level
android.os.Build.DEVICE // Device
android.os.Build.MODEL // Model
android.os.Build.PRODUCT // Product
使用它,然后将其与谷歌股票图像进行比较。还有一件事,几乎 99% 的所有自定义 ROM 都已植根,因此您可以检查设备是否已植根。 RootTools 库提供了检查 root 的简单方法:
RootTools.isRootAvailable()
您可以参考以下链接了解更多详情如何找出 ROM 提供商是谁? 对于 RootTools,请使用以下链接
尝试使用 Google 的 Saftynet 服务(它检测引导加载程序是否已解锁,要安装自定义 Rom 引导加载程序必须解锁)...它可以被欺骗,但没有多少用户知道如何做到这一点。 如果您只检测到 root,则当股票被 root 时,该应用程序也不会在股票 Rom 上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.