package com.efs.sdk.base.core.controller; import android.content.IntentFilter; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.Process; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Pair; import android.webkit.ValueCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.efs.sdk.base.BuildConfig; import com.efs.sdk.base.EfsReporter; import com.efs.sdk.base.core.c.f; import com.efs.sdk.base.core.config.GlobalEnvStruct; import com.efs.sdk.base.core.config.a.c; import com.efs.sdk.base.core.config.b; import com.efs.sdk.base.core.controller.a.a; import com.efs.sdk.base.core.e.d; import com.efs.sdk.base.core.f.f; import com.efs.sdk.base.core.util.Log; import com.efs.sdk.base.core.util.NetworkUtil; import com.efs.sdk.base.core.util.PackageUtil; import com.efs.sdk.base.core.util.a.d; import com.efs.sdk.base.core.util.e; import com.efs.sdk.base.http.HttpResponse; import com.efs.sdk.base.protocol.ILogProtocol; import com.facebook.appevents.codeless.internal.Constants; import com.facebook.internal.ServerProtocol; import com.facebook.login.widget.ToolTipPopup; import com.umeng.umcrash.UMCrash; import java.io.File; import java.util.HashMap; import java.util.Locale; import java.util.TimeZone; public class ControllerCenter implements Handler.Callback { /* renamed from: h reason: collision with root package name */ private static GlobalEnvStruct f5734h; /* renamed from: a reason: collision with root package name */ private int f5735a = 0; /* renamed from: b reason: collision with root package name */ private final int f5736b = 0; /* renamed from: c reason: collision with root package name */ private final int f5737c = 1; /* renamed from: d reason: collision with root package name */ private final int f5738d = 2; /* renamed from: e reason: collision with root package name */ private final int f5739e = 3; /* renamed from: f reason: collision with root package name */ private volatile boolean f5740f = false; /* renamed from: g reason: collision with root package name */ private a f5741g; /* renamed from: i reason: collision with root package name */ private Handler f5742i; public ControllerCenter(EfsReporter.Builder builder) { f5734h = builder.getGlobalEnvStruct(); Handler handler = new Handler(com.efs.sdk.base.core.util.a.a.f5791a.getLooper(), this); this.f5742i = handler; handler.sendEmptyMessage(0); } private void a() { if (this.f5741g == null) { this.f5741g = new a(); } try { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE"); f5734h.mAppContext.registerReceiver(this.f5741g, intentFilter); } catch (Throwable th) { Log.w("efs.base", "register network change receiver error", th); int i10 = this.f5735a + 1; this.f5735a = i10; if (i10 < 3) { this.f5742i.sendEmptyMessageDelayed(3, ToolTipPopup.DEFAULT_POPUP_DISPLAY_TIME); } } } static /* synthetic */ void a(ILogProtocol iLogProtocol) { for (ValueCallback<Pair<Message, Message>> valueCallback : getGlobalEnvStruct().getCallback(9)) { HashMap hashMap = new HashMap(4); hashMap.put("log_type", iLogProtocol.getLogType()); hashMap.put("log_data", iLogProtocol.generateString()); hashMap.put("link_key", iLogProtocol.getLinkKey()); hashMap.put("link_id", iLogProtocol.getLinkId()); Message obtain = Message.obtain(null, 9, hashMap); Message obtain2 = Message.obtain(); valueCallback.onReceiveValue(new Pair<>(obtain, obtain2)); obtain.recycle(); obtain2.recycle(); } } private void b(final ILogProtocol iLogProtocol) { if (iLogProtocol != null) { d.a(new Runnable() { /* class com.efs.sdk.base.core.controller.ControllerCenter.AnonymousClass1 */ public final void run() { try { iLogProtocol.insertGlobal(b.a.a().f5731a); if (!"wa".equalsIgnoreCase(iLogProtocol.getLogType())) { ControllerCenter.a(iLogProtocol); } if (ControllerCenter.getGlobalEnvStruct().isEnableSendLog()) { d.a(new Runnable(com.efs.sdk.base.core.d.b.a(iLogProtocol)) { /* class com.efs.sdk.base.core.e.d.AnonymousClass1 */ /* renamed from: a reason: collision with root package name */ final /* synthetic */ com.efs.sdk.base.core.d.b f5763a; { this.f5763a = r2; } public final void run() { d.this.f5762a.a(this.f5763a); } }); } } catch (Throwable th) { Log.e("efs.base", "log send error", th); } } }); } } @NonNull public static GlobalEnvStruct getGlobalEnvStruct() { return f5734h; } public boolean handleMessage(@NonNull Message message) { int i10 = message.what; if (i10 == 0) { b a10 = b.a.a(); com.efs.sdk.base.core.config.a aVar = new com.efs.sdk.base.core.config.a(); a10.f5731a = aVar; aVar.a("appid", getGlobalEnvStruct().getAppid()); int a11 = com.efs.sdk.base.core.util.d.a(); a10.f5731a.a("pid", Integer.valueOf(a11)); a10.f5731a.a("ps", com.efs.sdk.base.core.util.d.a(a11)); String a12 = e.a(a10.f5732b); a10.f5731a.a("wid", a12); if (TextUtils.isEmpty(getGlobalEnvStruct().getUid())) { a10.f5731a.a("uid", a12); } else { a10.f5731a.a("uid", getGlobalEnvStruct().getUid()); } com.efs.sdk.base.core.config.a aVar2 = a10.f5731a; com.efs.sdk.base.core.a.a.a(); aVar2.a("stime", Long.valueOf(com.efs.sdk.base.core.a.a.b() - Process.getElapsedCpuTime())); a10.f5731a.a("pkg", PackageUtil.getPackageName(a10.f5732b)); a10.f5731a.a("ver", PackageUtil.getAppVersionName(a10.f5732b)); a10.f5731a.a("vcode", PackageUtil.getAppVersionCode(a10.f5732b)); a10.f5731a.a("sdk_ver", BuildConfig.VERSION_NAME); a10.f5731a.a("brand", Build.BRAND.toLowerCase()); com.efs.sdk.base.core.config.a aVar3 = a10.f5731a; String str = Build.MODEL; aVar3.a("model", str == null ? "unknown" : str.replace(" ", "-").replace("_", "-").toLowerCase()); a10.f5731a.a("build_model", str); DisplayMetrics displayMetrics = a10.f5732b.getResources().getDisplayMetrics(); a10.f5731a.a("dsp_w", Integer.valueOf(displayMetrics.widthPixels)); a10.f5731a.a("dsp_h", Integer.valueOf(displayMetrics.heightPixels)); a10.f5731a.a("fr", Constants.PLATFORM); a10.f5731a.a("rom", Build.VERSION.RELEASE); a10.f5731a.a(ServerProtocol.DIALOG_PARAM_SDK_VERSION, Integer.valueOf(Build.VERSION.SDK_INT)); a10.f5731a.a("lang", Locale.getDefault().getLanguage()); a10.f5731a.a("tzone", TimeZone.getDefault().getID()); a10.f5731a.a("net", NetworkUtil.getNetworkType(a10.f5732b)); try { String[] networkAccessMode = NetworkUtil.getNetworkAccessMode(a10.f5732b); if ("Wi-Fi".equals(networkAccessMode[0])) { a10.f5731a.a(UMCrash.KEY_HEADER_ACCESS, NetworkUtil.NETWORK_TYPE_WIFI); } else if ("2G/3G".equals(networkAccessMode[0])) { a10.f5731a.a(UMCrash.KEY_HEADER_ACCESS, "2G/3G"); } else { a10.f5731a.a(UMCrash.KEY_HEADER_ACCESS, "unknow"); } if (!"".equals(networkAccessMode[1])) { a10.f5731a.a(UMCrash.KEY_HEADER_ACCESS_SUBTYPE, networkAccessMode[1]); } a10.f5731a.a(UMCrash.KEY_HEADER_NETWORK_TYPE, Integer.valueOf(NetworkUtil.getNetworkTypeUmeng(a10.f5732b))); } catch (Throwable th) { th.printStackTrace(); } f.a.a(); c.a().b(); a(); com.efs.sdk.base.core.f.f a13 = f.a.a(); boolean isIntl = f5734h.isIntl(); com.efs.sdk.base.core.f.c cVar = a13.f5779a; if (isIntl) { cVar.f5771a = "https://errlogos.umeng.com/api/crashsdk/logcollect"; cVar.f5772b = "4ea4e41a3993"; } else { cVar.f5771a = "https://errlog.umeng.com/api/crashsdk/logcollect"; cVar.f5772b = "28ef1713347d"; } a13.f5780b = this; a13.f5781c.f5766a = this; a13.f5782d.f5766a = this; this.f5740f = true; com.efs.sdk.base.core.c.d.a().sendEmptyMessageDelayed(0, f5734h.getLogSendDelayMills()); com.efs.sdk.base.core.f.f a14 = f.a.a(); if (a14.f5780b != null && getGlobalEnvStruct().isEnableWaStat()) { a14.f5780b.send(new com.efs.sdk.base.core.f.b("efs_core", "pvuv", a14.f5779a.f5773c)); } } else if (i10 == 1) { Object obj = message.obj; if (obj != null && (obj instanceof ILogProtocol)) { b((ILogProtocol) obj); } } else if (i10 == 3) { a(); } return true; } public void send(ILogProtocol iLogProtocol) { if (!this.f5740f) { Message obtain = Message.obtain(); obtain.what = 1; obtain.obj = iLogProtocol; this.f5742i.sendMessage(obtain); return; } b(iLogProtocol); } @Nullable public HttpResponse sendSyncImmediately(String str, int i10, String str2, boolean z10, File file) { com.efs.sdk.base.core.d.b bVar = new com.efs.sdk.base.core.d.b(str, (byte) 2); bVar.b(1); bVar.f5755d = file; bVar.a(str2); bVar.a(i10); bVar.f5753b.f5757b = z10; bVar.c(); d.a.a().f5762a.a(bVar); return bVar.f5753b.f5758c; } }