2017-05-03 3 views

答えて

0

コードでこれらのプロパティを確認し、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エミュレータはルートデバイスです。実際のデバイス上でテスト

+0

方法私はそれをGoogleのストック画像と比較するのですか? –

1
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 

は、これを使用して、Googleの株価images.Oneより多くの事とそれを比較しますが、デバイスが根ざしているかどうかを確認することができるように、すべてのカスタムROMをのほぼ99%が根ざしています。 RootToolsライブラリは、ルートをチェックするための簡単な方法を提供しています:

RootTools.isRootAvailable()あなたがHow to find out who the ROM provider is? そしてRootToolsため は、下のリンクを使用して、さらに詳細については、以下のリンク参照でき

https://github.com/Stericson/RootTools

関連する問題