简体   繁体   English

Android的复制保护如何检查设备是否已植根?

[英]How can Android's Copy Protection check if the device is rooted?

On http://developer.android.com/guide/publishing/licensing.html , under section "Replacement for Copy Protection" it says: http://developer.android.com/guide/publishing/licensing.html上的 “复制保护替换”部分下,它显示:

A limitation of the legacy Copy Protection mechanism on Android Market is that applications using it can be installed only on compatible devices that provide a secure internal storage environment. Android Market对旧版“复制保护”机制的限制是,使用它的应用程序只能安装在提供安全内部存储环境的兼容设备上。 For example, a copy-protected application cannot be downloaded from Market to a device that provides root access, and the application cannot be installed to a device's SD card. 例如,不能将受复制保护的应用程序从Market下载到提供根访问权限的设备上,并且不能将其安装到设备的SD卡上。

How can Android's - meanwhile deprecated - Copy Protection check whether the device is rooted? Android的-同时不建议使用的-复制保护如何检查设备是否植根? Afaik it's not possible, also according to Dianne Hackborn (see How can you detect if the device is rooted in the app? ). 根据Dianne Hackborn的说法,Afaik也是不可能的(请参阅如何检测设备是否植根于应用程序中? )。 So that can only mean, the check is done by some (unknown the the public) obfuscated criteria check, obviously not just a simple check whether the 'su' command exists, I suppose. 因此,这只能意味着,检查是通过一些(未知的公众)混淆标准检查完成的,显然,我想这不只是简单的检查“ su”命令是否存在。 Does anybody know more about that check logic - or how secure that is? 有人对这种检查逻辑有更多的了解吗?或者说它的安全性如何?

This is what I use: 这是我用的:

public static boolean isDeviceRooted () {
    boolean ret = false;
    String path = null;
    Map<String,String> env = System.getenv();

    if (env != null && (path = env.get("PATH")) != null) {
        setDevicePath(path);
        String [] dirs = path.split(":");
        for (String dir : dirs){
            String suPath = dir + "/" + "su";
            File suFile = new File(suPath);
            if (suFile != null && suFile.exists()) {
                setSuLocation(suPath);
                ret = true;
            }
        }
    }
    return ret;
}

Theoretically, it's not going to work in all cases, because a user can put 'su' to a non-standard location, which is not in a PATH, but practically if he does that, other applications that need to know where 'su' is won't find it either, so the purpose of rooting will be defeated. 从理论上讲,它不能在所有情况下都起作用,因为用户可以将“ su”放在非标准位置,该位置不在PATH中,但实际上,如果他这样做,其他应用程序需要知道“ su”在哪里也不会找到它,因此生根的目的将被打败。

While the presence of the Superuser app isn't a perfect way to tell if the phone is rooted its a pretty indicator that it might be. 尽管Superuser应用程序的存在并不是判断手机是否植根的完美方法,但它可以很好地指示手机是否扎根。 Why not just check to see if the package com.noshufou.android.su is installed? 为什么不只是检查是否已安装com.noshufou.android.su包?

I've never tried it but I don't see why it wouldn't work. 我从来没有尝试过,但是我不明白为什么它不起作用。

We would clearly state in the sales information that the app doesn't run on rooted devices. 我们会在销售信息中明确指出该应用程序无法在有根设备上运行。

This will definitely affect your install rate. 这肯定会影响您的安装速度。 Although you are planning to sell your app for $1000, that is going to have a much worse effect than anything else you could to it. 尽管您打算以1000美元的价格出售您的应用程序,但其效果将比其他任何方式都要差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM