package com.windmill.sdk.b; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import androidx.constraintlayout.core.motion.utils.TypedValues; 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.volley.VolleyError; import com.meishu.sdk.meishu_ad.view.scaleImage.SubsamplingScaleImageView; import com.windmill.sdk.WindMillAd; import com.windmill.sdk.b.c; import com.windmill.sdk.base.WMLogUtil; import com.windmill.sdk.c.d; import com.windmill.sdk.c.i; import com.windmill.sdk.models.Android; import com.windmill.sdk.models.Common; import com.windmill.sdk.models.CommonEndpointsConfig; import com.windmill.sdk.models.SdkConfig; import com.windmill.sdk.models.SdkConfigResponse; 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; /* compiled from: WMSdkConfig */ public class g { private static g a = null; private static boolean b = false; private static String k = ""; private final Handler c = new Handler(Looper.getMainLooper()); private final Runnable d = new Runnable() { /* class com.windmill.sdk.b.g.AnonymousClass1 */ public void run() { g.this.B(); } }; /* renamed from: e reason: collision with root package name */ private final String f16885e = "tb-3.4.3"; /* renamed from: f reason: collision with root package name */ private boolean f16886f = true; /* renamed from: g reason: collision with root package name */ private long f16887g = 0; /* renamed from: h reason: collision with root package name */ private SdkConfig f16888h = null; /* renamed from: i reason: collision with root package name */ private SdkConfig f16889i = null; private a j; private String l = "https://adservice.sigmob.cn/strategy/v6"; private String m = "https://adservice.sigmob.cn/waterfall/v1"; private String n = "https://dc.sigmob.cn/log"; /* compiled from: WMSdkConfig */ public interface a { void a(); } private g() { y(); A(); } /* JADX WARNING: Removed duplicated region for block: B:20:0x0074 */ /* JADX WARNING: Removed duplicated region for block: B:32:? A[RETURN, SYNTHETIC] */ private void A() { Throwable th; ObjectInputStream objectInputStream; if (ClientMetadata.getInstance() == null) { a(this.f16889i); return; } String string = i.a(ClientMetadata.getInstance().getContext()).getString("sdkConfigVer", null); File file = new File(d.a() + "/tb_config"); if (!"tb-3.4.3".equals(string) || !file.exists()) { a(this.f16889i); return; } try { objectInputStream = new ObjectInputStream(new FileInputStream(file)); try { a(SdkConfig.ADAPTER.decode(objectInputStream)); try { objectInputStream.close(); return; } catch (Throwable th2) { WMLogUtil.e(th2.getMessage()); return; } } catch (Throwable th3) { th = th3; try { a(this.f16889i); WMLogUtil.e(th.getMessage()); if (objectInputStream == null) { objectInputStream.close(); return; } return; } catch (Throwable th4) { WMLogUtil.e(th4.getMessage()); } } } catch (Throwable th5) { th = th5; objectInputStream = null; a(this.f16889i); WMLogUtil.e(th.getMessage()); if (objectInputStream == null) { } } throw th; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void B() { if (ClientMetadata.getInstance() != null) { if (!ClientMetadata.getInstance().isNetworkConnected(b()) || !com.windmill.sdk.a.a.b()) { WMLogUtil.e("Can't load an ad because is no network or can not CollectPersonalInformation"); D(); return; } C(); } } private void C() { SigmobRequestQueue requestQueue = Networking.getRequestQueue(); c cVar = new c(b(), new c.a() { /* class com.windmill.sdk.b.g.AnonymousClass2 */ @Override // com.windmill.sdk.b.c.a public void a(SdkConfigResponse sdkConfigResponse) { String str = WMLogUtil.TAG; WMLogUtil.dd(str, "SdkConfigResponse:" + sdkConfigResponse.toString()); SdkConfig sdkConfig = sdkConfigResponse.config; if (sdkConfigResponse.code.intValue() != 0 || sdkConfig == null) { WMLogUtil.e("ConfigResponseError:" + sdkConfigResponse.error_message); } else { g.this.a((g) sdkConfig); g.this.b((g) sdkConfig); } g.this.D(); } @Override // com.czhj.volley.Response.ErrorListener public void onErrorResponse(VolleyError volleyError) { WMLogUtil.e("ConfigResponseError:" + volleyError.toString()); g.this.D(); } }); if (requestQueue == null) { WMLogUtil.e("queue is null"); D(); return; } requestQueue.add(cVar); WMLogUtil.i(WMLogUtil.TAG, "start update sdk config"); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void D() { z(); if (this.f16886f) { this.c.postDelayed(this.d, Math.max(30000L, this.f16887g)); } } public static String c() { return "https://adservice.sigmob.cn/extconfig?" + d(); } public static String d() { return "appId=" + WindMillAd.sharedAds().getAppId() + "&" + "sdkVersion=3.4.3"; } private void y() { if (this.f16889i == null) { SdkConfig.Builder builder = new SdkConfig.Builder(); Common.Builder builder2 = new Common.Builder(); Android.Builder builder3 = new Android.Builder(); CommonEndpointsConfig.Builder builder4 = new CommonEndpointsConfig.Builder(); builder4.log(this.n); builder4.strategy(this.l); builder4.bidding_url(this.m); builder2.endpoints(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.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.f16889i = builder.build(); } } private void z() { this.c.removeCallbacks(this.d); } public void e() { z(); this.c.post(this.d); } public SdkConfig f() { SdkConfig sdkConfig = this.f16888h; return sdkConfig == null ? this.f16889i : sdkConfig; } public Common g() { return f().common_config; } public Android h() { return f().android_config; } public String i() { String str = g().endpoints.log; if (TextUtils.isEmpty(str)) { return this.n + "?" + d(); } else if (str.indexOf(63) == -1) { return str + "?" + d(); } else { return str + "&" + d(); } } public String j() { String str = g().endpoints.strategy; if (TextUtils.isEmpty(str)) { return this.l + "?" + d(); } else if (str.indexOf(63) == -1) { return str + "?" + d(); } else { return str + "&" + d(); } } public String k() { String str = g().endpoints.bidding_url; if (TextUtils.isEmpty(str)) { return this.m + "?" + d(); } else if (str.indexOf(63) == -1) { return str + "?" + d(); } else { return str + "&" + d(); } } public int l() { int intValue = g().max_send_log_records.intValue(); if (intValue < 10) { return 100; } return intValue; } public boolean m() { if (g() != null) { return g().log_enc.booleanValue(); } return false; } public int n() { if (g() == null || g().tracking_expiration_time.intValue() < 1) { return 86400; } return g().tracking_expiration_time.intValue(); } public int o() { if (g() == null || g().tracking_retry_interval.intValue() < 10) { return SubsamplingScaleImageView.ORIENTATION_180; } return g().tracking_retry_interval.intValue(); } public int p() { int intValue = g().send_log_interval.intValue(); if (intValue < 3) { return 3; } return intValue; } public List<Integer> q() { return g().dclog_blacklist; } public long r() { int intValue = g().ready_expire_timestamp.intValue(); if (intValue < 1) { intValue = TypedValues.Custom.TYPE_INT; } return ((long) intValue) * 1000; } public long s() { Integer num = g().load_interval; if (num == null || num.intValue() < 1) { return 0; } return (long) (num.intValue() * 1000); } public boolean t() { if (f() == null || g().disable_up_location == null) { return true; } return g().disable_up_location.booleanValue(); } public int u() { if (f() == null || h() == null) { return 0; } return h().disable_up_oaid.intValue(); } public boolean v() { if (f() == null || h() == null) { return false; } return h().enable_report_crash.booleanValue(); } public boolean w() { if (f() == null || h() == null) { return true; } return h().oaid_api_is_disable.booleanValue(); } public boolean x() { if (f() == null || h() == null) { return true; } return h().disable_boot_mark.booleanValue(); } public static g a() { if (a == null) { synchronized (g.class) { if (a == null) { a = new g(); } } } return a; } public static String b() { if (!TextUtils.isEmpty(k)) { return k + "?" + d(); } return "https://adservice.sigmob.cn/w/config?" + d(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:20:0x006b */ /* JADX WARNING: Removed duplicated region for block: B:24:0x007a A[SYNTHETIC, Splitter:B:24:0x007a] */ /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */ private void b(SdkConfig sdkConfig) { Throwable th; IOException e2; if (sdkConfig != null) { ObjectOutputStream objectOutputStream = null; File file = new File(d.a() + "/tb_config"); if (file.exists()) { file.delete(); } file.getParentFile().mkdirs(); try { ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(new FileOutputStream(file)); try { sdkConfig.encode(objectOutputStream2); i.a(ClientMetadata.getInstance().getContext()).edit().putString("sdkConfigVer", "tb-3.4.3").apply(); try { objectOutputStream2.close(); } catch (IOException e3) { WMLogUtil.e(e3.getMessage()); } } catch (IOException e4) { e2 = e4; objectOutputStream = objectOutputStream2; try { WMLogUtil.e(e2.getMessage()); if (objectOutputStream == null) { } } catch (Throwable th2) { th = th2; if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (IOException e5) { WMLogUtil.e(e5.getMessage()); } } throw th; } } catch (Throwable th3) { th = th3; objectOutputStream = objectOutputStream2; if (objectOutputStream != null) { } throw th; } } catch (IOException e6) { e2 = e6; WMLogUtil.e(e2.getMessage()); if (objectOutputStream == null) { objectOutputStream.close(); } } } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(SdkConfig sdkConfig) { Common common; if (sdkConfig != null && (common = sdkConfig.common_config) != null) { this.f16888h = sdkConfig; this.f16887g = (long) (common.configRefresh.intValue() * 1000); a aVar = this.j; if (aVar != null) { aVar.a(); } Config.sharedInstance().update(b, x(), w(), u(), i(), p(), l(), m()); TrackManager.getInstance().setRetryExpiredTime((long) n()); TrackManager.getInstance().setRetryInterval((long) o()); } } public long a(String str) { int i2 = 45; try { i2 = i.a(ClientMetadata.getInstance().getContext()).getInt(str, 45); } catch (Exception e2) { e2.printStackTrace(); } return ((long) i2) * 1000; } public int b(String str) { try { return i.a(ClientMetadata.getInstance().getContext()).getInt(str, 5); } catch (Exception e2) { e2.printStackTrace(); return 5; } } }