package com.mbridge.msdk.tracker; import android.content.Context; import android.text.TextUtils; import android.util.Log; import com.mbridge.msdk.newreward.player.view.hybrid.util.MRAIDCommunicatorUtil; import com.mbridge.msdk.tracker.w; import java.util.List; import java.util.UUID; import org.json.JSONObject; /* loaded from: classes4.dex */ class k { private static x a = null; private static volatile String o = ""; private final String b; private final m c; private Context d; private w e; private JSONObject f; private List g; private List h; private volatile c i; private volatile l j; private volatile d k; private volatile j l; private volatile r m; private volatile boolean n = true; private volatile n p; private volatile boolean q; public final void a(Context context) { this.d = context; } public final void a(w wVar) { this.e = wVar; } public final void a(JSONObject jSONObject) { this.f = jSONObject; } public final String c() { return this.b; } public final Context e() { return this.d; } public final m k() { return this.c; } public final boolean r() { return this.n; } public final void s() { this.q = true; } public final boolean t() { return !this.q; } public k(String str, m mVar) { this.b = str; this.c = mVar; } public final String a() { if (!y.a((Object) this.d) && !y.a(this.e)) { try { o().a(); this.n = false; this.q = false; if (TextUtils.isEmpty(o)) { o = UUID.randomUUID().toString(); } if (!y.a(a)) { try { a.a(b(), this.b, this.c); t.a().b(); } catch (Exception e) { if (a.a) { Log.e("TrackManager", "track manager start exception", e); } } } return o; } catch (Exception e2) { if (a.a) { Log.e("TrackManager", "start error", e2); } this.n = true; } } return ""; } public final String b() { if (!TextUtils.isEmpty(o)) { return o; } String uuid = UUID.randomUUID().toString(); o = uuid; return uuid; } public final w d() { w wVar = this.e; if (wVar != null) { return wVar; } w a2 = new w.a().a(); this.e = a2; return a2; } public final JSONObject f() { JSONObject jSONObject = this.f; if (jSONObject != null) { return jSONObject; } JSONObject jSONObject2 = new JSONObject(); this.f = jSONObject2; return jSONObject2; } public final c g() { String format; if (y.a(this.i)) { synchronized (k.class) { try { if (y.a(this.i)) { Context context = this.d; if (TextUtils.isEmpty(this.b)) { format = String.format("track_manager_%s.db", MRAIDCommunicatorUtil.STATES_DEFAULT); } else { format = String.format("track_manager_%s.db", this.b); } this.i = new c(new b(context, format, "event_table"), "event_table"); } } finally { } } } return this.i; } public final l h() { if (y.a(this.j)) { synchronized (k.class) { try { if (y.a(this.j)) { this.j = new p(new g(g(), o(), i())); } } finally { } } } return this.j; } public final j i() { if (y.a(this.l)) { synchronized (k.class) { try { if (y.a(this.l)) { this.l = new j(); } } finally { } } } return this.l; } public final d j() { if (y.a(this.k)) { this.k = d().h; } return this.k; } public final int l() { if (d().a < 0) { return 50; } return d().a; } public final int m() { return Math.max(d().b, 0); } public final int n() { return Math.max(d().e, 0); } public final r o() { if (y.a(this.m)) { synchronized (k.class) { try { if (y.a(this.m)) { this.m = new r(this); } } finally { } } } return this.m; } public final boolean a(e eVar) { if (y.a(eVar)) { return false; } f fVar = d().j; if (y.b(fVar)) { try { return fVar.a(eVar); } catch (Exception e) { if (a.a) { Log.e("TrackManager", "event filter apply exception", e); } } } String a2 = eVar.a(); if (TextUtils.isEmpty(a2)) { return false; } if (this.h != null) { try { return !r0.contains(a2); } catch (Exception e2) { if (a.a) { Log.e("TrackManager", "disallowTrackEventNames contains exception", e2); } } } List list = this.g; if (list != null) { try { return list.contains(a2); } catch (Exception e3) { if (a.a) { Log.e("TrackManager", "allowTrackEventNames contains exception", e3); } } } return true; } public final boolean p() throws IllegalStateException { if (y.a(d())) { throw new IllegalStateException("config can not be null"); } if (y.a(j())) { throw new IllegalStateException("decorate can not be null"); } if (y.a(d().i)) { throw new IllegalStateException("responseHandler can not be null"); } if (y.a(d().g) || y.a(d().g.c())) { throw new IllegalStateException("networkStackConfig or stack can not be null"); } if (TextUtils.isEmpty(d().g.b())) { throw new IllegalStateException("report url is null"); } return true; } public final n q() { if (y.a(this.p)) { synchronized (k.class) { try { if (y.a(this.p)) { this.p = new n(d().d <= 0 ? 2 : d().d, d().g, d().i, d().c); } } finally { } } } return this.p; } }