package com.fyber.inneractive.sdk.config; import android.app.Application; import android.content.SharedPreferences; import android.text.TextUtils; import com.fyber.inneractive.sdk.external.InneractiveAdManager; import com.fyber.inneractive.sdk.util.IAlog; /* loaded from: classes2.dex */ public final class d { public Boolean a = null; public Boolean b = null; public Boolean c = null; public String d = null; public String e = null; public InneractiveAdManager.GdprConsentSource f = null; public String g = null; public String h = null; public Boolean i = null; public Boolean j = null; public SharedPreferences k; public SharedPreferences l; public final void b() { IAlog.a("Clearing LGPD consent status", new Object[0]); if (com.fyber.inneractive.sdk.util.o.a == null) { IAlog.f("clearLgpdConsentStatus was invoked, but the Inneractive SDK was not properly initialized, or destroyed.", new Object[0]); return; } e(); this.i = null; SharedPreferences sharedPreferences = this.k; if (sharedPreferences != null) { sharedPreferences.edit().remove("IALgpdConsentStatus").apply(); } } public final void c() { IAlog.a("Clearing CCPA Consent String", new Object[0]); if (com.fyber.inneractive.sdk.util.o.a == null) { IAlog.f("clearUSPrivacyString was invoked, but the Inneractive SDK was not properly initialized, or destroyed.", new Object[0]); return; } e(); this.h = null; SharedPreferences sharedPreferences = this.k; if (sharedPreferences != null) { sharedPreferences.edit().remove("IACCPAConsentData").apply(); } } public final Boolean f() { k kVar; SharedPreferences sharedPreferences; m mVar = IAConfigManager.L.t; if (mVar != null && (kVar = mVar.b) != null) { int a = kVar.a(262, Integer.MIN_VALUE, "TcfVendorId"); if (a != 0 && (sharedPreferences = this.l) != null) { try { String string = sharedPreferences.getString("IABTCF_VendorConsents", null); if (string == null) { return null; } int i = (a >= 0 ? a : 262) - 1; return Boolean.valueOf(string.length() > i && string.charAt(i) == '1'); } catch (Exception unused) { } } } return null; } public final boolean a(boolean z, String str) { if (com.fyber.inneractive.sdk.util.o.a == null) { return false; } e(); SharedPreferences sharedPreferences = this.k; if (sharedPreferences == null) { return false; } sharedPreferences.edit().putBoolean(str, z).apply(); return true; } public final boolean d() { k kVar; SharedPreferences sharedPreferences; if (this.c == null) { m mVar = IAConfigManager.L.t; boolean z = false; if (mVar != null && (kVar = mVar.b) != null && kVar.a(1, Integer.MIN_VALUE, "TcfPurpose1") == 1 && (sharedPreferences = this.l) != null) { try { String string = sharedPreferences.getString("IABTCF_PurposeConsents", null); if (string != null && !string.isEmpty() && string.charAt(0) == '0') { z = true; } } catch (Exception unused) { IAlog.b("%sException caught when trying to resolveIsIabGdprPurpose1Disabled from prefs", IAlog.a(this)); } } this.c = Boolean.valueOf(z); } return this.c.booleanValue(); } public final void e() { String str; SharedPreferences sharedPreferences; Application application = com.fyber.inneractive.sdk.util.o.a; if (application != null) { if (this.l == null) { this.l = application.getSharedPreferences(application.getPackageName() + "_preferences", 0); } if (this.k == null) { SharedPreferences sharedPreferences2 = application.getSharedPreferences("IAConfigurationPreferences", 0); this.k = sharedPreferences2; if (sharedPreferences2 != null) { if (sharedPreferences2.contains("IAGDPRBool")) { this.a = Boolean.valueOf(sharedPreferences2.getBoolean("IAGDPRBool", false)); } else { this.b = f(); } if (sharedPreferences2.contains("IAGdprConsentData")) { this.d = sharedPreferences2.getString("IAGdprConsentData", null); } else { if (IAConfigManager.L.t.b.a(262, Integer.MIN_VALUE, "TcfVendorId") != 0 && (sharedPreferences = this.l) != null && sharedPreferences.contains("IABTCF_TCString")) { try { str = this.l.getString("IABTCF_TCString", null); } catch (Exception unused) { } this.e = str; } str = null; this.e = str; } if (sharedPreferences2.contains("IACCPAConsentData")) { this.h = sharedPreferences2.getString("IACCPAConsentData", null); } if (sharedPreferences2.contains("IAGdprSource")) { try { this.f = InneractiveAdManager.GdprConsentSource.valueOf(sharedPreferences2.getString("IAGdprSource", InneractiveAdManager.GdprConsentSource.Internal.toString())); } catch (Exception unused2) { this.f = InneractiveAdManager.GdprConsentSource.Internal; } } if (sharedPreferences2.contains("IALgpdConsentStatus")) { this.i = Boolean.valueOf(sharedPreferences2.getBoolean("IALgpdConsentStatus", false)); } if (sharedPreferences2.contains("keyUserID")) { this.g = sharedPreferences2.getString("keyUserID", null); } } } } } public final boolean a(String str, String str2) { if (com.fyber.inneractive.sdk.util.o.a == null) { return false; } e(); if (this.k == null) { return false; } IAlog.a("Saving %s value = %s to sharedPrefs", str, str2); this.k.edit().putString(str, str2).apply(); return true; } public final void a(String str) { if (com.fyber.inneractive.sdk.util.o.a != null) { e(); if (TextUtils.isEmpty(str)) { this.g = str; SharedPreferences sharedPreferences = this.k; if (sharedPreferences != null) { sharedPreferences.edit().remove("keyUserID").apply(); return; } return; } if (str.length() > 256) { str = str.substring(0, 256); } SharedPreferences sharedPreferences2 = this.k; if (sharedPreferences2 != null) { this.g = str; sharedPreferences2.edit().putString("keyUserID", str).apply(); } } } public final void a() { IAlog.a("Clearing GDPR Consent String and status", new Object[0]); if (com.fyber.inneractive.sdk.util.o.a == null) { IAlog.f("ClearGdprConsent was invoked, but the Inneractive SDK was not properly initialized, or destroyed.", new Object[0]); return; } e(); this.a = null; this.d = null; SharedPreferences sharedPreferences = this.k; if (sharedPreferences != null) { sharedPreferences.edit().remove("IAGdprConsentData").remove("IAGDPRBool").remove("IAGdprSource").apply(); } } }