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

Commit c18df654 authored by Anirudh Gupta's avatar Anirudh Gupta Committed by Rohit Sekhar
Browse files

safetynet: Set shipping level to 32 for devices >=33

If ro.product.first_api_level is 33, its forced to use HW attestation even though the safteynet checker app shows BASIC
setting it to 32 allows for software attestation and passing CTS

Change-Id: Ie7326eaac48424cdea3d9633ebe13c65053ef6c1
parent 101d4aa8
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.util.Arrays;

import android.app.Application;
import android.os.Build;
import android.os.Build.VERSION;
import android.util.Log;

public final class SafetyNetHooks {
@@ -44,6 +45,22 @@ public final class SafetyNetHooks {
        }
    }

    private static void setVersionField(String key, Integer value) {
        try {
            // Unlock
            Field field = Build.VERSION.class.getDeclaredField(key);
            field.setAccessible(true);

            // Edit
            field.set(null, value);

            // Lock
            field.setAccessible(false);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            Log.e(TAG, "Failed to spoof Build." + key, e);
        }
    }

    public static void init(Application app) {
        if (GMS_PACKAGE_NAME.equals(app.getPackageName())) {
            sIsGms = true;
@@ -51,6 +68,7 @@ public final class SafetyNetHooks {
            setBuildField("DEVICE", SPOOFED_DEVICE_PRODUCT);
            setBuildField("PRODUCT", SPOOFED_DEVICE_PRODUCT);
            setBuildField("FINGERPRINT", SPOOFED_FINGERPRINT);
            setVersionField("DEVICE_INITIAL_SDK_INT", Build.VERSION_CODES.S);
        }
    }