2017-05-03 4 views

Répondre

0

Vérifiez ces propriétés dans votre code et puis comparez avec les images de Google. Presque toutes les ROM personnalisées sont enracinées de sorte que vous pouvez également vérifier si le périphérique est rooté ou non. Voici le code pour vérifier la racine.

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; 
    } 

L'émulateur PS est un périphérique enraciné. Test sur l'appareil réel

+0

comment est-ce que je le compare avec google stock image –

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 

Utilisez cette puis le comparer avec le stock Google images.One chose, presque 99% de tous les ROM personnalisés sont enracinés pour que vous puissiez vérifier si l'appareil est ancré ou non. La bibliothèque RootTools propose des méthodes simples pour vérifier la racine:

RootTools.isRootAvailable()

Vous pouvez consulter ci-dessous les liens pour plus de détails How to find out who the ROM provider is? Et pour RootTools lien ci-dessous utilisent

https://github.com/Stericson/RootTools