package com.tapjoy; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.net.Uri; import com.facebook.gamingservices.cloudgaming.internal.SDKAnalyticsEvents; import com.ironsource.ad; import com.ironsource.v8; import com.tapjoy.TapjoyErrorMessage; import com.tapjoy.internal.a2; import com.tapjoy.internal.b2; import com.tapjoy.internal.c2; import com.tapjoy.internal.e2; import com.tapjoy.internal.f2; import com.tapjoy.internal.h2; import com.tapjoy.internal.p1; import com.tapjoy.internal.s2; import com.tapjoy.internal.t1; import com.tapjoy.internal.u1; import com.tapjoy.internal.w1; import com.tapjoy.internal.z1; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public class TapjoyConnectCore { public static TapjoyConnectCore l; public PackageManager h; public Context a = null; public TJConnectListener b = null; public boolean c = false; public String d = ""; public String e = ""; public String f = ""; public String g = ""; public Hashtable i = TapjoyConnectFlag.CONNECT_FLAG_DEFAULTS; public final ConcurrentLinkedQueue j = new ConcurrentLinkedQueue(); public final ExecutorService k = Executors.newSingleThreadExecutor(); public void addConnectFlag(String str, String str2) { if ((str.equals(TapjoyConnectFlag.SERVICE_URL) || str.equals(TapjoyConnectFlag.PLACEMENT_URL)) && !str2.endsWith("/")) { str2 = str2.concat("/"); } this.i.put(str, str2); } public final String b() { return this.f; } public final void b(final int i, final String str) { TapjoyUtil.runOnMainThread(new Runnable() { // from class: com.tapjoy.TapjoyConnectCore$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { TapjoyConnectCore.this.a(i, str); } }); } public final /* synthetic */ void c() { new w1().a(this.b); } public final /* synthetic */ void d() { new TJAppSetId().fetch(this.a, new TJTaskHandler() { // from class: com.tapjoy.TapjoyConnectCore$$ExternalSyntheticLambda4 @Override // com.tapjoy.TJTaskHandler public final void onComplete(Object obj) { TapjoyConnectCore.this.a((String) obj); } }); } public final /* synthetic */ void e() { TJTracking.INSTANCE.fetchAdvertisingID(this.a); } public String getAppID() { return this.d; } public Map getBaseURLParams() { t1 t1Var = new t1(); HashMap params = new HashMap(); e2 e2Var = t1Var.f; e2Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); Boolean bool = e2Var.a; String str = "0"; TapjoyUtil.safePut(params, TapjoyConstants.PREF_BELOW_CONSENT_AGE, bool != null ? bool.booleanValue() ? "1" : "0" : null, true); Boolean bool2 = e2Var.b; if (bool2 == null) { str = null; } else if (bool2.booleanValue()) { str = "1"; } TapjoyUtil.safePut(params, TapjoyConstants.PREF_SUBJECT_TO_GDPR, str, true); TapjoyUtil.safePut(params, TapjoyConstants.PREF_USER_CONSENT, e2Var.c, true); TapjoyUtil.safePut(params, TapjoyConstants.PREF_US_PRIVACY, e2Var.d, true); t1Var.g.a(params); f2 f2Var = t1Var.c; if (f2Var != null) { Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, TJVerifierKt.TJC_VERIFIER, f2Var.a, true); Boolean bool3 = f2Var.b; TapjoyUtil.safePut(params, "debug", bool3 != null ? bool3.toString() : null, true); TapjoyUtil.safePut(params, "test_id", f2Var.f, true); TapjoyUtil.safePut(params, "install_id", f2Var.g, true); TapjoyUtil.safePut(params, ad.E, f2Var.e, true); TapjoyUtil.safePut(params, "sdk_type", f2Var.c, true); TapjoyUtil.safePut(params, "library_version", f2Var.h, true); TapjoyUtil.safePut(params, "library_revision", f2Var.i, true); TapjoyUtil.safePut(params, "bridge_version", f2Var.j, true); TapjoyUtil.safePut(params, "installed", f2Var.d); h2 h2Var = f2Var.k; h2Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, SDKAnalyticsEvents.PARAMETER_SESSION_ID, h2Var.a, true); TapjoyUtil.safePut(params, "fq7", h2Var.g); TapjoyUtil.safePut(params, "fq30", h2Var.h); TapjoyUtil.safePut(params, "session_total_count", h2Var.d); TapjoyUtil.safePut(params, "session_total_length", h2Var.e); TapjoyUtil.safePut(params, "session_last_at", h2Var.c); TapjoyUtil.safePut(params, "session_last_length", h2Var.b); TapjoyUtil.safePut(params, "session_duration", h2Var.f); } p1 p1Var = t1Var.d; p1Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "app_id", p1Var.a, true); TapjoyUtil.safePut(params, "app_version", p1Var.d, true); TapjoyUtil.safePut(params, "app_group_id", p1Var.h, true); TapjoyUtil.safePut(params, "pkg_ver", p1Var.f, true); TapjoyUtil.safePut(params, "pkg_rev", p1Var.g, true); TapjoyUtil.safePut(params, "pkg_id", p1Var.e, true); c2 c2Var = p1Var.i; c2Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "cp", c2Var.a, true); z1 z1Var = t1Var.e; z1Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "managed_device_id", z1Var.a, true); TapjoyUtil.safePut(params, "device_name", z1Var.e, true); TapjoyUtil.safePut(params, "device_type", z1Var.b, true); TapjoyUtil.safePut(params, "connection_type", z1Var.c, true); TapjoyUtil.safePut(params, "connection_subtype", z1Var.d, true); TapjoyUtil.safePut(params, "volume", z1Var.f); TapjoyUtil.safePut(params, "brightness", z1Var.h); TapjoyUtil.safePut(params, "battery", z1Var.g); TapjoyUtil.safePut(params, "display_w", z1Var.i); TapjoyUtil.safePut(params, "display_h", z1Var.j); TapjoyUtil.safePut(params, "display_d", z1Var.k); TapjoyUtil.safePut(params, "screen_density", z1Var.k); a2 a2Var = z1Var.l; a2Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "country_code", a2Var.a, true); b2 b2Var = z1Var.n; b2Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "advertising_id", b2Var.e, true); TapjoyUtil.safePut(params, "platform", b2Var.f, true); TapjoyUtil.safePut(params, "os_version", b2Var.g, true); TapjoyUtil.safePut(params, "language_code", b2Var.a, true); TapjoyUtil.safePut(params, "theme", b2Var.i, true); TapjoyUtil.safePut(params, "timezone", b2Var.h, true); TapjoyUtil.safePut(params, v8.h.U, b2Var.b, true); TapjoyUtil.safePut(params, "store_view", String.valueOf(b2Var.c), true); TapjoyUtil.safePut(params, "ad_tracking_enabled", String.valueOf(b2Var.d), true); com.tapjoy.internal.o1 o1Var = b2Var.j; o1Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "android_id", o1Var.d, true); TapjoyUtil.safePut(params, "device_manufacturer", o1Var.e, true); TapjoyUtil.safePut(params, "installer", o1Var.b, true); TapjoyUtil.safePut(params, "ad_id_check_disabled", String.valueOf(o1Var.i), true); TapjoyUtil.safePut(params, "legacy_id_fallback_allowed", String.valueOf(o1Var.j), true); TapjoyUtil.safePut(params, "packaged_gps_version", o1Var.g, true); TapjoyUtil.safePut(params, "device_gps_version", o1Var.f, true); TapjoyUtil.safePut(params, "optout_adid", String.valueOf(o1Var.h), true); TapjoyUtil.safePut(params, "app_set_id", o1Var.c, true); TapjoyUtil.safePut(params, "pkg_sign", o1Var.k, true); TapjoyUtil.safePut(params, "screen_layout_size", o1Var.a); TapjoyUtil.safePut(params, "avail_disk", o1Var.l); TapjoyUtil.safePut(params, "total_disk", o1Var.m); u1 u1Var = z1Var.m; u1Var.getClass(); Intrinsics.checkNotNullParameter(params, "params"); TapjoyUtil.safePut(params, "carrier_name", u1Var.a, true); TapjoyUtil.safePut(params, "carrier_country_code", u1Var.c, true); TapjoyUtil.safePut(params, "mobile_network_code", u1Var.e, true); TapjoyUtil.safePut(params, "mobile_country_code", u1Var.d, true); TapjoyUtil.safePut(params, "country_sim", u1Var.f, true); TapjoyUtil.safePut(params, "timestamp", Long.valueOf(t1Var.b)); return params; } public String getConnectURL() { return TapjoyConfig.TJC_CONNECT_SERVICE_URL; } public Context getContext() { return this.a; } public String getCustomParameter() { return this.e; } public String getHostURL() { return getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL); } public String getPlacementURL() { return getConnectFlagValue(TapjoyConnectFlag.PLACEMENT_URL); } public String getRedirectDomain() { return this.g; } public boolean isConnected() { return this.c; } public boolean isViewOpen() { TapjoyLog.d("TapjoyConnect", "isViewOpen: " + this.j.size()); return !this.j.isEmpty(); } public void requestTapjoyConnect(Context context, String str, Hashtable hashtable, TJConnectListener tJConnectListener) { try { com.tapjoy.internal.f fVar = new com.tapjoy.internal.f(str); if (fVar.c != 1) { throw new IllegalArgumentException("The given API key was not for Android."); } this.d = fVar.d; this.f = fVar.e; if (hashtable != null) { this.i.putAll(hashtable); com.tapjoy.internal.a1 a1Var = s2.c.a; a1Var.getClass(); HashMap hashMap = new HashMap(); for (Map.Entry entry : hashtable.entrySet()) { String str2 = (String) com.tapjoy.internal.a1.f.get(entry.getKey()); if (str2 == null) { str2 = entry.getKey(); } a1Var.c.a.remove(str2); hashMap.put(str2, entry.getValue()); } a1Var.d.a = hashMap; a1Var.setChanged(); } com.tapjoy.internal.s sVar = com.tapjoy.internal.s.b; synchronized (sVar) { if (sVar.a == null) { Context applicationContext = context.getApplicationContext(); sVar.a = applicationContext; s2.c.a(applicationContext); com.tapjoy.internal.u.a(applicationContext); } } this.b = tJConnectListener; try { a(context); a(); } catch (TapjoyIntegrationException e) { TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.INTEGRATION_ERROR, e.getMessage())); b(1, e.getMessage()); com.tapjoy.internal.y.b.notifyObservers(Boolean.FALSE); } catch (TapjoyException e2) { TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, e2.getMessage())); b(2, e2.getMessage()); com.tapjoy.internal.y.b.notifyObservers(Boolean.FALSE); } } catch (IllegalArgumentException e3) { throw new TapjoyIntegrationException(e3.getMessage()); } } public void setConnected(boolean z) { this.c = z; } public void setCustomParameter(String str) { this.e = str; } public void viewDidClose(String str) { TapjoyLog.d("TapjoyConnect", "viewDidClose: " + str); this.j.remove(str); com.tapjoy.internal.y.c.notifyObservers(); } public void viewWillOpen(String str) { TapjoyLog.d("TapjoyConnect", "viewWillOpen: " + str); this.j.offer(str); } public static TapjoyConnectCore getInstance() { if (l == null) { l = new TapjoyConnectCore(); } return l; } public final /* synthetic */ void a(int i, String str) { TJConnectListener tJConnectListener = this.b; if (tJConnectListener != null) { tJConnectListener.onConnectFailure(i, str); } } public final void a() { this.k.execute(new Runnable() { // from class: com.tapjoy.TapjoyConnectCore$$ExternalSyntheticLambda1 @Override // java.lang.Runnable public final void run() { TapjoyConnectCore.this.d(); } }); } public String getConnectFlagValue(String str) { Hashtable hashtable = this.i; return (hashtable == null || hashtable.get(str) == null) ? "" : this.i.get(str).toString(); } public String getSupportURL(String str) { if (str == null) { str = this.d; } return getHostURL() + "support_requests/new?currency_id=" + str + "&app_id=" + this.d + "&udid=" + TJAppInfo.INSTANCE.getManagedDeviceID() + "&language_code=" + Locale.getDefault().getLanguage(); } public void release() { l = null; TapjoyLog.d("TapjoyConnect", "Releasing core static instance."); } public final /* synthetic */ void a(String str) { TJTracking.INSTANCE.setAppSetID(str); this.k.execute(new Runnable() { // from class: com.tapjoy.TapjoyConnectCore$$ExternalSyntheticLambda3 @Override // java.lang.Runnable public final void run() { TapjoyConnectCore.this.c(); } }); } public final void a(Context context) { this.a = context; this.h = context.getPackageManager(); TJUser.INSTANCE.setContext(context); TJSession.INSTANCE.setContext(context); TJPurchases.INSTANCE.setContext(context); TJTracking.INSTANCE.setContext(context); TJDeviceNetwork.INSTANCE.setContext(context); TJAppInfo.INSTANCE.setContext(context); TJStore.INSTANCE.setContext(context); TJPrivacyPolicy.getInstance().a(context); s2.c.a(context); this.k.submit(new Runnable() { // from class: com.tapjoy.TapjoyConnectCore$$ExternalSyntheticLambda2 @Override // java.lang.Runnable public final void run() { TapjoyConnectCore.this.e(); } }); if (this.i == null) { this.i = new Hashtable(); } try { PackageManager packageManager = this.h; if (packageManager != null) { ApplicationInfo applicationInfo = packageManager.getApplicationInfo(this.a.getPackageName(), 128); if (applicationInfo != null && applicationInfo.metaData != null) { for (String str : TapjoyConnectFlag.FLAG_ARRAY) { String string = applicationInfo.metaData.getString("tapjoy." + str); if (string != null) { TapjoyLog.d("TapjoyConnect", "Found manifest flag: " + str + ", " + string); addConnectFlag(str, string); } } TapjoyLog.d("TapjoyConnect", "Metadata successfully loaded"); } else { TapjoyLog.d("TapjoyConnect", "No metadata present."); } } } catch (Exception e) { TapjoyLog.e("TapjoyConnect", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error reading manifest meta-data -- " + e.toString())); } int identifier = this.a.getResources().getIdentifier("raw/tapjoy_config", null, this.a.getPackageName()); if (identifier != 0) { try { Properties properties = new Properties(); properties.load(this.a.getResources().openRawResource(identifier)); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { try { String str2 = (String) keys.nextElement(); addConnectFlag(str2, (String) properties.get(str2)); } catch (ClassCastException unused) { TapjoyLog.e("TapjoyConnect", "Error parsing configuration properties in tapjoy_config.txt"); } } } catch (Exception unused2) { } } TJIntegrationCheck.INSTANCE.integrationCheck(this.a); this.g = TapjoyUtil.getRedirectDomain(getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL)); if (this.i != null) { TapjoyLog.i("TapjoyConnect", "Connect Flags:"); TapjoyLog.i("TapjoyConnect", "--------------------"); for (Map.Entry entry : this.i.entrySet()) { TapjoyLog.i("TapjoyConnect", "key: " + ((String) entry.getKey()) + ", value: " + Uri.encode(entry.getValue().toString())); } TapjoyLog.i("TapjoyConnect", "hostURL: [" + getConnectFlagValue(TapjoyConnectFlag.SERVICE_URL) + v8.i.e); TapjoyLog.i("TapjoyConnect", "redirectDomain: [" + this.g + v8.i.e); TapjoyLog.i("TapjoyConnect", "--------------------"); } new TapjoyCache(context); } }