package com.tencent.wxop.stat.common; import android.content.Context; import java.util.HashMap; import java.util.Map; import org.json.JSONObject; /* loaded from: classes.dex */ public class b { static d a; private static StatLogger d = l.b(); private static JSONObject e = new JSONObject(); Integer b; String c; public b(Context context) { this.b = null; this.c = null; try { a(context); this.b = l.k(context.getApplicationContext()); this.c = com.tencent.wxop.stat.a.a(context).b(); } catch (Throwable th) { d.e(th); } } static synchronized d a(Context context) { d dVar; synchronized (b.class) { if (a == null) { a = new d(context.getApplicationContext()); } dVar = a; } return dVar; } public static void a(Context context, Map map) { if (map == null) { return; } for (Map.Entry entry : new HashMap(map).entrySet()) { e.put((String) entry.getKey(), entry.getValue()); } } public void a(JSONObject jSONObject, Thread thread) { String str; String str2; JSONObject jSONObject2 = new JSONObject(); try { if (a != null) { a.a(jSONObject2, thread); } r.a(jSONObject2, "cn", this.c); if (this.b != null) { jSONObject2.put("tn", this.b); } if (thread == null) { str = "ev"; str2 = jSONObject2; } else { str = "errkv"; str2 = jSONObject2.toString(); } jSONObject.put(str, str2); if (e == null || e.length() <= 0) { return; } jSONObject.put("eva", e); } catch (Throwable th) { d.e(th); } } }