package com.applovin.sdk; import android.content.Context; import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.applovin.impl.h4; import com.applovin.impl.i4; import com.applovin.impl.sdk.AppLovinSdkSettingsBase; import com.applovin.impl.sdk.j; import com.applovin.impl.sdk.n; import com.applovin.impl.sdk.utils.CollectionUtils; import com.applovin.impl.sdk.utils.JsonUtils; import com.applovin.impl.sdk.utils.StringUtils; import com.applovin.impl.yp; import csdk.gluads.Consts; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.json.JSONObject; /* loaded from: classes2.dex */ public class AppLovinSdkSettings extends AppLovinSdkSettingsBase { private boolean a; private boolean b; private String f; private String g; private j k; private String l; private boolean e = true; private final Map localSettings = new HashMap(); private List h = Collections.emptyList(); private List i = Collections.emptyList(); private final Map j = Collections.synchronizedMap(new HashMap()); private boolean c = true; private boolean d = true; public AppLovinSdkSettings(Context context) { this.l = ""; if (context == null) { n.h("AppLovinSdkSettings", "context cannot be null. Please provide a valid context."); } Context d = yp.d(context); this.a = yp.k(d); this.backingConsentFlowSettings = h4.a(d); this.l = d.getPackageName(); a(d); } private void a(Context context) { int identifier = context.getResources().getIdentifier("applovin_settings", "raw", context.getPackageName()); if (identifier == 0) { return; } String a = yp.a(identifier, context, (j) null); this.j.putAll(JsonUtils.tryToStringMap(StringUtils.isValidString(a) ? JsonUtils.jsonObjectFromJsonString(a, new JSONObject()) : new JSONObject())); } public Map getExtraParameters() { Map map; synchronized (this.j) { map = CollectionUtils.map(this.j); } return map; } @Deprecated public List getInitializationAdUnitIds() { return this.i; } public AppLovinTermsAndPrivacyPolicyFlowSettings getTermsAndPrivacyPolicyFlowSettings() { ((i4) this.backingConsentFlowSettings).a(i4.a.UNIFIED); return this.backingConsentFlowSettings; } @Deprecated public AppLovinTermsFlowSettings getTermsFlowSettings() { ((i4) this.backingConsentFlowSettings).a(i4.a.TERMS); return this.backingConsentFlowSettings; } @Deprecated public List getTestDeviceAdvertisingIds() { return this.h; } public boolean isCreativeDebuggerEnabled() { return this.c; } @Deprecated public boolean isExceptionHandlerEnabled() { return this.d; } public boolean isMuted() { return this.b; } public boolean isVerboseLoggingEnabled() { return this.a; } public void setCreativeDebuggerEnabled(boolean z) { n.e("AppLovinSdkSettings", "setCreativeDebuggerEnabled(creativeDebuggerEnabled=" + z + ")"); if (this.c == z) { return; } this.c = z; j jVar = this.k; if (jVar == null) { return; } if (z) { jVar.w().l(); } else { jVar.w().k(); } } @Deprecated public void setExceptionHandlerEnabled(boolean z) { n.e("AppLovinSdkSettings", "setExceptionHandlerEnabled(exceptionHandlerEnabled=" + z + ")"); this.d = z; } public void setExtraParameter(String str, @Nullable String str2) { n.e("AppLovinSdkSettings", "setExtraParameter(key=" + str + ", value=" + str2 + ")"); if (TextUtils.isEmpty(str)) { n.h("AppLovinSdkSettings", "Failed to set extra parameter for null or empty key: " + str); return; } String trim = str2 != null ? str2.trim() : null; if (Consts.MAX_TEST_MODE_NETWORK.equalsIgnoreCase(str)) { if (this.k == null) { this.f = trim; } else if (StringUtils.isValidString(trim)) { this.k.l0().a(Arrays.asList(trim.split(","))); } else { this.k.l0().a((String) null); } } else if ("fan".equals(str) || "esc".equals(str)) { if (!this.l.startsWith("com.unity.")) { return; } } else if ("disable_all_logs".equals(str)) { n.a(Boolean.parseBoolean(trim)); } this.j.put(str, trim); } @Deprecated public void setInitializationAdUnitIds(List list) { n.e("AppLovinSdkSettings", "setInitializationAdUnitIds(initializationAdUnitIds=" + list + ")"); if (list == null) { this.i = Collections.emptyList(); return; } ArrayList arrayList = new ArrayList(list.size()); for (String str : list) { if (StringUtils.isValidString(str) && str.length() > 0) { if (str.length() == 16) { arrayList.add(str); } else { n.h("AppLovinSdkSettings", "Unable to set initialization ad unit id (" + str + ") - please make sure it is in the format of XXXXXXXXXXXXXXXX"); } } } this.i = arrayList; } public void setMuted(boolean z) { n.e("AppLovinSdkSettings", "setMuted(muted=" + z + ")"); this.b = z; } public void setShouldFailAdDisplayIfDontKeepActivitiesIsEnabled(boolean z) { n.e("AppLovinSdkSettings", "setShouldFailAdDisplayIfDontKeepActivitiesIsEnabled(shouldFailAdDisplayIfDontKeepActivitiesIsEnabled=" + z + ")"); this.e = z; } @Deprecated public void setTestDeviceAdvertisingIds(List list) { n.e("AppLovinSdkSettings", "setTestDeviceAdvertisingIds(testDeviceAdvertisingIds=" + list + ")"); if (list == null) { this.h = Collections.emptyList(); return; } ArrayList arrayList = new ArrayList(list.size()); for (String str : list) { if (str == null || str.length() != 36) { n.h("AppLovinSdkSettings", "Unable to set test device advertising id (" + str + ") - please make sure it is in the format of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"); } else { arrayList.add(str); } } this.h = arrayList; } public void setUserIdentifier(String str) { n.e("AppLovinSdkSettings", "setUserIdentifier(userIdentifier=" + str + ")"); if (StringUtils.isValidString(str) && str.length() > yp.b(8)) { n.h("AppLovinSdk", "Provided user id longer than supported (" + str.length() + " bytes, " + yp.b(8) + " maximum)"); } j jVar = this.k; if (jVar == null) { this.g = str; return; } jVar.J(); if (n.a()) { this.k.J().a("AppLovinSdkSettings", "Setting user id: " + str); } this.k.q0().a(str); } public void setVerboseLogging(boolean z) { n.e("AppLovinSdkSettings", "setVerboseLogging(isVerboseLoggingEnabled=" + z + ")"); if (!yp.k()) { this.a = z; return; } n.h("AppLovinSdkSettings", "Ignoring setting of verbose logging - it is configured from Android manifest already."); if (yp.k(null) != z) { n.h("AppLovinSdkSettings", "Attempted to programmatically set verbose logging flag to value different from value configured in Android Manifest."); } } public boolean shouldFailAdDisplayIfDontKeepActivitiesIsEnabled() { return this.e; } @NonNull public String toString() { return "AppLovinSdkSettings{isVerboseLoggingEnabled=" + this.a + ", muted=" + this.b + ", testDeviceAdvertisingIds=" + this.h.toString() + ", initializationAdUnitIds=" + this.i.toString() + ", creativeDebuggerEnabled=" + this.c + ", exceptionHandlerEnabled=" + this.d + '}'; } @Nullable public String getUserIdentifier() { j jVar = this.k; return jVar == null ? this.g : jVar.q0().c(); } public void attachAppLovinSdk(j jVar) { this.k = jVar; if (StringUtils.isValidString(this.f)) { jVar.l0().a(Arrays.asList(this.f.split(","))); this.f = null; } if (this.g != null) { jVar.J(); if (n.a()) { jVar.J().a("AppLovinSdkSettings", "Setting user id: " + this.g); } jVar.q0().a(this.g); this.g = null; } } }