Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit e4710185 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Few restructuring after b2d69656

parent b2d69656
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -147,7 +147,8 @@ public class Attestation {
    }

    private AttestResponse attest(AttestRequest request, String apiKey) throws IOException {
        HttpURLConnection connection = (HttpURLConnection) new URL(SafetyNetPrefs.get(context).getServiceUrl(apiKey)).openConnection();
        String requestUrl = SafetyNetPrefs.get(context).getServiceUrl() + "?alt=PROTO&key=" + apiKey;
        HttpURLConnection connection = (HttpURLConnection) new URL(requestUrl).openConnection();
        connection.setRequestMethod("POST");
        connection.setDoInput(true);
        connection.setDoOutput(true);
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import java.util.ArrayList;

public class SafetyNetClientServiceImpl extends ISafetyNetService.Stub {
    private static final String TAG = "GmsSafetyNetClientImpl";
    private static final String DEFAULT_API_KEY = "AIzaSyDqVnJBjE5ymo--oBJt3On7HQx9xNm1RHA";

    private Context context;
    private String packageName;
@@ -52,7 +53,7 @@ public class SafetyNetClientServiceImpl extends ISafetyNetService.Stub {

    @Override
    public void attest(ISafetyNetCallbacks callbacks, byte[] nonce) throws RemoteException {
        attestWithApiKey(callbacks, nonce, "AIzaSyDqVnJBjE5ymo--oBJt3On7HQx9xNm1RHA");
        attestWithApiKey(callbacks, nonce, DEFAULT_API_KEY);
    }

    @Override
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class SafetyNetPrefs implements SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String OFFICIAL_ATTEST_BASE_URL = "https://www.googleapis.com/androidcheck/v1/attestations/attest?alt=PROTO&key=";
    private static final String OFFICIAL_ATTEST_BASE_URL = "https://www.googleapis.com/androidcheck/v1/attestations/attest";

    public static final String PREF_SNET_DISABLED = "snet_disabled";
    public static final String PREF_SNET_OFFICIAL = "snet_official";
@@ -88,8 +88,8 @@ public class SafetyNetPrefs implements SharedPreferences.OnSharedPreferenceChang
        return official;
    }

    public String getServiceUrl(String apiKey) {
        if (official) return OFFICIAL_ATTEST_BASE_URL + apiKey;
    public String getServiceUrl() {
        if (official) return OFFICIAL_ATTEST_BASE_URL;
        return customUrl;
    }
}