package com.sigmob.sdk.base; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import com.czhj.sdk.common.ClientMetadata; import com.czhj.sdk.common.models.Config; import com.czhj.sdk.common.network.Networking; import com.czhj.sdk.common.network.SigmobRequestQueue; import com.czhj.sdk.common.track.TrackManager; import com.czhj.sdk.logger.SigmobLog; import com.czhj.volley.VolleyError; import com.czhj.wire.Wire; import com.mbridge.msdk.foundation.entity.DomainCampaignEx; import com.meishu.sdk.meishu_ad.view.scaleImage.SubsamplingScaleImageView; import com.sigmob.sdk.b; import com.sigmob.sdk.base.models.config.SigmobAndroid; import com.sigmob.sdk.base.models.config.SigmobCommon; import com.sigmob.sdk.base.models.config.SigmobCommonEndpointsConfig; import com.sigmob.sdk.base.models.config.SigmobDialogSetting; import com.sigmob.sdk.base.models.config.SigmobNativeConfig; import com.sigmob.sdk.base.models.config.SigmobRvConfig; import com.sigmob.sdk.base.models.config.SigmobSdkConfig; import com.sigmob.sdk.base.models.config.SigmobSdkConfigResponse; import com.sigmob.sdk.base.models.config.SigmobSplashConfig; import com.sigmob.sdk.base.network.f; import com.sigmob.sdk.base.utils.c; import com.sigmob.sdk.base.utils.e; import com.sigmob.windad.WindAdOptions; import com.sigmob.windad.WindAds; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.List; public class i { private static final String a = "sdkConfigVer"; private static i b = null; private static boolean c = false; private final Handler d = new Handler(Looper.getMainLooper()); /* renamed from: e reason: collision with root package name */ private final Runnable f15459e = new Runnable() { /* class com.sigmob.sdk.base.i.AnonymousClass1 */ public void run() { i.this.V(); } }; /* renamed from: f reason: collision with root package name */ private final String f15460f = h.j; /* renamed from: g reason: collision with root package name */ private boolean f15461g = true; /* renamed from: h reason: collision with root package name */ private long f15462h = 0; /* renamed from: i reason: collision with root package name */ private SigmobSdkConfig f15463i = null; private SigmobSdkConfig j = null; private a k; public interface a { void a(); } private i() { U(); } private void U() { if (this.f15463i == null) { SigmobSdkConfig.Builder builder = new SigmobSdkConfig.Builder(); SigmobCommon.Builder builder2 = new SigmobCommon.Builder(); SigmobAndroid.Builder builder3 = new SigmobAndroid.Builder(); builder2.endpoints(new SigmobCommonEndpointsConfig.Builder().build()); SigmobRvConfig.Builder builder4 = new SigmobRvConfig.Builder(); builder4.cacheTop(4); builder2.rv_config(builder4.build()); builder2.configRefresh(1000); builder2.disable_up_location(true); builder2.is_gdpr_region(false); builder2.enable_debug_level(false); builder3.disable_boot_mark(true); builder3.disableUpAppInfo(true); builder3.oaid_api_is_disable(true); builder3.enable_permission(false); builder3.enable_report_crash(false); builder.common_config(builder2.build()); builder.android_config(builder3.build()); this.f15463i = builder.build(); } SigmobLog.d("Default config: " + this.f15463i.toString()); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void V() { if (b.e() != null) { if (!ClientMetadata.getInstance().isNetworkConnected(c()) || !c.a().i()) { SigmobLog.d("Can't load an ad because there is no network connectivity."); Z(); return; } X(); } } private boolean W() { SigmobCommon j2 = j(); if (j2 != null) { return ((Boolean) Wire.get(j2.log_enc, false)).booleanValue(); } return false; } private void X() { SigmobRequestQueue sigRequestQueue = Networking.getSigRequestQueue(); f fVar = new f(c(), new f.a() { /* class com.sigmob.sdk.base.i.AnonymousClass2 */ @Override // com.sigmob.sdk.base.network.f.a public void a(SigmobSdkConfigResponse sigmobSdkConfigResponse) { SigmobLog.d(sigmobSdkConfigResponse.toString()); final SigmobSdkConfig sigmobSdkConfig = sigmobSdkConfigResponse.config; if (sigmobSdkConfig != null) { WindAds.sharedAds().getHandler().post(new Runnable() { /* class com.sigmob.sdk.base.i.AnonymousClass2.AnonymousClass1 */ public void run() { i.this.b((i) sigmobSdkConfig); } }); i.this.a((i) sigmobSdkConfig); } else { SigmobLog.e(sigmobSdkConfigResponse.error_message); } i.this.Z(); } @Override // com.czhj.volley.Response.ErrorListener public void onErrorResponse(VolleyError volleyError) { SigmobLog.e(volleyError.toString()); i.this.Z(); } }); if (sigRequestQueue == null) { SigmobLog.e("queue is null"); Z(); return; } sigRequestQueue.add(fVar); SigmobLog.i("update sdk config"); } private void Y() { this.d.removeCallbacks(this.f15459e); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void Z() { Y(); if (this.f15461g) { this.d.postDelayed(this.f15459e, Math.max(30000L, this.f15462h)); } } public static synchronized i a() { i iVar; synchronized (i.class) { if (b == null) { b = new i(); } iVar = b; } return iVar; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:20:0x0063 */ /* JADX WARNING: Removed duplicated region for block: B:24:0x0072 A[SYNTHETIC, Splitter:B:24:0x0072] */ /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */ private void a(SigmobSdkConfig sigmobSdkConfig) { Throwable th; IOException e2; if (sigmobSdkConfig != null) { ObjectOutputStream objectOutputStream = null; File file = new File(c.a() + "/config"); if (file.exists()) { file.delete(); } file.getParentFile().mkdirs(); try { ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(new FileOutputStream(file)); try { sigmobSdkConfig.encode(objectOutputStream2); e.a().edit().putString(a, h.j).apply(); try { objectOutputStream2.close(); } catch (IOException e3) { SigmobLog.e(e3.getMessage()); } } catch (IOException e4) { e2 = e4; objectOutputStream = objectOutputStream2; try { SigmobLog.e(e2.getMessage()); if (objectOutputStream == null) { } } catch (Throwable th2) { th = th2; if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (IOException e5) { SigmobLog.e(e5.getMessage()); } } throw th; } } catch (Throwable th3) { th = th3; objectOutputStream = objectOutputStream2; if (objectOutputStream != null) { } throw th; } } catch (IOException e6) { e2 = e6; SigmobLog.e(e2.getMessage()); if (objectOutputStream == null) { objectOutputStream.close(); } } } } private SigmobSplashConfig aa() { if (j() != null) { return j().splash_config; } return null; } private SigmobNativeConfig ab() { if (j() != null) { return j().native_config; } return null; } public static String b() { return "appId=" + WindAds.sharedAds().getAppId() + "&" + "sdkVersion=4.15.2"; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(SigmobSdkConfig sigmobSdkConfig) { SigmobCommon sigmobCommon; if (sigmobSdkConfig != null && (sigmobCommon = sigmobSdkConfig.sigmobCommon_config) != null) { this.j = sigmobSdkConfig; this.f15462h = (long) (((Integer) Wire.get(sigmobCommon.configRefresh, Integer.valueOf((int) DomainCampaignEx.TTC_CT2_DEFAULT_VALUE))).intValue() * 1000); SigmobLog.d("config: " + sigmobSdkConfig.toString()); a aVar = this.k; if (aVar != null) { aVar.a(); } Config.sharedInstance().setEnable_okhttp3(R()); Config.sharedInstance().update(c, T(), Q(), M(), l(), E(), D(), W()); TrackManager.getInstance().setRetryInterval((long) C()); TrackManager.getInstance().setRetryExpiredTime(B()); } } public static String c() { String str; WindAdOptions options = WindAds.sharedAds().getOptions(); if (options == null || options.getExtData() == null || (str = options.getExtData().get(h.c)) == null || TextUtils.isEmpty(str)) { if (!TextUtils.isEmpty(h.f15455f)) { return h.f15455f + "?" + b(); } return "https://adservice.sigmob.cn/s/config?" + b(); } else if (str.indexOf(63) == -1) { return str + "?" + b(); } else { return str + "&" + b(); } } public static String d() { return "https://adservice.sigmob.cn/extconfig?" + b(); } public static boolean h() { return c; } public int A() { if (!x() || j().anti_fraud_log.motion_config == null) { return 0; } return j().anti_fraud_log.motion_config.queue_max.intValue() + -50 < j().anti_fraud_log.motion_config.count.intValue() * 2 ? (((Integer) Wire.get(j().anti_fraud_log.motion_config.count, 0)).intValue() * 2) + 50 : ((Integer) Wire.get(j().anti_fraud_log.motion_config.queue_max, 0)).intValue(); } public long B() { long intValue = j() != null ? (long) ((Integer) Wire.get(j().tracking_expiration_time, 86400)).intValue() : 86400; if (intValue < 180) { return 180; } return intValue; } public int C() { SigmobCommon j2 = j(); int i2 = SubsamplingScaleImageView.ORIENTATION_180; if (j2 != null) { i2 = ((Integer) Wire.get(j().tracking_retry_interval, Integer.valueOf((int) SubsamplingScaleImageView.ORIENTATION_180))).intValue(); } if (i2 < 10) { return 10; } return i2; } public int D() { int intValue = SigmobCommon.DEFAULT_MAX_SEND_LOG_RECORDS.intValue(); if (j() != null) { intValue = ((Integer) Wire.get(j().max_send_log_records, SigmobCommon.DEFAULT_MAX_SEND_LOG_RECORDS)).intValue(); } return intValue < 10 ? SigmobCommon.DEFAULT_MAX_SEND_LOG_RECORDS.intValue() : intValue; } public int E() { int intValue; if (j() == null || (intValue = ((Integer) Wire.get(j().send_log_interval, 3)).intValue()) < 3) { return 3; } return intValue; } public List<Integer> F() { if (j() != null) { return j().dclog_blacklist; } return null; } public boolean G() { if (j() != null) { return ((Boolean) Wire.get(j().enable_debug_level, false)).booleanValue(); } return false; } public long H() { if (j() == null) { return 0; } long intValue = (long) ((Integer) Wire.get(j().load_interval, 0)).intValue(); if (intValue < 1) { return 0; } return intValue * 1000; } public boolean I() { if (j() != null) { return ((Boolean) Wire.get(j().disable_up_location, false)).booleanValue(); } return true; } public boolean J() { if (k() != null) { return ((Boolean) Wire.get(k().disableUpAppInfo, false)).booleanValue(); } return true; } public int K() { if (k() != null) { return ((Integer) Wire.get(k().report_log, 0)).intValue(); } return 0; } public boolean L() { SigmobAndroid k2 = k(); return k2 != null && ((Integer) Wire.get(k2.up_wifi_list_interval, 0)).intValue() >= 60; } public int M() { if (k() != null) { return ((Integer) Wire.get(k().disable_up_oaid, 0)).intValue(); } return 0; } public boolean N() { if (k() != null) { return ((Boolean) Wire.get(k().enable_permission, false)).booleanValue(); } return false; } public int O() { if (k() != null) { return ((Integer) Wire.get(k().apk_expired_time, 0)).intValue(); } return 0; } public boolean P() { if (k() != null) { return ((Boolean) Wire.get(k().enable_report_crash, false)).booleanValue(); } return false; } public boolean Q() { if (k() != null) { return ((Boolean) Wire.get(k().oaid_api_is_disable, false)).booleanValue(); } return true; } public boolean R() { return false; } public int S() { if (k() != null) { return ((Integer) Wire.get(k().enable_app_list, 0)).intValue(); } return 0; } public boolean T() { if (k() != null) { return ((Boolean) Wire.get(k().disable_boot_mark, false)).booleanValue(); } return true; } public i a(a aVar) { this.k = aVar; return b; } public boolean a(String str) { if (!x() || j().anti_fraud_log.events == null) { return false; } return j().anti_fraud_log.events.contains(str); } /* JADX WARNING: Removed duplicated region for block: B:16:0x0060 */ /* JADX WARNING: Removed duplicated region for block: B:28:? A[RETURN, SYNTHETIC] */ public void e() { Throwable th; ObjectInputStream objectInputStream; String string = e.a().getString(a, null); File file = new File(c.a() + "/config"); if (!h.j.equals(string) || !file.exists()) { b(this.f15463i); return; } try { objectInputStream = new ObjectInputStream(new FileInputStream(file)); try { b(SigmobSdkConfig.ADAPTER.decode(objectInputStream)); try { objectInputStream.close(); return; } catch (Throwable th2) { SigmobLog.e(th2.getMessage()); return; } } catch (Throwable th3) { th = th3; try { b(this.f15463i); SigmobLog.e(th.getMessage()); if (objectInputStream == null) { objectInputStream.close(); return; } return; } catch (Throwable th4) { SigmobLog.e(th4.getMessage()); } } } catch (Throwable th5) { th = th5; objectInputStream = null; b(this.f15463i); SigmobLog.e(th.getMessage()); if (objectInputStream == null) { } } throw th; } public void f() { Y(); this.d.post(this.f15459e); } public boolean g() { SigmobCommon j2 = j(); if (j2 != null) { return ((Boolean) Wire.get(j2.feedback_debug, false)).booleanValue(); } return false; } public SigmobSdkConfig i() { SigmobSdkConfig sigmobSdkConfig = this.j; return sigmobSdkConfig == null ? this.f15463i : sigmobSdkConfig; } public SigmobCommon j() { if (i() == null) { return null; } return i().sigmobCommon_config; } public SigmobAndroid k() { if (i() == null) { return null; } return i().sigmobAndroid_config; } public String l() { StringBuilder sb; String str; String str2 = j().endpoints.log; if (TextUtils.isEmpty(str2)) { str2 = "https://dc.sigmob.cn/log"; } if (str2.indexOf(63) == -1) { sb = new StringBuilder(); sb.append(str2); str = "?"; } else { sb = new StringBuilder(); sb.append(str2); str = "&"; } sb.append(str); sb.append(b()); return sb.toString(); } public String m() { StringBuilder sb; String str; String str2 = (String) Wire.get(j().endpoints.feedback, "https://adxtool.sigmob.cn/debug/feedback"); if (TextUtils.isEmpty(str2)) { return str2; } if (str2.indexOf(63) == -1) { sb = new StringBuilder(); sb.append(str2); str = "?"; } else { sb = new StringBuilder(); sb.append(str2); str = "&"; } sb.append(str); sb.append(b()); return sb.toString(); } public String n() { StringBuilder sb; String str; String str2 = j().endpoints.ads; if (TextUtils.isEmpty(str2)) { str2 = "https://adservice.sigmob.cn/ad/v4"; } if (str2.indexOf(63) == -1) { sb = new StringBuilder(); sb.append(str2); str = "?"; } else { sb = new StringBuilder(); sb.append(str2); str = "&"; } sb.append(str); sb.append(b()); return sb.toString(); } public String o() { StringBuilder sb; String str; String str2 = j().endpoints.hb_ads; if (TextUtils.isEmpty(str2)) { str2 = "https://adservice.sigmob.cn/hb/v2/ad"; } if (str2.indexOf(63) == -1) { sb = new StringBuilder(); sb.append(str2); str = "?"; } else { sb = new StringBuilder(); sb.append(str2); str = "&"; } sb.append(str); sb.append(b()); return sb.toString(); } public SigmobRvConfig p() { if (j() != null) { return j().rv_config; } return null; } public int q() { if (p() != null) { return ((Integer) Wire.get(p().cacheTop, 5)).intValue(); } return 5; } public long r() { if (p() == null) { return 45000; } int intValue = ((Integer) Wire.get(p().ad_load_timeout, 45)).intValue(); if (intValue < 10) { intValue = 10; } return (long) (intValue * 1000); } public SigmobDialogSetting s() { if (p() != null) { return p().close_dialog_setting; } return null; } public int t() { if (aa() == null) { return 50; } return ((Integer) Wire.get(aa().cacheTop, 50)).intValue(); } public long u() { int i2 = 2; if (aa() != null) { i2 = ((Integer) Wire.get(aa().material_expired_time, 2)).intValue(); } return i2 < 0 ? (long) i2 : ((long) i2) * 24 * 60 * 60 * 1000; } public int v() { if (ab() != null) { return ((Integer) Wire.get(ab().cacheTop, 50)).intValue(); } return 50; } public long w() { SigmobNativeConfig ab = ab(); if (ab == null) { return 45000; } int intValue = ((Integer) Wire.get(ab.ad_load_timeout, 45)).intValue(); if (intValue < 10) { intValue = 10; } return (long) (intValue * 1000); } public boolean x() { return (j() == null || j().anti_fraud_log == null || j().anti_fraud_log.events == null) ? false : true; } public int y() { if (!x() || j().anti_fraud_log.motion_config == null) { return 0; } return ((Integer) Wire.get(j().anti_fraud_log.motion_config.interval, 0)).intValue(); } public int z() { if (!x() || j().anti_fraud_log.motion_config == null) { return 0; } return ((Integer) Wire.get(j().anti_fraud_log.motion_config.count, 0)).intValue(); } }