package com.qumeng.advlib.common; import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.text.TextUtils; import android.util.Log; import com.aliyun.clientinforeport.core.LogSender; import com.baidu.mobads.sdk.internal.bk; import com.mbridge.msdk.foundation.entity.CampaignEx; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Random; /* compiled from: ReportUtils */ public class d { public static final String a = "https://tracelog-debug.aiclk.com"; public static final String b = "https://logrcv.aiclk.com/trace"; public static String c = ""; public static String d = ""; /* renamed from: e reason: collision with root package name */ private static StringBuilder f15297e = new StringBuilder(); /* renamed from: f reason: collision with root package name */ private static long f15298f = 0; /* renamed from: g reason: collision with root package name */ public static int f15299g = -1; /* renamed from: h reason: collision with root package name */ private static long f15300h = 0; /* renamed from: i reason: collision with root package name */ public static long f15301i = 0; private static int j = -1; private static final HandlerThread k = new HandlerThread("cpc/sdk-remote-" + c); private static Handler l; /* access modifiers changed from: package-private */ /* compiled from: ReportUtils */ public static class a implements Runnable { final /* synthetic */ String a; a(String str) { this.a = str; } public void run() { try { d.a(this.a); } catch (Throwable th) { th.printStackTrace(); } } } private static Handler a() { if (l == null) { synchronized (d.class) { if (l == null) { HandlerThread handlerThread = k; handlerThread.start(); l = new Handler(handlerThread.getLooper()); } } } return l; } public static void b(Context context, int i2) { f15299g = i2; long currentTimeMillis = System.currentTimeMillis(); f15301i = currentTimeMillis; long j2 = f15300h; long j3 = j2 > 0 ? currentTimeMillis - j2 : -1; if (context != null && b()) { HashMap hashMap = new HashMap(); hashMap.put("op1", "REPORT_TYPE"); hashMap.put("opt_gap", j3 + ""); hashMap.put("opt_loadId", f15300h + ""); hashMap.put("opt_isNormalStart", f15299g + ""); b(context, "LoadSdk", hashMap); } } public static void c(Context context, String str, Map<String, String> map) { a(context, b, str, map); } public static void a(Runnable runnable) { Handler a2 = a(); if (a2 != null) { a2.post(runnable); } } public static void a(Runnable runnable, long j2) { Handler a2 = a(); if (a2 != null) { a2.postDelayed(runnable, j2); } } public static void b(Context context, String str, Map<String, String> map) { a(context, a, str, map); } public static void a(Context context, String str, String str2, String str3, String str4) { if (context != null) { HashMap hashMap = new HashMap(); hashMap.put("op1", "CHECK_UPDATE"); hashMap.put("opt_reqbody", str); hashMap.put("opt_respbody", str2); hashMap.put("opt_action", str3); hashMap.put("opt_md5", str4 + ""); b(context, "LoadSdk", hashMap); } } public static boolean b() { if (j == -1) { j = new Random().nextInt(10); } return j == 1; } public static void a(Context context, String str, String str2, long j2) { try { if (b()) { HashMap hashMap = new HashMap(); hashMap.put("op1", str); hashMap.put("opt_download", bk.f11130g); hashMap.put("opt_url", str2 + ""); if (j2 > 0) { hashMap.put("opt_block_time", j2 + ""); } b(context, "Download", hashMap); } } catch (Throwable unused) { } } public static void a(Context context) { if (context != null && b()) { f15300h = System.currentTimeMillis(); HashMap hashMap = new HashMap(); hashMap.put("op1", "START"); hashMap.put("opt_loadId", f15300h + ""); hashMap.put("opt_isNormalStart", f15299g + ""); b(context, "LoadSdk", hashMap); } } public static void a(Context context, String str) { if (context != null && b()) { HashMap hashMap = new HashMap(); hashMap.put("op1", "LOAD_ERROR"); hashMap.put("opt_error", str); try { hashMap.put("opt_process", e.c(context)); } catch (Throwable unused) { } b(context, "LoadSdk", hashMap); } } public static void a(Context context, boolean z, boolean z2, boolean z3, long j2, long j3, Map map) { if (context != null && b()) { HashMap hashMap = new HashMap(); hashMap.put("op1", "SUCCESS"); hashMap.put("opt_isRemote", (z ? 1 : 0) + ""); hashMap.put("opt_unzip", (z2 ? 1 : 0) + ""); hashMap.put("opt_checkonline", (z3 ? 1 : 0) + ""); hashMap.put("opt_checkTime", j3 + ""); hashMap.put("opt_loadId", f15300h + ""); hashMap.put("opt_loadTime", (System.currentTimeMillis() - j2) + ""); long j4 = -1; if (f15301i > 0) { j4 = System.currentTimeMillis() - f15301i; } hashMap.put("opt_gap", j4 + ""); hashMap.put("opt_isNormalStart", f15299g + ""); if (map != null && map.size() > 0) { hashMap.putAll(map); } b(context, "LoadSdk", hashMap); } } public static void a(Context context, int i2) { if (context != null && b()) { HashMap hashMap = new HashMap(); hashMap.put("op1", "Loading"); hashMap.put("opt_loadId", f15300h + ""); hashMap.put("opt_step", i2 + ""); StringBuilder sb = f15297e; sb.append(i2 + "-"); hashMap.put("opt_path", f15297e.toString()); long j2 = 0; if (f15298f != 0) { j2 = System.currentTimeMillis() - f15298f; } f15298f = System.currentTimeMillis(); hashMap.put("opt_loadTime", j2 + ""); b(context, "LoadSdk", hashMap); Log.i("reportLoadsdkLoading", "step = " + i2 + " , time = " + j2); } } public static void a(Context context, boolean z, boolean z2, boolean z3, String str, long j2, Map map) { if (context != null) { HashMap hashMap = new HashMap(); hashMap.put("op1", "FAIL"); hashMap.put("opt_isRemote", (z ? 1 : 0) + ""); hashMap.put("opt_unzip", (z2 ? 1 : 0) + ""); hashMap.put("opt_checkonline", (z3 ? 1 : 0) + ""); hashMap.put("opt_checkTime", j2 + ""); hashMap.put("opt_cause", str); hashMap.put("opt_loadId", f15300h + ""); long j3 = -1; if (f15301i > 0) { j3 = System.currentTimeMillis() - f15301i; } hashMap.put("opt_gap", j3 + ""); hashMap.put("opt_isNormalStart", f15299g + ""); hashMap.put("opt_lyr", "android_cpc_sdk_custom"); if (map != null && map.size() > 0) { hashMap.putAll(map); } b(context, "LoadSdk", hashMap); } } private static void a(Context context, String str, String str2, Map<String, String> map) { a aVar = new a(a(str, a(context, str2, map))); Handler a2 = a(); if (a2 != null) { a2.post(aVar); } } private static String a(String str, Map<String, String> map) { return str + e.a(map); } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x00a5 */ /* JADX WARNING: Removed duplicated region for block: B:13:0x00a9 */ /* JADX WARNING: Removed duplicated region for block: B:16:0x00b2 */ private static Map a(Context context, String str, Map<String, String> map) { HashMap hashMap = new HashMap(); hashMap.put(LogSender.KEY_OPERATION_SYSTEM, "Android"); hashMap.put(CampaignEx.JSON_KEY_TIMESTAMP, String.valueOf(System.currentTimeMillis())); hashMap.put("opt_bootstrap_v", c); hashMap.put("opt_lib_v", d); hashMap.put("t", str + ""); if (context != null) { hashMap.put("opt_app_pkgid", context.getPackageName()); hashMap.put("opt_app_vn", e.b(context)); hashMap.put("opt_app_vc", e.a(context) + ""); } hashMap.put("opt_os_version", Build.VERSION.RELEASE + ""); if (map != null) { for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); hashMap.put(key, map.get(key)); } } try { String str2 = Build.BRAND; if (str2 != null) { hashMap.put("opt_brand", str2); } String str3 = Build.MODEL; if (str3 != null) { hashMap.put("opt_model", str3); } } catch (Exception e2) { e2.printStackTrace(); } return hashMap; } public static void a(String str) throws Throwable { if (str != null && !TextUtils.isEmpty(str)) { if (str.startsWith("http://") || str.startsWith("https://")) { URLConnection openConnection = new URL(str).openConnection(); try { openConnection.connect(); int responseCode = ((HttpURLConnection) openConnection).getResponseCode(); if (responseCode != 200) { Log.e("NetUtils", "ERROR " + String.valueOf(responseCode) + " on url \"" + str + "\""); } } finally { try { ((HttpURLConnection) openConnection).disconnect(); } catch (Exception e2) { e2.printStackTrace(); } } } } } }