package fuzion24.device.vulnerability.util;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SharedPreferencesUtils {

    private static final String PREFS_LAST_LIST_OF_SCANS = "PREFS_LIST_OF_SCANS";
    private static final String PREFS_FIRST_RUN = "PREFS_FIRST_RUN";
    private static final String PREFS_AUTOMATIC_SHARING_ENABLE = "PREFS_AUTOMATIC_SHARING_ENABLE";

    private static final String PREFS_NAME = "com.nowsecure.android.vts.PREFERENCE_FILE_KEY";

    private static SharedPreferences getPreferences(Context context) {
        return context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    }

    public static Boolean isAutomaticSharingEnable(Context context) {
        return  getPreferences(context).getBoolean(PREFS_AUTOMATIC_SHARING_ENABLE, false);
    }

    public static void setIsAutomaticSharingEnable(Context context, Boolean isAutomaticSharingEnable) {
        getPreferences(context).edit().putBoolean(PREFS_AUTOMATIC_SHARING_ENABLE, isAutomaticSharingEnable).commit();
    }

    public static Boolean isTheFirstRun(Context context) {
        return getPreferences(context).getBoolean(PREFS_FIRST_RUN, true);
    }

    public static void disableFirstRun(Context context) {
        getPreferences(context).edit().putBoolean(PREFS_FIRST_RUN, false).commit();
    }


    public static List<String> getTheListOfScansAvailable(Context context) {
        Set<String> listOfPreviousScans = getPreferences(context).getStringSet(PREFS_LAST_LIST_OF_SCANS, null);

        if (listOfPreviousScans == null) {
            return null;
        }

        List<String> listOfScans = Arrays.asList(listOfPreviousScans.toArray(new String[listOfPreviousScans.size()]));

        return listOfScans;
    }

    public static void setTheListOfScansAvailable(Context context, List<String> listOfScans) {
        SharedPreferences.Editor editor = getPreferences(context).edit();

        editor.putStringSet(PREFS_LAST_LIST_OF_SCANS, new HashSet<>(listOfScans));

        editor.apply();
    }

}

@@ -499,16 +499,102 @@
 NABLE%22;%0A
+    private static final String BUILD_FINGERPRINT_HASH   = %22BUILD_FINGERPRINT_HASH%22;%0A%0A
 %0A    pri
@@ -2234,10 +2234,423 @@
 %0A    %7D%0A%0A
+    public static void setBuildUpdateFingerPrint(Context context, String fingerprint)%7B%0A        SharedPreferences.Editor editor = getPreferences(context).edit();%0A%0A        editor.putString(BUILD_FINGERPRINT_HASH, fingerprint);%0A%0A        editor.apply();%0A    %7D%0A%0A    public static String getBuildUpdateFingerprint(Context context)%7B%0A        return getPreferences(context).getString(BUILD_FINGERPRINT_HASH, null);%0A    %7D%0A%0A
 %7D%0A

Add some helper methods to set and get the build fingerprint