[英]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.