Huawei Safety Detect vs. Google SafetyNet & User Detect Use Cases

Ömer Akkuş
Huawei Developers
Published in
5 min readOct 27, 2021

Hi everyone,

In this article, I will give detailed information about the Huawei Safety Detect service and Google Safety Net services, and the comparison of the 2 services with each other.

With applying safety services, it helps us about whether the user is a real user, whether the device is reliable and even whether the connected wi-fi network is safe. If your app is an app that gives importance to security (bank application, etc.), it is strongly recommended that you use Safety services. With the help of this service, many security vulnerabilities can be avoided.

Huawei Safety Detect Service

The features that Huawei Safety Detect service provides to us are as follows;

SysIntegrity: It checks if the device on which your app is running is trustworthy.

AppsCheck: It helps identify malicious apps on your device.

URLCheck: Determines the threat type of a specific URL.

UserDetect: Determines whether the users using your app are real users.

WifiDetect: It determines whether the Wi-fi network to be connected is secure or not.

Google SafetyNet Service

The features that Google SafetyNet service provides to us are as follows;

Attestation: Attestation API actually corresponds to SysIntegrity API from Huawei Safety Detect services. It checks if the device on which your app is running is trustworthy.

Safe Browsing: Safe Browsing API corresponds to URLChecks API from Huawei Safety Detect services. Checks if a URL connection is secure.

reCAPTCHA: reCAPTCHA Api actually corresponds to the UserDetect API from Huawei Safety Detect services. It offers various captchas to find out whether a user is a real user or a bot.

Verify Apps: The Verify Apps API corresponds to the AppsCheck API, which is one of the Huawei Safety Detect services. It is checked whether the applications on your device are safe.

Note: Google SafetyNet services do not have a feature corresponding to the Wifi Detect API, which is one of the features of the Huawei Safety Detect service.

Terms of using the services

There are many criteria on hardware or device basis in order to use both services.

App prerequisites for Safety Net Service

To use Google SafetyNet service, minSdk version must be 19 or higher and compileSdk version must be 28 and above.

If your application provides these features, the SafetyNet service works on all devices with Google services. Huawei Safety Detect service should be integrated for devices with HMS as this service will not work on new generation Huawei devices without Google service.

App prerequisites for Huawei Safety Detect Service

The Safety Detect service can run on devices with minSdk version 19 and above.

  • minSdkVersion: 19 or later
  • targetSdkVersion: 30 (recommended)
  • compileSdkVersion: 30 (recommended)
  • Gradle version: 5.4.1 or later (recommended)

In addition, you can find the features of the Safety Detect service supported by which devices and the necessary conditions in the table below.

Supported Devices:

Function Restrictions:

The Wifi detect feature is currently only available in China. Not yet supported for other regions.

You can also access the countries where the Safety Detect service is used, from this link.

Integration stages:

First, we need to add Google and Maven repository at the project level.

Then we need to implement the Safety Net service in our app-level gradle file.

dependencies {
implementation 'com.google.android.gms:play-services-safetynet:17.0.1'
}

We have implemented the necessary steps for the Google safety net service. Now it’s time for the Huawei Safety Detect service.

Likewise we must add the Huawei repo to the project level gradle file.

After this step, we need to add the Safety detect service to the project level gradle file.

dependencies {
implementation ‘com.huawei.hms:safetydetect:5.0.5.302’
}

After all these steps, we are ready to use our services.

In this article, I will apply the user detect service as a use case, which allows us to check whether users are real users.

As you can see in the code block above, we first initialize our user detect service. Afterwards, captchas are shown to the user to determine whether the user is a real user by running the service. When the user proves that he is a real user, he enters the onSuccess method and the service gives us the responseToken value. If we want to keep this value, you can send it to your app server from here.

After running the User Detect API, you can see the result below.

userDetectAPI

We performed the user detect use case from the features of the Huawei Safety Detect service. Let’s do the same use case with the Google SafetyNet service’s recaptcha api.

As you can see in the code block above, it has a very similar structure to the user detect api. The only difference is that the user detect api uses app id as a parameter, while the reCaptcha API uses the site api key.

SITE_API_KEY value is created from the Google API Console. In the Huawei Safety service, it also corresponds to the appId value.

Likewise, if the user proves to be a real user, the recaptca api also gives us a responseToken.

reCAPTCHA API

Conclusion

In this article, I compared Google SafetyNet service and Huawei Safety Detect service and tried to explain the benefits they provide to us and the use case where user control is made.I hope it was a useful article for everyone. Thank you for taking the time to read.

References

Google Safety Net API

Huawei Safety Detect Service

--

--