Upgrade snet extension

This commit is contained in:
topjohnwu 2018-10-28 16:07:34 -04:00
parent 79418a3767
commit 3e22573d8d
3 changed files with 13 additions and 7 deletions

View File

@ -8,7 +8,7 @@ android {
applicationId "com.topjohnwu.snet"
minSdkVersion 14
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 11
versionCode 12
versionName "snet"
}
@ -23,5 +23,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-safetynet:15.0.1'
implementation 'com.google.android.gms:play-services-safetynet:16.0.0'
}

View File

@ -21,3 +21,6 @@
#-renamesourcefileattribute SourceFile
-keep class com.topjohnwu.snet.Snet { *; }
-repackageclasses ''
-allowaccessmodification

View File

@ -5,7 +5,6 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import android.util.Base64;
import android.util.Log;
@ -27,6 +26,8 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.security.SecureRandom;
import androidx.annotation.NonNull;
public class SafetyNetHelper implements InvocationHandler,
OnSuccessListener<SafetyNetApi.AttestationResponse>, OnFailureListener {
@ -39,9 +40,6 @@ public class SafetyNetHelper implements InvocationHandler,
private static final SecureRandom RANDOM = new SecureRandom();
private static final String TAG = "SNET";
/* Insert the magic API key here :) */
private static final String API_KEY = "";
private final Activity mActivity;
private final Object callback;
@ -57,6 +55,11 @@ public class SafetyNetHelper implements InvocationHandler,
} catch (Exception ignored) {}
}
/* Return magic API key here :) */
private String getApiKey() {
return "";
}
/* Override ISafetyNetHelper.getVersion */
private int getVersion() {
return BuildConfig.VERSION_CODE;
@ -76,7 +79,7 @@ public class SafetyNetHelper implements InvocationHandler,
RANDOM.nextBytes(nonce);
SafetyNetClient client = SafetyNet.getClient(mActivity.getBaseContext());
client.attest(nonce, API_KEY).addOnSuccessListener(this).addOnFailureListener(this);
client.attest(nonce, getApiKey()).addOnSuccessListener(this).addOnFailureListener(this);
}
private Dialog getErrorDialog(int errorCode, int requestCode) {