Experts,
we are having intermittent connection failures with the SafetyNet client on Android. We are using com.google.android.gms:play-services-safetynet version 11.8.0 but have also seen the issue with version 16.
The issue occurs when the device is connected to a WiFi network without internet connection and then switched to a WiFi network with internet connectivity. In this case the attest method sometimes continues to fail with a status code of 7 (Network Error). Several retries will not solve the issue.
We confirmed that we are not hitting the 'Per-minute, per-user' API quota, which returns a different status code.
Any ideas? Thanks!
SafetyNet.getClient(context).attest(nonceBytes, googleApiKey)
.addOnSuccessListener(
new OnSuccessListener<SafetyNetApi.AttestationResponse>() {
@Override
public void onSuccess(SafetyNetApi.AttestationResponse response) {
// do something here
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception ex) {
// An error occurred while communicating with the service.
if (ex instanceof ApiException) {
// An error with the Google Play services API contains some additional details.
ApiException apiException = (ApiException) ex;
// here we get apiException.getStatusCode() of 7;
} else {
// other type of exception
}
}
});