package g8; import android.content.Context; import android.content.SharedPreferences; import com.vungle.warren.VungleLogger; import java.io.File; import java.io.Serializable; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; /* loaded from: classes2.dex */ public class f { /* renamed from: a, reason: collision with root package name */ private final File f9763a; /* renamed from: b, reason: collision with root package name */ private final Executor f9764b; /* renamed from: c, reason: collision with root package name */ private final ConcurrentHashMap f9765c; /* renamed from: d, reason: collision with root package name */ private final SharedPreferences f9766d; /* renamed from: e, reason: collision with root package name */ private final HashSet f9767e; class a implements Runnable { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Serializable f9768a; a(Serializable serializable) { this.f9768a = serializable; } @Override // java.lang.Runnable public void run() { com.vungle.warren.utility.j.j(f.this.f9763a, this.f9768a); } } public f(Context context, Executor executor) { ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap(); this.f9765c = concurrentHashMap; this.f9767e = new HashSet(); this.f9764b = executor; File file = new File(context.getNoBackupFilesDir(), "vungle_settings"); this.f9763a = file; File file2 = new File(context.getFilesDir(), "vungle_settings"); if (file2.exists() && !file2.renameTo(file)) { VungleLogger.c("FilePreferences", "Can't move old FilePreferences"); } Object g10 = com.vungle.warren.utility.j.g(file); if (g10 instanceof HashMap) { concurrentHashMap.putAll((HashMap) g10); } this.f9766d = context.getSharedPreferences("com.vungle.sdk", 0); h(); } private void h() { for (Map.Entry entry : this.f9766d.getAll().entrySet()) { Object value = entry.getValue(); if (value instanceof Boolean) { l(entry.getKey(), ((Boolean) value).booleanValue()); } else if (value instanceof String) { j(entry.getKey(), (String) value); } else if (value instanceof Integer) { i(entry.getKey(), ((Integer) value).intValue()); } else if (value instanceof HashSet) { k(entry.getKey(), (HashSet) value); } } this.f9766d.edit().clear().apply(); c(); } public f b(String... strArr) { this.f9767e.addAll(Arrays.asList(strArr)); return this; } public void c() { this.f9764b.execute(new a(new HashMap(this.f9765c))); } public boolean d(String str, boolean z10) { Object obj = this.f9765c.get(str); return obj instanceof Boolean ? ((Boolean) obj).booleanValue() : z10; } public int e(String str, int i10) { Object obj = this.f9765c.get(str); return obj instanceof Integer ? ((Integer) obj).intValue() : i10; } public String f(String str, String str2) { Object obj = this.f9765c.get(str); return obj instanceof String ? (String) obj : str2; } public HashSet g(String str, HashSet hashSet) { Object obj = this.f9765c.get(str); return obj instanceof HashSet ? com.vungle.warren.utility.d.b((HashSet) obj) : hashSet; } public f i(String str, int i10) { this.f9765c.put(str, Integer.valueOf(i10)); if (this.f9767e.contains(str)) { this.f9766d.edit().putInt(str, i10).apply(); } return this; } public f j(String str, String str2) { this.f9765c.put(str, str2); if (this.f9767e.contains(str)) { this.f9766d.edit().putString(str, str2).apply(); } return this; } public f k(String str, HashSet hashSet) { this.f9765c.put(str, com.vungle.warren.utility.d.b(hashSet)); if (this.f9767e.contains(str)) { this.f9766d.edit().putStringSet(str, com.vungle.warren.utility.d.b(hashSet)).apply(); } return this; } public f l(String str, boolean z10) { this.f9765c.put(str, Boolean.valueOf(z10)); if (this.f9767e.contains(str)) { this.f9766d.edit().putBoolean(str, z10).apply(); } return this; } }