如何检测根/越狱android设备
在我的Android应用程序中,我只想为根设备提供一个特定的功能。检查的唯一方法是知道我是否可以运行超级用户命令吗?这张支票够了吗?有更多的方法来检测被越狱的android设备吗?有很多方法可以用来越狱手机;大多数依赖于硬件和/或软件。默认情况下,有些手机甚至附带超级用户访问权限!检查所有这些方法是没有意义的,因为最终结果是一样的:您拥有超级用户访问权限。是的,最简单/最简单/最好的答案是尝试执行超级用户命令 如果你担心这还不够,也许你可以解释一下你想做什么。看看,这是一个很棒的库,旨在简化为根设备开发应用程序的过程 从他们的:如何检测根/越狱android设备,android,jailbreak,rooted-device,Android,Jailbreak,Rooted Device,在我的Android应用程序中,我只想为根设备提供一个特定的功能。检查的唯一方法是知道我是否可以运行超级用户命令吗?这张支票够了吗?有更多的方法来检测被越狱的android设备吗?有很多方法可以用来越狱手机;大多数依赖于硬件和/或软件。默认情况下,有些手机甚至附带超级用户访问权限!检查所有这些方法是没有意义的,因为最终结果是一样的:您拥有超级用户访问权限。是的,最简单/最简单/最好的答案是尝试执行超级用户命令 如果你担心这还不够,也许你可以解释一下你想做什么。看看,这是一个很棒的库,旨在简化为根
if(RootTools.isRootAvailable()){
//苏存在,做点什么
}否则{
//做点别的
}
对于那些仍然想知道如何检测根设备的人,现在有了一种方法
您现在可以使用SafetyNet认证API
是指向文档的链接
// The nonce should be at least 16 bytes in length.
// You must generate the value of API_KEY in the Google APIs dashboard.
SafetyNet.getClient(this).attest(nonce, API_KEY)
.addOnSuccessListener(this,
new OnSuccessListener<SafetyNetApi.AttestationResponse>() {
@Override
public void onSuccess(SafetyNetApi.AttestationResponse response) {
// Indicates communication with the service was successful.
// Use response.getJwsResult() to get the result data.
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// An error occurred while communicating with the service.
if (e instanceof ApiException) {
// An error with the Google Play services API contains some
// additional details.
ApiException apiException = (ApiException) e;
// You can retrieve the status code using the
// apiException.getStatusCode() method.
} else {
// A different, unknown type of error occurred.
Log.d(TAG, "Error: " + e.getMessage());
}
}
});
下面是一个如何使用从文档中获取的API的片段
// The nonce should be at least 16 bytes in length.
// You must generate the value of API_KEY in the Google APIs dashboard.
SafetyNet.getClient(this).attest(nonce, API_KEY)
.addOnSuccessListener(this,
new OnSuccessListener<SafetyNetApi.AttestationResponse>() {
@Override
public void onSuccess(SafetyNetApi.AttestationResponse response) {
// Indicates communication with the service was successful.
// Use response.getJwsResult() to get the result data.
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// An error occurred while communicating with the service.
if (e instanceof ApiException) {
// An error with the Google Play services API contains some
// additional details.
ApiException apiException = (ApiException) e;
// You can retrieve the status code using the
// apiException.getStatusCode() method.
} else {
// A different, unknown type of error occurred.
Log.d(TAG, "Error: " + e.getMessage());
}
}
});
其中ctsProfileMatch
和设备的基本完整性
完整性