SORU
9 Temmuz 2009, PERŞEMBE


Eğer köklü bir cihaz üzerinde çalışan belirlemek

Benim uygulama sadece root mevcut olduğu bir cihaz üzerinde çalışacak bir işlevi belirli bir parça vardır. Ziyade olan bu özellik, başarısız olduğunda kullanılır (Daha sonra uygun bir hata iletisi kullanıcı), tercih ederdim bir yetenek sessizce kontrol ederseniz kökü mevcut ilk ve değilse,gizlemek ilgili seçenekler.

Bunu yapmanın bir yolu var mı?

CEVAP
11 Kasım 2011, Cuma


Burada Kök için üç yoldan birini kontrol edecek bir sınıf.

/** @author Kevin Kowalewski */
public class RootUtil {
    public static boolean isDeviceRooted() {
        return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
    }

    private static boolean checkRootMethod1() {
        String buildTags = android.os.Build.TAGS;
        return buildTags != null && buildTags.contains("test-keys");
    }

    private static boolean checkRootMethod2() {
        String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
                "/system/bin/failsafe/su", "/data/local/su" };
        for (String path : paths) {
            if (new File(path).exists()) return true;
        }
        return false;
    }

    private static boolean checkRootMethod3() {
        Process process = null;
        try {
            process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
            if (in.readLine() != null) return true;
            return false;
        } catch (Throwable t) {
            return false;
        } finally {
            if (process != null) process.destroy();
        }
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BiGSH0TROB

    BiGSH0TROB

    7 NİSAN 2011
  • EminemVEVO

    EminemVEVO

    12 Mayıs 2009
  • Propaganda Time

    Propaganda T

    19 EYLÜL 2010