Android的复制保护如何检查设备是否已植根?
作者:互联网
在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. 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.
如何Android – 同时弃用 – 复制保护检查设备是否已植根?根据Dianne Hackborn(见How can you detect if the device is rooted in the app?)的说法,这是不可能的.所以这只能意味着,检查是由一些(未知的公共)混淆标准检查完成的,显然不仅仅是简单检查’su’命令是否存在,我想.
有没有人更了解那种检查逻辑 – 或者它有多安全?
解决方法:
这是我使用的:
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;
}
从理论上讲,它并不适用于所有情况,因为用户可以将’su’放在非标准位置,这不在PATH中,但实际上如果他这样做,其他应用程序需要知道’su’的位置也不会找到它,因此生根的目的将被打败.
标签:android,android-lvl 来源: https://codeday.me/bug/20190704/1379099.html