1. 病毒应用检测率高,权威机构验证:病毒应用检测率99%。
2. 基于行为检测未知威胁的能力。
开发者可获取恶意应用列表,基于风险(风险应用/病毒应用)评估是否限制APP行为。
请参考:开发流程
使用 Safety Detect AppsCheck API 之前,必须确保在用户设备上安装了正确版本的 HMS 服务。如果安装了不正确的版本,则您的应用可能会在调用 API 后停止响应。如果您的应用检测到安装了错误的版本,则应要求用户在其设备上更新 HMS。
要检查已安装的 HMS 版本是否与您使用的Android SDK版本兼容,请调用 isHuaweiMobileServicesAvailable() 方法,如以下代码片段所示:
- if (HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(context) == ConnectionResult.SUCCESS){
- // The SafetyDetect SysIntegrity API is available.
- } else {
- // Prompt user to update HMS.
- }
您可直接调用SafetyDetectClient的getMaliciousAppsList()获取恶意应用列表:
- private void invokeGetMaliciousApps() {
- SafetyDetectClient appsCheckClient = SafetyDetect.getClient(MainActivity.this);
- Task task = appsCheckClient.getMaliciousAppsList();
- task.addOnSuccessListener(new OnSuccessListener<MaliciousAppsListResp>() {
- @Override
- public void onSuccess(MaliciousAppsListResp maliciousAppsListResp) {
- // Indicates communication with the service was successful.
- // Use resp.getMaliciousApps() to get malicious apps data.
- List<MaliciousAppsData> appsDataList = maliciousAppsListResp.getMaliciousAppsList();
- // Indicates get malicious apps was successful.
- if(maliciousAppsListResp.getRtnCode() == CommonCode.OK) {
- if (appsDataList.isEmpty()) {
- // Indicates there are no known malicious apps.
- Log.i(TAG, "There are no known potentially malicious apps installed.");
- } else {
- Log.i(TAG, "Potentially malicious apps are installed!");
- for (MaliciousAppsData maliciousApp : appsDataList) {
- Log.i(TAG, "Information about a malicious app:");
- // Use getApkPackageName() to get APK name of malicious app.
- Log.i(TAG, "APK: " + maliciousApp.getApkPackageName());
- // Use getApkSha256() to get APK sha256 of malicious app.
- Log.i(TAG, "SHA-256: " + maliciousApp.getApkSha256());
- // Use getApkCategory() to get category of malicious app.
- // Categories are defined in AppsCheckConstants
- Log.i(TAG, "Category: " + maliciousApp.getApkCategory());
- }
- }
- }else{
- Log.e(TAG,"getMaliciousAppsList fialed: "+maliciousAppsListResp.getErrorReason());
- }
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- // An error occurred while communicating with the service.
- if (e instanceof ApiException) {
- // An error with the HMS API contains some
- // additional details.
- ApiException apiException = (ApiException) e;
- // You can retrieve the status code using the apiException.getStatusCode() method.
- Log.e(TAG, "Error: " + SafetyDetectStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getStatusMessage());
- } else {
- // A different, unknown type of error occurred.
- Log.e(TAG, "ERROR: " + e.getMessage());
- }
- }
- });
- }