package com.mobon.sdk; import android.app.Application; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.Uri; import android.text.TextUtils; import com.google.android.gms.ads.RequestConfiguration; import com.unity3d.services.core.device.reader.JsonStorageKeyNames; import h5.i0; import java.io.IOException; import java.io.PrintStream; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import org.json.JSONObject; /* loaded from: classes2.dex */ public class f { /* renamed from: g, reason: collision with root package name */ private static WeakReference f7592g; /* renamed from: a, reason: collision with root package name */ private Context f7593a; /* renamed from: c, reason: collision with root package name */ private c f7595c; /* renamed from: d, reason: collision with root package name */ private Application f7596d; /* renamed from: b, reason: collision with root package name */ private int f7594b = -1; /* renamed from: e, reason: collision with root package name */ private boolean f7597e = false; /* renamed from: f, reason: collision with root package name */ private final ArrayList f7598f = new ArrayList(); class a implements h5.j { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ String f7599a; a(String str) { this.f7599a = str; } @Override // h5.j public void a(h5.i iVar, i0 i0Var) { String str; String str2; if (i0Var == null || !i0Var.S() || i0Var.c() == null) { str = "error => " + i0Var.Y(); str2 = "onConnectSDKUrlAPI ERROR2"; } else { try { String R = i0Var.c().R(); f7.f.a("API_SDK_INFO result :: " + R); boolean isEmpty = TextUtils.isEmpty(R) ^ true; JSONObject jSONObject = new JSONObject(R); if (jSONObject.optInt("resultCode") != 200) { isEmpty = false; } if (isEmpty) { g7.a aVar = new g7.a(jSONObject.getString("result")); f7.l.g(f.this.f7593a, "Key.MOBON_MEDIA_AUID_FQ_VALUE", aVar.f9748o); f7.l.i(f.this.f7593a, "Key.MOBON_MEDIA_CROSS_BROWSER_VALUE", aVar.f9749p); f7.l.i(f.this.f7593a, "Key.MOBON_URL_LIST_DOWNLOAD_SAVE_DATE", this.f7599a); if (!TextUtils.isEmpty(aVar.f9745l)) { Uri parse = Uri.parse(aVar.f9745l); String queryParameter = parse.getQueryParameter("key"); if (!TextUtils.isEmpty(queryParameter)) { f7.l.i(f.this.f7593a, "Key.MOBON_API_KEY", queryParameter); } String queryParameter2 = parse.getQueryParameter("refresh"); if (!TextUtils.isEmpty(queryParameter2)) { f7.l.f(f.this.f7593a, "Key.MOBON_AUID_REFRESH", queryParameter2.equals("Y")); } if (TextUtils.equals(parse.getQueryParameter("log"), "Y")) { f7.f.e(true); } String queryParameter3 = parse.getQueryParameter("crossYn"); if (!TextUtils.isEmpty(queryParameter3)) { f7.l.i(f.this.f7593a, "Key.MOBON_MEDIA_CROSS_BROWSER_VALUE", queryParameter3); } String queryParameter4 = parse.getQueryParameter("baconPeriod"); if (TextUtils.isEmpty(queryParameter4) || !com.mobon.sdk.a.s(queryParameter4)) { f7.l.g(f.this.f7593a, "Key.MOBON_MEDIA_BACON_PERIOD_VALUE", 60); } else { f7.l.g(f.this.f7593a, "Key.MOBON_MEDIA_BACON_PERIOD_VALUE", Integer.parseInt(queryParameter4)); } } com.mobon.sdk.a.d(f.this.f7593a, f.this); return; } return; } catch (Exception e10) { str = "error => " + e10.toString(); str2 = "onConnectSDKUrlAPI ERROR1"; } } f7.f.b(str2, str); } @Override // h5.j public void b(h5.i iVar, IOException iOException) { f7.f.b("onConnectSDKUrlAPI ERROR3", "error => " + iOException.toString()); } } class b implements h5.j { b() { } @Override // h5.j public void a(h5.i iVar, i0 i0Var) { if (i0Var == null || !i0Var.S() || i0Var.c() == null) { f7.f.b("onConnectGetAUID_API ERROR", "error => " + i0Var.Y()); return; } try { String string = new JSONObject(i0Var.c().R()).getJSONObject(JsonStorageKeyNames.DATA_KEY).getString("au_id"); if (TextUtils.isEmpty(string)) { return; } f7.l.i(f.this.f7593a, "Key.AUID", string); f7.l.i(f.this.f7593a, "Key.AUID_GET_TIME", String.valueOf(System.currentTimeMillis())); f7.f.a("get auid :::" + string); } catch (Exception e10) { e10.printStackTrace(); } } @Override // h5.j public void b(h5.i iVar, IOException iOException) { f7.f.b("onConnectGetAUID_API ERROR", "error => " + iOException.toString()); } } private class c extends BroadcastReceiver { private c() { } @Override // android.content.BroadcastReceiver public void onReceive(Context context, Intent intent) { try { System.out.println("!!!!!!!!!!!!!!!!!!!!!!! mobon broadcast !!!!!!!!!!!!!!!!!!!!!"); System.out.println(f7.l.e(context, "com.mobon.sdk.MediaCode") + " mobonsdk ver : 1.0.0.54"); f7.f.f(true); if (TextUtils.isEmpty(intent.getStringExtra("ver")) || f.this.f7593a.isRestricted()) { return; } PrintStream printStream = System.out; StringBuilder sb = new StringBuilder(); sb.append("application : "); sb.append(f.this.f7596d == null ? "null" : "not null"); printStream.println(sb.toString()); f7.e.d(f.this.f7593a); f7.e.b(f.this.f7593a); } catch (Exception e10) { e10.printStackTrace(); } } /* synthetic */ c(f fVar, a aVar) { this(); } } public f(Context context, String str) { Context applicationContext = context.getApplicationContext(); this.f7593a = applicationContext; if (f7592g != null) { return; } j(applicationContext, str); } public static f c(Context context) { if (context == null) { return null; } String e10 = f7.l.e(context, "com.mobon.sdk.MediaCode"); if (TextUtils.isEmpty(e10)) { e10 = com.mobon.sdk.a.m(context, "com.mobon.sdk.MediaCode"); } if (TextUtils.isEmpty(e10)) { throw new IllegalArgumentException("empty _mediaCode"); } if (f7592g == null) { new f(context, e10); } return (f) f7592g.get(); } private void g() { if (this.f7593a == null) { return; } String a10 = f7.d.a(); String e10 = f7.l.e(this.f7593a, "Key.MOBON_URL_LIST_DOWNLOAD_SAVE_DATE"); if (!RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED.equals(e10) && a10.equals(e10)) { f7.f.a("금일 url 업데이트는 완료됨."); com.mobon.sdk.a.d(this.f7593a, this); return; } f7.f.a("onConnectSDKUrlAPI 호출"); if (f7.m.d(this.f7593a)) { new HashMap().put("id", f7.l.e(this.f7593a, "com.mobon.sdk.MediaCode")); f7.f.b("API_SDK_INFO :: ", p.f7783a + "addata.mediacategory.com/media/sdkScriptInfo/mbot.json"); f7.i.a(this.f7593a, p.f7783a + "addata.mediacategory.com/media/sdkScriptInfo/mbot.json", null).z(new a(a10)); } } private void h() { try { f7.f.a("mobon oncreate()"); Context context = this.f7593a; if (context == null || TextUtils.isEmpty(f7.l.e(context, "com.mobon.sdk.MediaCode")) || f7592g != null) { return; } f7592g = new WeakReference(this); System.out.println(f7.l.e(this.f7593a, "com.mobon.sdk.MediaCode") + " mobonsdk ver : 1.0.0.54"); if (e.f7583a) { f7.e.d(this.f7593a); } if (!f7.l.a(this.f7593a, "Key.MOBON_FIRST_APP_INSTALL")) { f7.f.a("앱 최초 설치시 초기화 작업"); f7.l.f(this.f7593a, "Key.INTERSTITIAL_CANCELABLE", true); f7.l.f(this.f7593a, "Key.ENDING_POPUP_CANCELABLE", true); f7.l.f(this.f7593a, "Key.MOBON_FIRST_APP_INSTALL", true); f7.l.f(this.f7593a, "Key.BACON_BANNER_CHECKABLE", true); f7.l.f(this.f7593a, "Key.BACON_ENDING_CHECKABLE", true); f7.l.f(this.f7593a, "Key.BACON_INTERSTITIAL_CHECKABLE", true); } g(); if (this.f7595c == null) { c cVar = new c(this, null); this.f7595c = cVar; this.f7593a.registerReceiver(cVar, new IntentFilter("com.mobon.sdk.action.log")); } } catch (Exception e10) { f7.f.c("onCreate() Exception!", e10); } } private void j(Context context, String str) { if (TextUtils.isEmpty(str)) { str = com.mobon.sdk.a.m(context, "com.mobon.sdk.MediaCode"); } f7.f.b("Meta data code", str); if (TextUtils.isEmpty(str)) { throw new IllegalArgumentException("empty _mediaCode"); } if (str.startsWith("YOUR")) { str = "mbot"; } f7.l.i(context, "com.mobon.sdk.MediaCode", str); if (RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED.equals(f7.l.e(context, "Key.MOBON_CHILD_PACKAGE_NAME"))) { f7.l.i(context, "Key.MOBON_CHILD_PACKAGE_NAME", context.getPackageName()); } h(); } public String d() { return TextUtils.isEmpty(f7.l.e(this.f7593a, "Key.AUID")) ? RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED : f7.l.e(this.f7593a, "Key.AUID"); } public Application e() { return this.f7596d; } protected void f() { String e10 = f7.l.e(this.f7593a, "Key.ADID"); f7.f.a("user adid :::" + e10); if (TextUtils.isEmpty(e10)) { return; } String e11 = f7.l.e(this.f7593a, "Key.AUID_GET_TIME"); if (TextUtils.isEmpty(d())) { e11 = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } if (!TextUtils.isEmpty(e11)) { try { long parseLong = Long.parseLong(e11); int c10 = f7.l.c(this.f7593a, "Key.MOBON_MEDIA_AUID_FQ_VALUE"); int i10 = 1; if (c10 < 1) { c10 = 7; } if (!f7.l.a(this.f7593a, "Key.MOBON_AUID_REFRESH")) { i10 = c10; } if (System.currentTimeMillis() - parseLong < i10 * 24 * 3600000) { return; } } catch (Exception e12) { f7.l.i(this.f7593a, "Key.AUID_GET_TIME", "0"); e12.printStackTrace(); } } f7.f.a("onConnectGetAUID_API AUID 갱신"); try { if (TextUtils.isEmpty(f7.l.e(this.f7593a, "Key.MOBON_API_KEY"))) { f7.f.a("mobon secret key empty!!!"); } else { String a10 = f7.a.a("adid=" + f7.l.e(this.f7593a, "Key.ADID"), f7.l.e(this.f7593a, "Key.MOBON_API_KEY")); HashMap hashMap = new HashMap(); hashMap.put("mcid", f7.l.e(this.f7593a, "com.mobon.sdk.MediaCode")); hashMap.put("mb_secret", a10); f7.i.a(this.f7593a, p.f7783a + "www.mediacategory.com/servlet/auid", hashMap).z(new b()); } } catch (Exception e13) { e13.printStackTrace(); } } public void i(boolean z10) { f7.f.e(z10); } }