同程有借 v1.0.0版本的 MD5 值为:e33397cdbab33543d0c134ec96d77fb8

以下内容为反编译后的 g.java 源代码,内容仅作参考


package com.bonree.sdk.ax;

import android.text.TextUtils;
import anet.channel.util.HttpConstant;
import com.bonree.sdk.agent.business.entity.EventBean;
import com.bonree.sdk.agent.business.entity.NetworkEventInfoBean;
import com.bonree.sdk.agent.business.entity.NetworkRequestExtraBean;
import com.bonree.sdk.agent.business.entity.WebViewInfoBean;
import com.bonree.sdk.agent.business.entity.WebviewPerformanceTiming;
import com.bonree.sdk.agent.business.entity.WebviewResourceBean;
import com.bonree.sdk.agent.engine.webview.entity.AjaxPerformanceTimingEvent;
import com.bonree.sdk.agent.engine.webview.entity.PagePerformanceTiming;
import com.bonree.sdk.agent.engine.webview.entity.ResourcePerformanceTiming;
import com.bonree.sdk.bl.f;
import com.bonree.sdk.bz.af;
import com.bonree.sdk.bz.x;
import com.bonree.sdk.common.json.JSONException;
import com.bonree.sdk.common.json.JSONObject;
import com.bonree.sdk.o.j;
import com.huawei.hms.framework.common.ContainerUtils;
import com.moture.lib.core.utils.string.HanziToPinyin;
import com.xiaomi.mipush.sdk.Constants;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public final class g {
    private static f f3941a = com.bonree.sdk.bl.a.a();
    private static final int f3942b = 999;
    private static final int f3943c = 1000;
    private static int f3944d = 1;
    private static int f3945e = 2;
    private static int f3946f = 3;
    private static int f3947g = 10;
    private static int f3948h = 0;
    private static int f3949i = 1;
    private static int f3950j = 2;

    public static NetworkEventInfoBean a(j jVar, com.bonree.sdk.agent.engine.network.cronet.b bVar, Map<String, j> map) {
        if (jVar != null && jVar.f() != null) {
            if (h.a() != null) {
                if (h.a().equals(jVar.f() + jVar.p())) {
                    f3941a.c("代理过滤domain:" + jVar.f(), new Object[0]);
                    return null;
                }
            }
            if (jVar.p() != 80 && jVar.p() != 443) {
                NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
                networkEventInfoBean.startTime = com.bonree.sdk.c.a.g();
                if (jVar.f().contains(Constants.COLON_SEPARATOR) && !jVar.f().contains("[")) {
                    networkEventInfoBean.mRequestUrl = "[" + jVar.f() + "]:" + jVar.p();
                } else {
                    networkEventInfoBean.mRequestUrl = jVar.f() + Constants.COLON_SEPARATOR + jVar.p();
                }
                networkEventInfoBean.mProtocolType = 7;
                if (jVar.q() == null) {
                    networkEventInfoBean.mTargetPort = 0;
                } else {
                    networkEventInfoBean.mTargetIp = jVar.q();
                    networkEventInfoBean.mTargetPort = jVar.p();
                }
                if (jVar.n() != 200) {
                    networkEventInfoBean.mErrorCode = Integer.valueOf(jVar.n());
                    if (jVar.d() != null) {
                        networkEventInfoBean.mErrorMsg = jVar.d();
                    }
                    if (jVar.c() > 0) {
                        networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(jVar.c());
                    }
                    a(networkEventInfoBean, jVar);
                } else {
                    networkEventInfoBean.mErrorCode = 200;
                    if (map != null) {
                        String str = jVar.f() + jVar.p() + jVar.g();
                        if (str != null && !map.containsKey(str)) {
                            a(networkEventInfoBean, jVar);
                            if (jVar.h() > jVar.g()) {
                                networkEventInfoBean.mConnectTimeUs = (int) ((jVar.h() - jVar.g()) * 1000);
                            } else {
                                networkEventInfoBean.mConnectTimeUs = 1000;
                            }
                            int m9 = jVar.m();
                            networkEventInfoBean.mdownloadSizeByte = m9;
                            if (m9 > 0) {
                                if (jVar.b() != null && jVar.a() != null && jVar.b().size() > 0 && jVar.a().size() > 0) {
                                    long c9 = jVar.b().get(0).c();
                                    long c10 = jVar.a().get(0).c();
                                    if (c10 > 0 && c9 > c10) {
                                        networkEventInfoBean.mResponseTimeUs = (int) ((c9 - c10) * 1000);
                                    }
                                }
                                if (networkEventInfoBean.mResponseTimeUs == 0) {
                                    networkEventInfoBean.mResponseTimeUs = 1000;
                                }
                                if (jVar.m() > 0) {
                                    networkEventInfoBean.mDownloadTimeUs = networkEventInfoBean.mResponseTimeUs;
                                }
                            }
                            if (jVar.e() > 0) {
                                networkEventInfoBean.mSslTimeUs = (int) (jVar.e() * 1000);
                            }
                            map.put(str, jVar);
                        }
                    }
                    if (bVar != null) {
                        if (bVar.c() > 0 && bVar.b() > 0 && bVar.c() > bVar.b()) {
                            networkEventInfoBean.mRequestTimeUs = (int) ((bVar.c() - bVar.b()) * 1000);
                        } else {
                            networkEventInfoBean.mRequestTimeUs = 1000;
                        }
                    }
                }
                networkEventInfoBean.mAppRequestType = 10;
                networkEventInfoBean.isCustom = false;
                return networkEventInfoBean;
            }
            f3941a.c("过滤80 443 端口:" + jVar.f() + "   port " + jVar.p(), new Object[0]);
        }
        return null;
    }

    private static String a(byte[] bArr) {
        return null;
    }

    private static NetworkEventInfoBean b(j jVar, com.bonree.sdk.agent.engine.network.cronet.b bVar, Map<String, j> map) {
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.startTime = com.bonree.sdk.c.a.g();
        if (jVar.f().contains(Constants.COLON_SEPARATOR) && !jVar.f().contains("[")) {
            networkEventInfoBean.mRequestUrl = "[" + jVar.f() + "]:" + jVar.p();
        } else {
            networkEventInfoBean.mRequestUrl = jVar.f() + Constants.COLON_SEPARATOR + jVar.p();
        }
        networkEventInfoBean.mProtocolType = 7;
        if (jVar.q() == null) {
            networkEventInfoBean.mTargetPort = 0;
        } else {
            networkEventInfoBean.mTargetIp = jVar.q();
            networkEventInfoBean.mTargetPort = jVar.p();
        }
        if (jVar.n() != 200) {
            networkEventInfoBean.mErrorCode = Integer.valueOf(jVar.n());
            if (jVar.d() != null) {
                networkEventInfoBean.mErrorMsg = jVar.d();
            }
            if (jVar.c() > 0) {
                networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(jVar.c());
            }
            a(networkEventInfoBean, jVar);
        } else {
            networkEventInfoBean.mErrorCode = 200;
            a(networkEventInfoBean, jVar, map);
            if (bVar != null) {
                if (bVar.c() > 0 && bVar.b() > 0 && bVar.c() > bVar.b()) {
                    networkEventInfoBean.mRequestTimeUs = (int) ((bVar.c() - bVar.b()) * 1000);
                } else {
                    networkEventInfoBean.mRequestTimeUs = 1000;
                }
            }
        }
        networkEventInfoBean.mAppRequestType = 10;
        networkEventInfoBean.isCustom = false;
        return networkEventInfoBean;
    }

    public static Map<String, String> c(Map<String, String> map, List<String> list) {
        if (list != null && !list.isEmpty() && map != null && map.size() > 0) {
            HashMap hashMap = new HashMap();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (entry != null) {
                    hashMap.put(entry.getKey().toLowerCase(), entry.getValue());
                }
            }
            HashMap hashMap2 = new HashMap();
            try {
                synchronized (list) {
                    for (String str : list) {
                        if (!TextUtils.isEmpty(str)) {
                            String str2 = (String) hashMap.get(str.toLowerCase());
                            if (!TextUtils.isEmpty(str2)) {
                                hashMap2.put(str, str2);
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                f fVar = f3941a;
                fVar.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
            }
            if (hashMap2.size() > 0) {
                return hashMap2;
            }
        }
        return null;
    }

    private static synchronized void c(NetworkEventInfoBean networkEventInfoBean, String str, List<String> list) {
        String substring;
        synchronized (g.class) {
            if (list != null) {
                try {
                    if (!list.isEmpty()) {
                        if (TextUtils.isEmpty(str)) {
                            return;
                        }
                        HashMap hashMap = new HashMap();
                        String replaceAll = str.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                        String lowerCase = replaceAll.toLowerCase();
                        for (String str2 : list) {
                            if (!TextUtils.isEmpty(str2)) {
                                String replaceAll2 = str2.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                                String lowerCase2 = replaceAll2.toLowerCase();
                                if (lowerCase.contains(lowerCase2 + Constants.COLON_SEPARATOR)) {
                                    int indexOf = lowerCase.indexOf(lowerCase2) - 1;
                                    if (indexOf != -1) {
                                        String valueOf = String.valueOf(lowerCase.charAt(indexOf));
                                        if (!valueOf.equals(Constants.COLON_SEPARATOR) && !valueOf.equals("\n") && !valueOf.equals("\r")) {
                                        }
                                    }
                                    String substring2 = replaceAll.substring(lowerCase.indexOf(lowerCase2 + Constants.COLON_SEPARATOR));
                                    if (substring2.contains("\n")) {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1, substring2.indexOf("\n"));
                                    } else {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1);
                                    }
                                    if (substring.startsWith(HanziToPinyin.Token.SEPARATOR)) {
                                        substring = substring.replaceFirst(HanziToPinyin.Token.SEPARATOR, "");
                                    }
                                    hashMap.put(replaceAll2, substring.replace("\r", "").replace("\n", ""));
                                }
                            }
                        }
                        if (hashMap.size() > 0) {
                            networkEventInfoBean.mRequestTraceInfo = hashMap;
                        }
                    }
                } catch (Throwable th) {
                    f3941a.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
                }
            }
        }
    }

    private static void b(NetworkEventInfoBean networkEventInfoBean, String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        networkEventInfoBean.mResponseHeader = str;
    }

    private static void b(NetworkEventInfoBean networkEventInfoBean, j jVar) {
        if (TextUtils.isEmpty(networkEventInfoBean.mTargetIp) && jVar != null) {
            networkEventInfoBean.mTargetIp = jVar.q();
            networkEventInfoBean.mTargetPort = jVar.p();
        }
    }

    private static NetworkEventInfoBean b(AjaxPerformanceTimingEvent ajaxPerformanceTimingEvent, long j9, List<String> list, List<String> list2, List<String> list3, List<String> list4, int i9) {
        if (ajaxPerformanceTimingEvent == null || af.b(ajaxPerformanceTimingEvent.ajaxUrl)) {
            return null;
        }
        String str = ajaxPerformanceTimingEvent.ajaxUrl;
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mRequestUrl = str;
        int i10 = (int) (ajaxPerformanceTimingEvent.dnsStart * 1000.0d);
        int i11 = (int) (ajaxPerformanceTimingEvent.dnsEnd * 1000.0d);
        int i12 = (int) (ajaxPerformanceTimingEvent.connectStart * 1000.0d);
        int i13 = (int) (ajaxPerformanceTimingEvent.ssl * 1000.0d);
        int i14 = (int) (ajaxPerformanceTimingEvent.connectEnd * 1000.0d);
        int i15 = (int) (ajaxPerformanceTimingEvent.firstByteEndTime * 1000.0d);
        int i16 = (int) (ajaxPerformanceTimingEvent.startTime * 1000.0d);
        int i17 = (int) (ajaxPerformanceTimingEvent.callbackTime * 1000.0d);
        int i18 = (int) (ajaxPerformanceTimingEvent.endTime * 1000.0d);
        long abs = Math.abs(j9);
        long j10 = ((abs - i17) - i18) + i16;
        f3941a.c("ajaxFinishTime=%d,absFinishTime=%d,callbackTime=%d,endTime=%d,startTime=%d,startTimeUs=%d", Long.valueOf(j9), Long.valueOf(abs), Integer.valueOf(i17), Integer.valueOf(i18), Integer.valueOf(i16), Long.valueOf(j10));
        if (j10 < 0) {
            j10 = 1000 * abs;
        }
        if (j9 < 0) {
            j10 = -j10;
        }
        networkEventInfoBean.startTime = j10;
        networkEventInfoBean.mDnsTimeUs = Math.abs(i11 - i10);
        double d9 = ajaxPerformanceTimingEvent.ssl;
        if (d9 > 0.0d) {
            networkEventInfoBean.mConnectTimeUs = Math.abs(i13 - i12);
        } else if (d9 == 0.0d) {
            networkEventInfoBean.mConnectTimeUs = Math.abs(i14 - i12);
        }
        if (ajaxPerformanceTimingEvent.ssl > 0.0d && str.startsWith("https://")) {
            networkEventInfoBean.mSslTimeUs = Math.abs(i14 - i13);
        }
        if (i14 > 0) {
            i11 = i14;
        } else if (i11 <= 0) {
            i11 = i16 > 0 ? i16 : i15;
        }
        int i19 = i15 - i11;
        int i20 = i18 - i15;
        networkEventInfoBean.mRequestTimeUs = 999;
        if (i19 <= 0) {
            i19 = 999;
        }
        networkEventInfoBean.mResponseTimeUs = i19;
        if (i20 > 0) {
            networkEventInfoBean.mDownloadTimeUs = Math.max(i20, 999);
        } else {
            networkEventInfoBean.mDownloadTimeUs = 0;
        }
        networkEventInfoBean.mdownloadSizeByte = ajaxPerformanceTimingEvent.responseLength;
        if (networkEventInfoBean.mRequestUrl.startsWith("file://") && ajaxPerformanceTimingEvent.statusCode == 602) {
            networkEventInfoBean.mErrorCode = 200;
        } else {
            networkEventInfoBean.mErrorCode = Integer.valueOf(ajaxPerformanceTimingEvent.statusCode);
            if (ajaxPerformanceTimingEvent.statusCode != 200) {
                networkEventInfoBean.mErrorOccurrentProcess = 4;
                if (!TextUtils.isEmpty(ajaxPerformanceTimingEvent.errorPlatform)) {
                    networkEventInfoBean.mErrorPlatform = ajaxPerformanceTimingEvent.errorPlatform;
                }
                if (!TextUtils.isEmpty(ajaxPerformanceTimingEvent.errorMessage)) {
                    networkEventInfoBean.mErrorMsg = ajaxPerformanceTimingEvent.errorMessage;
                }
            }
        }
        String d10 = x.d(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(d10)) {
            networkEventInfoBean.mTraceId = d10;
        }
        String e9 = x.e(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(e9)) {
            networkEventInfoBean.xBrResponse = e9;
        }
        String f9 = x.f(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(f9)) {
            networkEventInfoBean.traceResponse = f9;
        }
        a(i9, networkEventInfoBean.mErrorCode.intValue(), networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, ajaxPerformanceTimingEvent.responseHeader);
        int a9 = h.a(str, ajaxPerformanceTimingEvent.nextHopProtocol);
        networkEventInfoBean.mProtocolType = a9;
        if (a9 == 3 && networkEventInfoBean.mRequestUrl.startsWith("http://")) {
            String str2 = "https://" + networkEventInfoBean.mRequestUrl.substring(7);
            networkEventInfoBean.mRequestUrl = str2;
            ajaxPerformanceTimingEvent.ajaxUrl = str2;
        }
        String a10 = a.a(ajaxPerformanceTimingEvent.ajaxUrl);
        if (af.b(a10)) {
            a10 = a.a(str);
        }
        if (!TextUtils.isEmpty(a10)) {
            networkEventInfoBean.mResourceType = a10;
        }
        networkEventInfoBean.mMethod = ajaxPerformanceTimingEvent.method;
        networkEventInfoBean.mAppRequestType = 3;
        networkEventInfoBean.mPageId = ajaxPerformanceTimingEvent.pvid;
        networkEventInfoBean.isCustom = false;
        networkEventInfoBean.mRequestDataSize = a(ajaxPerformanceTimingEvent.requestHeader);
        a(networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, list);
        b(networkEventInfoBean, ajaxPerformanceTimingEvent.responseHeader, list4);
        c(networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, list3);
        networkEventInfoBean.mCustomBusinessBody = a(ajaxPerformanceTimingEvent.requestBody, list2);
        return networkEventInfoBean;
    }

    private static void a(NetworkEventInfoBean networkEventInfoBean, j jVar) {
        if (jVar.q() == null || !jVar.f().contains(jVar.q())) {
            long b9 = com.bonree.sdk.c.a.b();
            h.d(jVar.f());
            networkEventInfoBean.mDnsTimeUs = ((int) (com.bonree.sdk.c.a.b() - b9)) * 1000;
        }
    }

    private static void a(NetworkEventInfoBean networkEventInfoBean, j jVar, Map<String, j> map) {
        if (map == null) {
            return;
        }
        String str = jVar.f() + jVar.p() + jVar.g();
        if (str == null || map.containsKey(str)) {
            return;
        }
        a(networkEventInfoBean, jVar);
        if (jVar.h() > jVar.g()) {
            networkEventInfoBean.mConnectTimeUs = (int) ((jVar.h() - jVar.g()) * 1000);
        } else {
            networkEventInfoBean.mConnectTimeUs = 1000;
        }
        int m9 = jVar.m();
        networkEventInfoBean.mdownloadSizeByte = m9;
        if (m9 > 0) {
            if (jVar.b() != null && jVar.a() != null && jVar.b().size() > 0 && jVar.a().size() > 0) {
                long c9 = jVar.b().get(0).c();
                long c10 = jVar.a().get(0).c();
                if (c10 > 0 && c9 > c10) {
                    networkEventInfoBean.mResponseTimeUs = (int) ((c9 - c10) * 1000);
                }
            }
            if (networkEventInfoBean.mResponseTimeUs == 0) {
                networkEventInfoBean.mResponseTimeUs = 1000;
            }
            if (jVar.m() > 0) {
                networkEventInfoBean.mDownloadTimeUs = networkEventInfoBean.mResponseTimeUs;
            }
        }
        if (jVar.e() > 0) {
            networkEventInfoBean.mSslTimeUs = (int) (jVar.e() * 1000);
        }
        map.put(str, jVar);
    }

    private static NetworkEventInfoBean a(PagePerformanceTiming pagePerformanceTiming, long j9) {
        WebviewPerformanceTiming webviewPerformanceTiming;
        long j10;
        long j11;
        int abs;
        int abs2;
        int abs3;
        int abs4;
        String a9;
        List<WebviewResourceBean> list;
        if (pagePerformanceTiming == null) {
            return null;
        }
        String l9 = af.l(pagePerformanceTiming.getUrl());
        WebviewPerformanceTiming webviewPerformanceTiming2 = new WebviewPerformanceTiming();
        webviewPerformanceTiming2.ns = pagePerformanceTiming.getNs();
        webviewPerformanceTiming2.fs = pagePerformanceTiming.getFs();
        webviewPerformanceTiming2.reqs = pagePerformanceTiming.getReqs();
        webviewPerformanceTiming2.rsps = pagePerformanceTiming.getRsps();
        webviewPerformanceTiming2.rspe = pagePerformanceTiming.getRspe();
        webviewPerformanceTiming2.dcles = pagePerformanceTiming.getDcles();
        webviewPerformanceTiming2.dclee = pagePerformanceTiming.getDclee();
        webviewPerformanceTiming2.di = pagePerformanceTiming.getDi();
        webviewPerformanceTiming2.dc = pagePerformanceTiming.getDc();
        webviewPerformanceTiming2.dl = pagePerformanceTiming.getDl();
        webviewPerformanceTiming2.les = pagePerformanceTiming.getLes();
        webviewPerformanceTiming2.lee = pagePerformanceTiming.getLee();
        webviewPerformanceTiming2.ues = pagePerformanceTiming.getUes();
        webviewPerformanceTiming2.uee = pagePerformanceTiming.getUee();
        webviewPerformanceTiming2.cs = pagePerformanceTiming.getCs();
        webviewPerformanceTiming2.ce = pagePerformanceTiming.getCe();
        webviewPerformanceTiming2.dls = pagePerformanceTiming.getDls();
        webviewPerformanceTiming2.dle = pagePerformanceTiming.getDle();
        webviewPerformanceTiming2.rds = pagePerformanceTiming.getRds();
        webviewPerformanceTiming2.rde = pagePerformanceTiming.getRde();
        webviewPerformanceTiming2.scs = pagePerformanceTiming.getScs();
        WebViewInfoBean webViewInfoBean = new WebViewInfoBean();
        webViewInfoBean.pvid = pagePerformanceTiming.getPvid();
        webViewInfoBean.url = pagePerformanceTiming.getUrl();
        webViewInfoBean.webviewPerformanceTiming = webviewPerformanceTiming2;
        if (!af.b(l9) && (list = webViewInfoBean.webviewResources) != null && !list.isEmpty()) {
            Iterator<WebviewResourceBean> it = webViewInfoBean.webviewResources.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                WebviewResourceBean next = it.next();
                if (l9.equals(af.l(next.name))) {
                    webViewInfoBean.nextHopProtocol = next.nextHopProtocol;
                    break;
                }
            }
        }
        if (af.b(webViewInfoBean.url) || (webviewPerformanceTiming = webViewInfoBean.webviewPerformanceTiming) == null) {
            return null;
        }
        String str = webViewInfoBean.url;
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        int i9 = 1000;
        int i10 = webviewPerformanceTiming.dle * 1000;
        int i11 = webviewPerformanceTiming.dls * 1000;
        int i12 = webviewPerformanceTiming.ce * 1000;
        int i13 = webviewPerformanceTiming.cs * 1000;
        int i14 = webviewPerformanceTiming.reqs * 1000;
        int i15 = webviewPerformanceTiming.scs * 1000;
        int i16 = webviewPerformanceTiming.rsps * 1000;
        int i17 = webviewPerformanceTiming.rspe * 1000;
        int i18 = webviewPerformanceTiming.lee;
        if (i18 > 0) {
            j11 = i18 * 1000;
        } else {
            int i19 = webviewPerformanceTiming.les;
            if (i19 <= 0) {
                j10 = j9;
                networkEventInfoBean.startTime = j10;
                networkEventInfoBean.mRequestUrl = str;
                int abs5 = Math.abs(i10 - i11);
                abs = (i12 > i15 || i15 <= 0) ? 0 : Math.abs(i12 - i15);
                if (abs <= 0) {
                    abs2 = Math.abs(i12 - i13) - abs;
                } else {
                    abs2 = Math.abs(i12 - i13);
                }
                abs3 = Math.abs(i14 - i12);
                abs4 = Math.abs(i16 - i14);
                int abs6 = Math.abs(i17 - i16);
                networkEventInfoBean.mDnsTimeUs = abs5;
                networkEventInfoBean.mConnectTimeUs = abs2;
                if (str.startsWith("https://")) {
                    i9 = 0;
                } else if (Math.abs(i14 - i15) >= 1000) {
                    i9 = abs;
                }
                networkEventInfoBean.mSslTimeUs = i9;
                if (abs3 <= 0) {
                    abs3 = 999;
                }
                networkEventInfoBean.mRequestTimeUs = abs3;
                if (abs4 <= 0) {
                    abs4 = 999;
                }
                networkEventInfoBean.mResponseTimeUs = abs4;
                networkEventInfoBean.mDownloadTimeUs = Math.max(abs6, 999);
                networkEventInfoBean.mdownloadSizeByte = webViewInfoBean.pfl;
                networkEventInfoBean.mErrorCode = 200;
                networkEventInfoBean.mProtocolType = h.a(str, webViewInfoBean.nextHopProtocol);
                a9 = a.a(str);
                if (!TextUtils.isEmpty(a9)) {
                    networkEventInfoBean.mResourceType = a9;
                }
                networkEventInfoBean.mAppRequestType = 1;
                networkEventInfoBean.mPageId = webViewInfoBean.pvid;
                networkEventInfoBean.isCustom = false;
                if (!str.startsWith("http://") || str.startsWith("https://")) {
                    networkEventInfoBean.mMethod = "GET";
                }
                f3941a.c("  WebViewInfoBean:%s", networkEventInfoBean);
                return networkEventInfoBean;
            }
            j11 = i19 * 1000;
        }
        j10 = j9 - j11;
        networkEventInfoBean.startTime = j10;
        networkEventInfoBean.mRequestUrl = str;
        int abs52 = Math.abs(i10 - i11);
        if (i12 > i15) {
        }
        if (abs <= 0) {
        }
        abs3 = Math.abs(i14 - i12);
        abs4 = Math.abs(i16 - i14);
        int abs62 = Math.abs(i17 - i16);
        networkEventInfoBean.mDnsTimeUs = abs52;
        networkEventInfoBean.mConnectTimeUs = abs2;
        if (str.startsWith("https://")) {
        }
        networkEventInfoBean.mSslTimeUs = i9;
        if (abs3 <= 0) {
        }
        networkEventInfoBean.mRequestTimeUs = abs3;
        if (abs4 <= 0) {
        }
        networkEventInfoBean.mResponseTimeUs = abs4;
        networkEventInfoBean.mDownloadTimeUs = Math.max(abs62, 999);
        networkEventInfoBean.mdownloadSizeByte = webViewInfoBean.pfl;
        networkEventInfoBean.mErrorCode = 200;
        networkEventInfoBean.mProtocolType = h.a(str, webViewInfoBean.nextHopProtocol);
        a9 = a.a(str);
        if (!TextUtils.isEmpty(a9)) {
        }
        networkEventInfoBean.mAppRequestType = 1;
        networkEventInfoBean.mPageId = webViewInfoBean.pvid;
        networkEventInfoBean.isCustom = false;
        if (!str.startsWith("http://")) {
        }
        networkEventInfoBean.mMethod = "GET";
        f3941a.c("  WebViewInfoBean:%s", networkEventInfoBean);
        return networkEventInfoBean;
    }

    private static void b(NetworkEventInfoBean networkEventInfoBean) {
        if (networkEventInfoBean.mRequestUrl.startsWith("https://")) {
            networkEventInfoBean.mRequestUrl = networkEventInfoBean.mRequestUrl.replace("https:", "wss:");
        } else if (networkEventInfoBean.mRequestUrl.startsWith("http://")) {
            networkEventInfoBean.mRequestUrl = networkEventInfoBean.mRequestUrl.replace("http:", "ws:");
        }
    }

    private static synchronized void b(NetworkEventInfoBean networkEventInfoBean, String str, List<String> list) {
        String substring;
        synchronized (g.class) {
            if (list != null) {
                try {
                    if (!list.isEmpty()) {
                        if (TextUtils.isEmpty(str)) {
                            return;
                        }
                        HashMap hashMap = new HashMap();
                        String replaceAll = str.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                        String lowerCase = replaceAll.toLowerCase();
                        for (String str2 : list) {
                            if (!TextUtils.isEmpty(str2)) {
                                String replaceAll2 = str2.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                                String lowerCase2 = replaceAll2.toLowerCase();
                                if (lowerCase.contains(lowerCase2 + Constants.COLON_SEPARATOR)) {
                                    int indexOf = lowerCase.indexOf(lowerCase2) - 1;
                                    if (indexOf != -1) {
                                        String valueOf = String.valueOf(lowerCase.charAt(indexOf));
                                        if (!valueOf.equals(Constants.COLON_SEPARATOR) && !valueOf.equals("\n") && !valueOf.equals("\r")) {
                                        }
                                    }
                                    String substring2 = replaceAll.substring(lowerCase.indexOf(lowerCase2 + Constants.COLON_SEPARATOR));
                                    if (substring2.contains("\n")) {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1, substring2.indexOf("\n"));
                                    } else {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1);
                                    }
                                    if (substring.startsWith(HanziToPinyin.Token.SEPARATOR)) {
                                        substring = substring.replaceFirst(HanziToPinyin.Token.SEPARATOR, "");
                                    }
                                    hashMap.put(replaceAll2, substring.replace("\r", "").replace("\n", ""));
                                }
                            }
                        }
                        if (hashMap.size() > 0) {
                            networkEventInfoBean.mResponseTraceInfo = hashMap;
                        }
                    }
                } catch (Throwable th) {
                    f3941a.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
                }
            }
        }
    }

    public static Map<String, String> b(Map<String, String> map, List<String> list) {
        if (list != null && !list.isEmpty() && map != null && map.size() > 0) {
            HashMap hashMap = new HashMap();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (entry != null) {
                    hashMap.put(entry.getKey().toLowerCase(), entry.getValue());
                }
            }
            HashMap hashMap2 = new HashMap();
            try {
                synchronized (list) {
                    for (String str : list) {
                        if (!TextUtils.isEmpty(str)) {
                            String str2 = (String) hashMap.get(str.toLowerCase());
                            if (!TextUtils.isEmpty(str2)) {
                                hashMap2.put(str, str2);
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                f fVar = f3941a;
                fVar.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
            }
            if (hashMap2.size() > 0) {
                return hashMap2;
            }
        }
        return null;
    }

    private static NetworkEventInfoBean a(WebViewInfoBean webViewInfoBean, long j9) {
        WebviewPerformanceTiming webviewPerformanceTiming;
        long j10;
        long j11;
        int abs;
        int abs2;
        int abs3;
        int abs4;
        String a9;
        if (af.b(webViewInfoBean.url) || (webviewPerformanceTiming = webViewInfoBean.webviewPerformanceTiming) == null) {
            return null;
        }
        String str = webViewInfoBean.url;
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        int i9 = 1000;
        int i10 = webviewPerformanceTiming.dle * 1000;
        int i11 = webviewPerformanceTiming.dls * 1000;
        int i12 = webviewPerformanceTiming.ce * 1000;
        int i13 = webviewPerformanceTiming.cs * 1000;
        int i14 = webviewPerformanceTiming.reqs * 1000;
        int i15 = webviewPerformanceTiming.scs * 1000;
        int i16 = webviewPerformanceTiming.rsps * 1000;
        int i17 = webviewPerformanceTiming.rspe * 1000;
        int i18 = webviewPerformanceTiming.lee;
        if (i18 > 0) {
            j11 = i18 * 1000;
        } else {
            int i19 = webviewPerformanceTiming.les;
            if (i19 <= 0) {
                j10 = j9;
                networkEventInfoBean.startTime = j10;
                networkEventInfoBean.mRequestUrl = str;
                int abs5 = Math.abs(i10 - i11);
                abs = (i12 > i15 || i15 <= 0) ? 0 : Math.abs(i12 - i15);
                if (abs <= 0) {
                    abs2 = Math.abs(i12 - i13) - abs;
                } else {
                    abs2 = Math.abs(i12 - i13);
                }
                abs3 = Math.abs(i14 - i12);
                abs4 = Math.abs(i16 - i14);
                int abs6 = Math.abs(i17 - i16);
                networkEventInfoBean.mDnsTimeUs = abs5;
                networkEventInfoBean.mConnectTimeUs = abs2;
                if (str.startsWith("https://")) {
                    i9 = 0;
                } else if (Math.abs(i14 - i15) >= 1000) {
                    i9 = abs;
                }
                networkEventInfoBean.mSslTimeUs = i9;
                if (abs3 <= 0) {
                    abs3 = 999;
                }
                networkEventInfoBean.mRequestTimeUs = abs3;
                if (abs4 <= 0) {
                    abs4 = 999;
                }
                networkEventInfoBean.mResponseTimeUs = abs4;
                networkEventInfoBean.mDownloadTimeUs = Math.max(abs6, 999);
                networkEventInfoBean.mdownloadSizeByte = webViewInfoBean.pfl;
                networkEventInfoBean.mErrorCode = 200;
                networkEventInfoBean.mProtocolType = h.a(str, webViewInfoBean.nextHopProtocol);
                a9 = a.a(str);
                if (!TextUtils.isEmpty(a9)) {
                    networkEventInfoBean.mResourceType = a9;
                }
                networkEventInfoBean.mAppRequestType = 1;
                networkEventInfoBean.mPageId = webViewInfoBean.pvid;
                networkEventInfoBean.isCustom = false;
                if (!str.startsWith("http://") || str.startsWith("https://")) {
                    networkEventInfoBean.mMethod = "GET";
                }
                f3941a.c("  WebViewInfoBean:%s", networkEventInfoBean);
                return networkEventInfoBean;
            }
            j11 = i19 * 1000;
        }
        j10 = j9 - j11;
        networkEventInfoBean.startTime = j10;
        networkEventInfoBean.mRequestUrl = str;
        int abs52 = Math.abs(i10 - i11);
        if (i12 > i15) {
        }
        if (abs <= 0) {
        }
        abs3 = Math.abs(i14 - i12);
        abs4 = Math.abs(i16 - i14);
        int abs62 = Math.abs(i17 - i16);
        networkEventInfoBean.mDnsTimeUs = abs52;
        networkEventInfoBean.mConnectTimeUs = abs2;
        if (str.startsWith("https://")) {
        }
        networkEventInfoBean.mSslTimeUs = i9;
        if (abs3 <= 0) {
        }
        networkEventInfoBean.mRequestTimeUs = abs3;
        if (abs4 <= 0) {
        }
        networkEventInfoBean.mResponseTimeUs = abs4;
        networkEventInfoBean.mDownloadTimeUs = Math.max(abs62, 999);
        networkEventInfoBean.mdownloadSizeByte = webViewInfoBean.pfl;
        networkEventInfoBean.mErrorCode = 200;
        networkEventInfoBean.mProtocolType = h.a(str, webViewInfoBean.nextHopProtocol);
        a9 = a.a(str);
        if (!TextUtils.isEmpty(a9)) {
        }
        networkEventInfoBean.mAppRequestType = 1;
        networkEventInfoBean.mPageId = webViewInfoBean.pvid;
        networkEventInfoBean.isCustom = false;
        if (!str.startsWith("http://")) {
        }
        networkEventInfoBean.mMethod = "GET";
        f3941a.c("  WebViewInfoBean:%s", networkEventInfoBean);
        return networkEventInfoBean;
    }

    private static NetworkEventInfoBean a(ResourcePerformanceTiming resourcePerformanceTiming, long j9, long j10, String str) {
        long j11;
        long abs;
        try {
            WebviewResourceBean webviewResourceBean = new WebviewResourceBean();
            webviewResourceBean.startTime = resourcePerformanceTiming.getSt();
            webviewResourceBean.resourceType = resourcePerformanceTiming.getRt();
            webviewResourceBean.name = resourcePerformanceTiming.getName();
            webviewResourceBean.duration = resourcePerformanceTiming.getDura();
            webviewResourceBean.fetchStart = resourcePerformanceTiming.getFs();
            webviewResourceBean.domainLookupStart = resourcePerformanceTiming.getDls();
            webviewResourceBean.domainLookupEnd = resourcePerformanceTiming.getDle();
            webviewResourceBean.connectStart = resourcePerformanceTiming.getCs();
            webviewResourceBean.connectEnd = resourcePerformanceTiming.getCe();
            webviewResourceBean.secureConnectionStart = resourcePerformanceTiming.getScs();
            webviewResourceBean.requestStart = resourcePerformanceTiming.getReqs();
            webviewResourceBean.responseStart = resourcePerformanceTiming.getRsps();
            webviewResourceBean.responseEnd = resourcePerformanceTiming.getRspe();
            webviewResourceBean.transferSize = resourcePerformanceTiming.getTs();
            webviewResourceBean.encodedBodySize = resourcePerformanceTiming.getEbs();
            webviewResourceBean.decodedBodySize = resourcePerformanceTiming.getDbs();
            webviewResourceBean.nextHopProtocol = resourcePerformanceTiming.getPr();
            webviewResourceBean.pvid = str;
            String str2 = webviewResourceBean.name;
            if (af.b(str2)) {
                return null;
            }
            NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
            long j12 = webviewResourceBean.startTime;
            long j13 = j12 * 1000;
            long j14 = webviewResourceBean.domainLookupEnd * 1000;
            long j15 = webviewResourceBean.domainLookupStart * 1000;
            long j16 = webviewResourceBean.connectEnd * 1000;
            long j17 = webviewResourceBean.connectStart * 1000;
            long j18 = webviewResourceBean.requestStart * 1000;
            long j19 = webviewResourceBean.secureConnectionStart * 1000;
            long j20 = webviewResourceBean.responseStart * 1000;
            long j21 = webviewResourceBean.responseEnd * 1000;
            long j22 = webviewResourceBean.duration * 1000;
            long j23 = webviewResourceBean.encodedBodySize;
            networkEventInfoBean.mRequestUrl = str2;
            if (j10 > 0) {
                j11 = j12 > 0 ? j10 + (j12 * 1000) : j10;
            } else if (j12 > 0) {
                Long.signum(j12);
                j11 = j9 - (j12 * 1000);
            } else {
                j11 = j9;
            }
            networkEventInfoBean.startTime = j11;
            int i9 = (int) j23;
            int i10 = (j20 > 0L ? 1 : (j20 == 0L ? 0 : -1));
            if (i10 != 0) {
                int abs2 = (j16 < j19 || j19 <= 0) ? 0 : (int) Math.abs(j16 - j19);
                int abs3 = (int) Math.abs(j18 - j16);
                int abs4 = (int) Math.abs(j20 - j18);
                if (i10 > 0) {
                    abs = Math.abs(j21 - j20);
                } else if (j16 > 0) {
                    abs = Math.abs(j21 - j16);
                } else if (j14 > 0) {
                    abs = Math.abs(j21 - j14);
                } else {
                    abs = Math.abs(j21 - j13);
                }
                int i11 = (int) abs;
                networkEventInfoBean.mDnsTimeUs = (int) Math.abs(j14 - j15);
                if (j19 >= j17 && j19 > 0) {
                    networkEventInfoBean.mConnectTimeUs = (int) Math.abs(j19 - j17);
                } else if (j16 > 0) {
                    networkEventInfoBean.mConnectTimeUs = (int) Math.abs(j16 - j17);
                }
                if (!str2.startsWith("https://")) {
                    abs2 = 0;
                }
                networkEventInfoBean.mSslTimeUs = abs2;
                if (abs3 <= 0) {
                    abs3 = 999;
                }
                networkEventInfoBean.mRequestTimeUs = abs3;
                if (abs4 <= 0) {
                    abs4 = 999;
                }
                networkEventInfoBean.mResponseTimeUs = abs4;
                networkEventInfoBean.mDownloadTimeUs = Math.max(i11, 999);
            } else if (j22 > 10000) {
                networkEventInfoBean.mResponseTimeUs = (int) j22;
            }
            networkEventInfoBean.mdownloadSizeByte = i9;
            if (str2.startsWith("http://") || str2.startsWith("https://")) {
                networkEventInfoBean.mMethod = "GET";
            }
            networkEventInfoBean.mErrorCode = 200;
            networkEventInfoBean.mProtocolType = h.a(str2, webviewResourceBean.nextHopProtocol);
            String a9 = a.a(str2);
            if (!TextUtils.isEmpty(a9)) {
                networkEventInfoBean.mResourceType = a9;
            }
            networkEventInfoBean.isCustom = false;
            networkEventInfoBean.mAppRequestType = 2;
            networkEventInfoBean.mPageId = webviewResourceBean.pvid;
            f3941a.a("page resourceType :%s", networkEventInfoBean);
            return networkEventInfoBean;
        } catch (Throwable th) {
            f3941a.a("add webview resource exception:", th);
            return null;
        }
    }

    private static NetworkEventInfoBean a(WebviewResourceBean webviewResourceBean, long j9, long j10) {
        long abs;
        String str = webviewResourceBean.name;
        if (af.b(str)) {
            return null;
        }
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        long j11 = webviewResourceBean.startTime;
        long j12 = j11 * 1000;
        long j13 = webviewResourceBean.domainLookupEnd * 1000;
        long j14 = webviewResourceBean.domainLookupStart * 1000;
        long j15 = webviewResourceBean.connectEnd * 1000;
        long j16 = webviewResourceBean.connectStart * 1000;
        long j17 = webviewResourceBean.requestStart * 1000;
        long j18 = webviewResourceBean.secureConnectionStart * 1000;
        long j19 = webviewResourceBean.responseStart * 1000;
        long j20 = webviewResourceBean.responseEnd * 1000;
        long j21 = webviewResourceBean.duration * 1000;
        long j22 = webviewResourceBean.encodedBodySize;
        networkEventInfoBean.mRequestUrl = str;
        networkEventInfoBean.startTime = j10 <= 0 ? j11 > 0 ? j9 - (j11 * 1000) : j9 : j11 > 0 ? j10 + (j11 * 1000) : j10;
        int i9 = (int) j22;
        int i10 = (j19 > 0L ? 1 : (j19 == 0L ? 0 : -1));
        if (i10 != 0) {
            int abs2 = (j15 < j18 || j18 <= 0) ? 0 : (int) Math.abs(j15 - j18);
            int abs3 = (int) Math.abs(j17 - j15);
            int i11 = abs2;
            int abs4 = (int) Math.abs(j19 - j17);
            if (i10 > 0) {
                abs = Math.abs(j20 - j19);
            } else if (j15 > 0) {
                abs = Math.abs(j20 - j15);
            } else if (j13 > 0) {
                abs = Math.abs(j20 - j13);
            } else {
                abs = Math.abs(j20 - j12);
            }
            int i12 = (int) abs;
            networkEventInfoBean.mDnsTimeUs = (int) Math.abs(j13 - j14);
            if (j18 >= j16 && j18 > 0) {
                networkEventInfoBean.mConnectTimeUs = (int) Math.abs(j18 - j16);
            } else if (j15 > 0) {
                networkEventInfoBean.mConnectTimeUs = (int) Math.abs(j15 - j16);
            }
            networkEventInfoBean.mSslTimeUs = str.startsWith("https://") ? i11 : 0;
            if (abs3 <= 0) {
                abs3 = 999;
            }
            networkEventInfoBean.mRequestTimeUs = abs3;
            if (abs4 <= 0) {
                abs4 = 999;
            }
            networkEventInfoBean.mResponseTimeUs = abs4;
            networkEventInfoBean.mDownloadTimeUs = Math.max(i12, 999);
        } else if (j21 > 10000) {
            networkEventInfoBean.mResponseTimeUs = (int) j21;
        }
        networkEventInfoBean.mdownloadSizeByte = i9;
        if (str.startsWith("http://") || str.startsWith("https://")) {
            networkEventInfoBean.mMethod = "GET";
        }
        networkEventInfoBean.mErrorCode = 200;
        networkEventInfoBean.mProtocolType = h.a(str, webviewResourceBean.nextHopProtocol);
        String a9 = a.a(str);
        if (!TextUtils.isEmpty(a9)) {
            networkEventInfoBean.mResourceType = a9;
        }
        networkEventInfoBean.isCustom = false;
        networkEventInfoBean.mAppRequestType = 2;
        networkEventInfoBean.mPageId = webviewResourceBean.pvid;
        f3941a.a("page resourceType :%s", networkEventInfoBean);
        return networkEventInfoBean;
    }

    public static NetworkEventInfoBean a(com.bonree.sdk.o.e eVar, int i9, List<String> list, List<String> list2, List<String> list3) {
        if (TextUtils.isEmpty(eVar.c())) {
            return null;
        }
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        if (!TextUtils.isEmpty(eVar.f())) {
            networkEventInfoBean.mTargetIp = eVar.f();
            networkEventInfoBean.mTargetPort = eVar.g();
        } else {
            networkEventInfoBean.mTargetPort = 0;
        }
        networkEventInfoBean.startTime = eVar.C();
        networkEventInfoBean.mRequestUrl = eVar.c();
        networkEventInfoBean.mDnsTimeUs = eVar.i() * 1000;
        networkEventInfoBean.mConnectTimeUs = eVar.j() * 1000;
        networkEventInfoBean.mSslTimeUs = eVar.k() * 1000;
        networkEventInfoBean.mRequestTimeUs = eVar.l() * 1000;
        networkEventInfoBean.mResponseTimeUs = eVar.m() * 1000;
        networkEventInfoBean.mDownloadTimeUs = eVar.n() * 1000;
        networkEventInfoBean.mdownloadSizeByte = (int) eVar.p();
        networkEventInfoBean.mErrorCode = Integer.valueOf(eVar.w());
        int i10 = eVar.f6363a;
        if (i10 > 0) {
            networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(i10);
        }
        if (!TextUtils.isEmpty(eVar.a())) {
            networkEventInfoBean.mErrorMsg = eVar.a();
        }
        networkEventInfoBean.mMethod = eVar.y();
        networkEventInfoBean.mProtocolType = h.a(eVar.c(), eVar.q());
        String z8 = eVar.z();
        if (!TextUtils.isEmpty(z8)) {
            networkEventInfoBean.mResourceType = z8;
        }
        networkEventInfoBean.mAppRequestType = 10;
        networkEventInfoBean.isCustom = false;
        networkEventInfoBean.mMethod = eVar.y();
        networkEventInfoBean.mRequestDataSize = eVar.o();
        if (eVar.t() != null && eVar.t().size() > 0) {
            String a9 = x.a(eVar.t());
            if (!TextUtils.isEmpty(a9)) {
                networkEventInfoBean.mTraceId = a9;
            }
            String b9 = x.b(eVar.t());
            if (!TextUtils.isEmpty(b9)) {
                networkEventInfoBean.xBrResponse = b9;
            }
            String c9 = x.c(eVar.t());
            if (!TextUtils.isEmpty(c9)) {
                networkEventInfoBean.traceResponse = c9;
            }
        }
        if (eVar.w() >= 400 && eVar.w() < 600) {
            networkEventInfoBean.mErrorOccurrentProcess = 4;
        }
        a(i9, eVar.w(), networkEventInfoBean, eVar.r(), eVar.u());
        networkEventInfoBean.mCustomBusinessHeader = a(eVar.s(), list);
        networkEventInfoBean.mResponseTraceInfo = b(eVar.t(), list3);
        networkEventInfoBean.mRequestTraceInfo = c(eVar.s(), list2);
        f3941a.a("networkEventBean okhttp3Eventlistener:%s", networkEventInfoBean);
        return networkEventInfoBean;
    }

    private static void a(int i9, int i10, NetworkEventInfoBean networkEventInfoBean, String str, String str2) {
        if (i9 == 0) {
            networkEventInfoBean.mRequestHeader = null;
            networkEventInfoBean.mResponseHeader = null;
        } else if (i9 == 2) {
            a(networkEventInfoBean, str);
            b(networkEventInfoBean, str2);
        } else if (i9 != 1 || i10 < 400) {
        } else {
            a(networkEventInfoBean, str);
            if (i10 < 600) {
                networkEventInfoBean.mErrorOccurrentProcess = 4;
                b(networkEventInfoBean, str2);
            }
        }
    }

    public static void a(EventBean eventBean, NetworkEventInfoBean networkEventInfoBean) {
        Integer num;
        Integer num2;
        if (networkEventInfoBean == null || (num = networkEventInfoBean.mErrorCode) == null) {
            return;
        }
        if (num.intValue() >= 400 || (((num2 = networkEventInfoBean.mErrorOccurrentProcess) != null && num2.intValue() > 0) || !(TextUtils.isEmpty(networkEventInfoBean.mErrorMsg) || networkEventInfoBean.mErrorMsg.equals("null")))) {
            eventBean.mTraceInfoList = com.bonree.sdk.be.c.h().f();
        }
    }

    private static void a(NetworkEventInfoBean networkEventInfoBean, String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        networkEventInfoBean.mRequestHeader = str;
    }

    public static NetworkEventInfoBean a(com.bonree.sdk.o.b bVar, int i9) {
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mIdentifier = bVar.X();
        networkEventInfoBean.startTime = bVar.R();
        networkEventInfoBean.mRequestUrl = bVar.f();
        if (!TextUtils.isEmpty(bVar.j())) {
            networkEventInfoBean.mErrorMsg = bVar.j();
        }
        int i10 = bVar.f6363a;
        if (i10 > 0) {
            networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(i10);
        }
        networkEventInfoBean.mErrorCode = Integer.valueOf(bVar.k());
        if (!af.b(bVar.u())) {
            networkEventInfoBean.mProtocolType = h.a(bVar.f(), bVar.u());
        } else {
            networkEventInfoBean.mProtocolType = h.c(bVar.f());
        }
        if (bVar.y() == null) {
            networkEventInfoBean.mTargetPort = 0;
        } else {
            networkEventInfoBean.mTargetIp = bVar.y();
            networkEventInfoBean.mTargetPort = bVar.z();
        }
        networkEventInfoBean.mRequestTimeUs = bVar.E() * 1000;
        if (!TextUtils.isEmpty(bVar.Q())) {
            networkEventInfoBean.mMethod = bVar.Q();
        } else {
            int i11 = networkEventInfoBean.mProtocolType;
            if (i11 == 1 || i11 == 2 || i11 == 3) {
                networkEventInfoBean.mMethod = "GET";
            }
        }
        if (a(bVar)) {
            if (networkEventInfoBean.mRequestUrl.startsWith("https://")) {
                networkEventInfoBean.mRequestUrl = networkEventInfoBean.mRequestUrl.replace("https:", "wss:");
            } else if (networkEventInfoBean.mRequestUrl.startsWith("http://")) {
                networkEventInfoBean.mRequestUrl = networkEventInfoBean.mRequestUrl.replace("http:", "ws:");
            }
        } else {
            networkEventInfoBean.mDnsTimeUs = bVar.A() >= 0 ? bVar.A() * 1000 : bVar.A();
            networkEventInfoBean.mConnectTimeUs = bVar.B() >= 0 ? bVar.B() * 1000 : bVar.B();
            networkEventInfoBean.mSslTimeUs = bVar.D() >= 0 ? bVar.D() * 1000 : bVar.D();
            int m9 = (int) bVar.m();
            networkEventInfoBean.mdownloadSizeByte = m9;
            if (m9 <= 0) {
                networkEventInfoBean.mdownloadSizeByte = (int) bVar.L();
            }
            int G = bVar.G() * 1000;
            networkEventInfoBean.mDownloadTimeUs = G;
            if (G <= 0) {
                networkEventInfoBean.mDownloadTimeUs = bVar.K() * 1000;
            }
            String t9 = bVar.t();
            if (!TextUtils.isEmpty(t9)) {
                networkEventInfoBean.mResourceType = t9;
            }
        }
        if (bVar.O() != null && bVar.O().size() > 0) {
            String a9 = x.a(bVar.O());
            if (!TextUtils.isEmpty(a9)) {
                networkEventInfoBean.mTraceId = a9;
            }
            String b9 = x.b(bVar.O());
            if (!TextUtils.isEmpty(b9)) {
                networkEventInfoBean.xBrResponse = b9;
            }
            String c9 = x.c(bVar.O());
            if (!TextUtils.isEmpty(c9)) {
                networkEventInfoBean.traceResponse = c9;
            }
        }
        if (bVar.k() >= 400 && bVar.k() < 600) {
            networkEventInfoBean.mErrorOccurrentProcess = 4;
        }
        a(i9, bVar.k(), networkEventInfoBean, bVar.v(), bVar.d());
        networkEventInfoBean.mAppRequestType = 10;
        networkEventInfoBean.isCustom = false;
        return networkEventInfoBean;
    }

    public static boolean a(com.bonree.sdk.o.b bVar, NetworkEventInfoBean networkEventInfoBean, j jVar, boolean z8) {
        int i9;
        boolean z9;
        long H;
        long b9;
        int i10;
        int i11;
        if (a(bVar)) {
            if (TextUtils.isEmpty(networkEventInfoBean.mTargetIp) && jVar != null) {
                networkEventInfoBean.mTargetIp = jVar.q();
                networkEventInfoBean.mTargetPort = jVar.p();
            }
        } else {
            if (jVar == null && networkEventInfoBean.mErrorCode.intValue() == 200 && !z8) {
                f3941a.c("没有socketData:" + networkEventInfoBean.mRequestUrl, new Object[0]);
                return false;
            } else if (jVar == null) {
                f3941a.c("没有关联到socketData:" + networkEventInfoBean.mRequestUrl, new Object[0]);
            } else {
                f3941a.c("socketData mathch:" + jVar.toString(), new Object[0]);
                if (!h.a(networkEventInfoBean.mErrorCode.intValue())) {
                    if (TextUtils.isEmpty(networkEventInfoBean.mTargetIp)) {
                        if (h.a() != null && h.a().contains(jVar.q())) {
                            f3941a.c(" socketData proxy ", new Object[0]);
                        } else {
                            networkEventInfoBean.mTargetIp = jVar.q();
                            networkEventInfoBean.mTargetPort = jVar.p();
                        }
                    }
                    if (!h.b(networkEventInfoBean.mErrorCode.intValue())) {
                        if (networkEventInfoBean.mConnectTimeUs > 0 || bVar.b() >= jVar.g() || jVar.h() <= 0 || jVar.g() <= 0) {
                            i9 = 0;
                        } else {
                            i9 = (int) ((jVar.h() - jVar.g()) * 1000);
                            if (bVar.C() > 0) {
                                networkEventInfoBean.mConnectTimeUs = bVar.C() * 1000;
                                z9 = true;
                                if (!h.c(networkEventInfoBean.mErrorCode.intValue())) {
                                    if (networkEventInfoBean.mSslTimeUs <= 0 && h.b(networkEventInfoBean.mRequestUrl) && networkEventInfoBean.mConnectTimeUs > 0) {
                                        int e9 = (int) (jVar.e() * 1000);
                                        networkEventInfoBean.mSslTimeUs = e9;
                                        if (e9 <= 0) {
                                            if (i9 <= 0) {
                                                i9 = networkEventInfoBean.mConnectTimeUs;
                                            }
                                            int i12 = (int) ((i9 / 0.7f) * 0.3f);
                                            networkEventInfoBean.mSslTimeUs = i12;
                                            if (z9) {
                                                networkEventInfoBean.mConnectTimeUs -= i12;
                                            } else if (jVar.i() > 0 && jVar.h() > 0 && jVar.h() + (networkEventInfoBean.mSslTimeUs / 1000) > jVar.i() && (i10 = networkEventInfoBean.mConnectTimeUs) > (i11 = networkEventInfoBean.mSslTimeUs)) {
                                                networkEventInfoBean.mConnectTimeUs = i10 - i11;
                                            }
                                        } else if (z9) {
                                            networkEventInfoBean.mConnectTimeUs -= e9;
                                        }
                                    }
                                    if (!h.d(networkEventInfoBean.mErrorCode.intValue())) {
                                        if (networkEventInfoBean.mRequestTimeUs <= 0 && jVar.i() > 0) {
                                            networkEventInfoBean.mRequestTimeUs = jVar.j() - jVar.i() > 0 ? (int) ((jVar.j() - jVar.i()) * 1000) : 1000;
                                        }
                                        if (!h.e(networkEventInfoBean.mErrorCode.intValue())) {
                                            if (networkEventInfoBean.mResponseTimeUs <= 0) {
                                                if (jVar.k() > 0 && jVar.i() > 0) {
                                                    networkEventInfoBean.mResponseTimeUs = jVar.k() - jVar.i() > 0 ? (int) ((jVar.k() - jVar.i()) * 1000) : 1000;
                                                } else if (bVar.H() > 0) {
                                                    if (bVar.I() > 0 && bVar.H() > bVar.I()) {
                                                        H = bVar.H();
                                                        b9 = bVar.I();
                                                    } else if (bVar.e() > 0 && bVar.H() > bVar.e()) {
                                                        H = bVar.H();
                                                        b9 = bVar.e();
                                                    } else {
                                                        H = bVar.H();
                                                        b9 = bVar.b();
                                                    }
                                                    int i13 = (int) ((H - b9) * 1000);
                                                    if (i13 > networkEventInfoBean.mDnsTimeUs + networkEventInfoBean.mConnectTimeUs + networkEventInfoBean.mSslTimeUs && bVar.b() < jVar.g() && bVar.H() > jVar.h()) {
                                                        networkEventInfoBean.mResponseTimeUs = ((i13 - networkEventInfoBean.mDnsTimeUs) - networkEventInfoBean.mConnectTimeUs) - networkEventInfoBean.mSslTimeUs;
                                                    } else {
                                                        networkEventInfoBean.mResponseTimeUs = i13;
                                                    }
                                                }
                                            }
                                            if (networkEventInfoBean.mDownloadTimeUs <= 0 && jVar.l() > 0 && jVar.k() > 0) {
                                                networkEventInfoBean.mDownloadTimeUs = jVar.l() - jVar.k() > 0 ? (int) ((jVar.l() - jVar.k()) * 1000) : 0;
                                            }
                                            if (networkEventInfoBean.mdownloadSizeByte <= 0) {
                                                networkEventInfoBean.mdownloadSizeByte = jVar.m();
                                            }
                                        }
                                    }
                                }
                            } else {
                                networkEventInfoBean.mConnectTimeUs = i9;
                            }
                        }
                        z9 = false;
                        if (!h.c(networkEventInfoBean.mErrorCode.intValue())) {
                        }
                    }
                }
            }
        }
        return true;
    }

    public static NetworkEventInfoBean a(com.bonree.sdk.o.b bVar, Map<String, List> map, int i9) {
        Integer valueOf;
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mRequestUrl = bVar.f();
        if (af.b(bVar.Q())) {
            networkEventInfoBean.mMethod = "GET";
        } else {
            networkEventInfoBean.mMethod = bVar.Q();
        }
        networkEventInfoBean.mdownloadSizeByte = (int) bVar.m();
        String t9 = bVar.t();
        if (af.d(t9)) {
            networkEventInfoBean.mResourceType = t9;
        }
        networkEventInfoBean.mConnectTimeUs = bVar.B() * 1000;
        networkEventInfoBean.mResponseTimeUs = bVar.F() > 0 ? bVar.F() * 1000 : 0;
        networkEventInfoBean.mErrorCode = Integer.valueOf(bVar.i());
        if (af.d(bVar.j())) {
            networkEventInfoBean.mErrorMsg = bVar.j();
        }
        if (!TextUtils.isEmpty(bVar.j()) || (400 <= bVar.i() && bVar.i() <= 600)) {
            String j9 = bVar.j();
            com.bonree.sdk.bl.g.a(" throw message:" + j9, new Object[0]);
            int i10 = 3;
            if (!TextUtils.isEmpty(j9)) {
                if (j9.contains("SocketException: Failed host lookup")) {
                    i10 = 2;
                } else if (!j9.contains("SocketException: OS Error: Connection timed out") && !j9.contains("SocketException: HTTP connection timed out afte")) {
                    if (j9.contains("HandshakeException: Handshake error in client")) {
                        i10 = 1;
                    }
                }
                valueOf = Integer.valueOf(i10);
                networkEventInfoBean.mErrorOccurrentProcess = valueOf;
                if (valueOf.intValue() == 2) {
                    networkEventInfoBean.mErrorCode = 659;
                }
            }
            i10 = 4;
            valueOf = Integer.valueOf(i10);
            networkEventInfoBean.mErrorOccurrentProcess = valueOf;
            if (valueOf.intValue() == 2) {
            }
        }
        a(i9, bVar.i(), networkEventInfoBean, bVar.v(), bVar.d());
        String l9 = af.l(networkEventInfoBean.mRequestUrl);
        if (!TextUtils.isEmpty(l9)) {
            String[] b9 = h.b(networkEventInfoBean.mRequestUrl, l9);
            if (!TextUtils.isEmpty(b9[0])) {
                networkEventInfoBean.mTargetIp = b9[0];
            }
            networkEventInfoBean.mTargetPort = Integer.parseInt(b9[1]);
        }
        List<String> a9 = h.a(l9, map);
        if (a9 != null && !a9.isEmpty()) {
            networkEventInfoBean.mCNameArray = a9;
        }
        networkEventInfoBean.mProtocolType = h.c(bVar.f());
        networkEventInfoBean.mAppRequestType = 10;
        networkEventInfoBean.isCustom = false;
        a(networkEventInfoBean);
        f3941a.a("flutter frame data:%s", networkEventInfoBean);
        return networkEventInfoBean;
    }

    private static void a(NetworkEventInfoBean networkEventInfoBean, j jVar, com.bonree.sdk.o.b bVar) {
        int i9;
        boolean z8;
        long H;
        long b9;
        int i10;
        int i11;
        if (jVar == null) {
            f3941a.c("没有关联到socketData:" + networkEventInfoBean.mRequestUrl, new Object[0]);
            return;
        }
        f3941a.c("socketData mathch:" + jVar.toString(), new Object[0]);
        if (h.a(networkEventInfoBean.mErrorCode.intValue())) {
            return;
        }
        if (TextUtils.isEmpty(networkEventInfoBean.mTargetIp)) {
            if (h.a() != null && h.a().contains(jVar.q())) {
                f3941a.c(" socketData proxy ", new Object[0]);
            } else {
                networkEventInfoBean.mTargetIp = jVar.q();
                networkEventInfoBean.mTargetPort = jVar.p();
            }
        }
        if (h.b(networkEventInfoBean.mErrorCode.intValue())) {
            return;
        }
        if (networkEventInfoBean.mConnectTimeUs > 0 || bVar.b() >= jVar.g() || jVar.h() <= 0 || jVar.g() <= 0) {
            i9 = 0;
        } else {
            i9 = (int) ((jVar.h() - jVar.g()) * 1000);
            if (bVar.C() > 0) {
                networkEventInfoBean.mConnectTimeUs = bVar.C() * 1000;
                z8 = true;
                if (h.c(networkEventInfoBean.mErrorCode.intValue())) {
                    if (networkEventInfoBean.mSslTimeUs <= 0 && h.b(networkEventInfoBean.mRequestUrl) && networkEventInfoBean.mConnectTimeUs > 0) {
                        int e9 = (int) (jVar.e() * 1000);
                        networkEventInfoBean.mSslTimeUs = e9;
                        if (e9 <= 0) {
                            if (i9 <= 0) {
                                i9 = networkEventInfoBean.mConnectTimeUs;
                            }
                            int i12 = (int) ((i9 / 0.7f) * 0.3f);
                            networkEventInfoBean.mSslTimeUs = i12;
                            if (z8) {
                                networkEventInfoBean.mConnectTimeUs -= i12;
                            } else if (jVar.i() > 0 && jVar.h() > 0 && jVar.h() + (networkEventInfoBean.mSslTimeUs / 1000) > jVar.i() && (i10 = networkEventInfoBean.mConnectTimeUs) > (i11 = networkEventInfoBean.mSslTimeUs)) {
                                networkEventInfoBean.mConnectTimeUs = i10 - i11;
                            }
                        } else if (z8) {
                            networkEventInfoBean.mConnectTimeUs -= e9;
                        }
                    }
                    if (h.d(networkEventInfoBean.mErrorCode.intValue())) {
                        return;
                    }
                    if (networkEventInfoBean.mRequestTimeUs <= 0 && jVar.i() > 0) {
                        networkEventInfoBean.mRequestTimeUs = jVar.j() - jVar.i() > 0 ? (int) ((jVar.j() - jVar.i()) * 1000) : 1000;
                    }
                    if (h.e(networkEventInfoBean.mErrorCode.intValue())) {
                        return;
                    }
                    if (networkEventInfoBean.mResponseTimeUs <= 0) {
                        if (jVar.k() > 0 && jVar.i() > 0) {
                            networkEventInfoBean.mResponseTimeUs = jVar.k() - jVar.i() > 0 ? (int) ((jVar.k() - jVar.i()) * 1000) : 1000;
                        } else if (bVar.H() > 0) {
                            if (bVar.I() > 0 && bVar.H() > bVar.I()) {
                                H = bVar.H();
                                b9 = bVar.I();
                            } else if (bVar.e() > 0 && bVar.H() > bVar.e()) {
                                H = bVar.H();
                                b9 = bVar.e();
                            } else {
                                H = bVar.H();
                                b9 = bVar.b();
                            }
                            int i13 = (int) ((H - b9) * 1000);
                            if (i13 > networkEventInfoBean.mDnsTimeUs + networkEventInfoBean.mConnectTimeUs + networkEventInfoBean.mSslTimeUs && bVar.b() < jVar.g() && bVar.H() > jVar.h()) {
                                networkEventInfoBean.mResponseTimeUs = ((i13 - networkEventInfoBean.mDnsTimeUs) - networkEventInfoBean.mConnectTimeUs) - networkEventInfoBean.mSslTimeUs;
                            } else {
                                networkEventInfoBean.mResponseTimeUs = i13;
                            }
                        }
                    }
                    if (networkEventInfoBean.mDownloadTimeUs <= 0 && jVar.l() > 0 && jVar.k() > 0) {
                        networkEventInfoBean.mDownloadTimeUs = jVar.l() - jVar.k() > 0 ? (int) ((jVar.l() - jVar.k()) * 1000) : 0;
                    }
                    if (networkEventInfoBean.mdownloadSizeByte <= 0) {
                        networkEventInfoBean.mdownloadSizeByte = jVar.m();
                        return;
                    }
                    return;
                }
                return;
            }
            networkEventInfoBean.mConnectTimeUs = i9;
        }
        z8 = false;
        if (h.c(networkEventInfoBean.mErrorCode.intValue())) {
        }
    }

    public static void a(NetworkEventInfoBean networkEventInfoBean, Map<String, List> map) {
        List<String> a9;
        if (networkEventInfoBean == null) {
            return;
        }
        String l9 = af.l(networkEventInfoBean.mRequestUrl);
        if ((TextUtils.isEmpty(networkEventInfoBean.mTargetIp) || networkEventInfoBean.mTargetIp.equals("0")) && !h.a(networkEventInfoBean.mErrorCode.intValue())) {
            String[] b9 = h.b(networkEventInfoBean.mRequestUrl, l9);
            if (!TextUtils.isEmpty(b9[0])) {
                networkEventInfoBean.mTargetIp = b9[0];
            }
            networkEventInfoBean.mTargetPort = Integer.parseInt(b9[1]);
        }
        int i9 = networkEventInfoBean.mDnsTimeUs;
        if (i9 != 0 && i9 <= 999 && !h.a(networkEventInfoBean.mErrorCode.intValue())) {
            networkEventInfoBean.mDnsTimeUs = 999;
        }
        int i10 = networkEventInfoBean.mConnectTimeUs;
        if (i10 != 0 && i10 <= 999 && !h.b(networkEventInfoBean.mErrorCode.intValue())) {
            networkEventInfoBean.mConnectTimeUs = 999;
        }
        if (!h.b(networkEventInfoBean.mRequestUrl) && networkEventInfoBean.mTargetPort != 443) {
            networkEventInfoBean.mSslTimeUs = 0;
        } else if (networkEventInfoBean.mConnectTimeUs > 0 && networkEventInfoBean.mSslTimeUs <= 0 && !h.c(networkEventInfoBean.mErrorCode.intValue())) {
            networkEventInfoBean.mSslTimeUs = 999;
        }
        int i11 = networkEventInfoBean.mRequestTimeUs;
        if (i11 > 0 && i11 <= 999 && networkEventInfoBean.mErrorCode.intValue() == 200) {
            networkEventInfoBean.mRequestTimeUs = 999;
        } else if (networkEventInfoBean.mRequestTimeUs == 0 && networkEventInfoBean.mResponseTimeUs > 0) {
            networkEventInfoBean.mRequestTimeUs = 999;
        }
        int i12 = networkEventInfoBean.mDownloadTimeUs;
        if (i12 > 0 && i12 <= 999 && networkEventInfoBean.mErrorCode.intValue() == 200) {
            networkEventInfoBean.mDownloadTimeUs = 999;
        }
        if (!TextUtils.isEmpty(networkEventInfoBean.mRequestUrl) && !TextUtils.isEmpty(networkEventInfoBean.mTargetIp) && networkEventInfoBean.mRequestUrl.contains(networkEventInfoBean.mTargetIp)) {
            networkEventInfoBean.mDnsTimeUs = 0;
        } else if (!af.b(l9) && (a9 = h.a(l9, map)) != null && !a9.isEmpty()) {
            networkEventInfoBean.mCNameArray = a9;
        }
        String str = networkEventInfoBean.mRequestHeader;
        if (str != null && str.contains("br_request_id")) {
            String str2 = networkEventInfoBean.mRequestHeader;
            String substring = str2.substring(str2.indexOf("br_request_id"));
            String trim = networkEventInfoBean.mRequestHeader.replace(substring.substring(0, substring.indexOf("\n") + 1), "").trim();
            if (TextUtils.isEmpty(trim)) {
                trim = null;
            }
            networkEventInfoBean.mRequestHeader = trim;
        }
        a(networkEventInfoBean);
        if (networkEventInfoBean.mResponseTimeUs < 0) {
            networkEventInfoBean.mResponseTimeUs = 999;
        }
    }

    private static void a(NetworkEventInfoBean networkEventInfoBean) {
        if (networkEventInfoBean.mErrorCode.intValue() >= 600 || networkEventInfoBean.mErrorCode.intValue() < 400) {
            return;
        }
        networkEventInfoBean.mErrorPlatform = HttpConstant.HTTP;
    }

    private static NetworkEventInfoBean a(AjaxPerformanceTimingEvent ajaxPerformanceTimingEvent, long j9, List<String> list, List<String> list2, List<String> list3, List<String> list4, int i9) {
        if (ajaxPerformanceTimingEvent == null || af.b(ajaxPerformanceTimingEvent.ajaxUrl)) {
            return null;
        }
        if (!h.e(ajaxPerformanceTimingEvent.ajaxUrl)) {
            String str = ajaxPerformanceTimingEvent.pageUrl;
            if (!af.b(str)) {
                String c9 = af.c(str, ajaxPerformanceTimingEvent.ajaxUrl);
                if (af.b(c9)) {
                    return null;
                }
                ajaxPerformanceTimingEvent.ajaxUrl = c9;
            }
        }
        if (af.b(ajaxPerformanceTimingEvent.ajaxUrl)) {
            return null;
        }
        String str2 = ajaxPerformanceTimingEvent.ajaxUrl;
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mRequestUrl = str2;
        int i10 = (int) (ajaxPerformanceTimingEvent.dnsStart * 1000.0d);
        int i11 = (int) (ajaxPerformanceTimingEvent.dnsEnd * 1000.0d);
        int i12 = (int) (ajaxPerformanceTimingEvent.connectStart * 1000.0d);
        int i13 = (int) (ajaxPerformanceTimingEvent.ssl * 1000.0d);
        int i14 = (int) (ajaxPerformanceTimingEvent.connectEnd * 1000.0d);
        int i15 = (int) (ajaxPerformanceTimingEvent.firstByteEndTime * 1000.0d);
        int i16 = (int) (ajaxPerformanceTimingEvent.startTime * 1000.0d);
        int i17 = (int) (ajaxPerformanceTimingEvent.callbackTime * 1000.0d);
        int i18 = (int) (ajaxPerformanceTimingEvent.endTime * 1000.0d);
        long abs = Math.abs(j9);
        long j10 = ((abs - i17) - i18) + i16;
        f3941a.c("ajaxFinishTime=%d,absFinishTime=%d,callbackTime=%d,endTime=%d,startTime=%d,startTimeUs=%d", Long.valueOf(j9), Long.valueOf(abs), Integer.valueOf(i17), Integer.valueOf(i18), Integer.valueOf(i16), Long.valueOf(j10));
        if (j10 < 0) {
            j10 = 1000 * abs;
        }
        if (j9 < 0) {
            j10 = -j10;
        }
        networkEventInfoBean.startTime = j10;
        networkEventInfoBean.mDnsTimeUs = Math.abs(i11 - i10);
        double d9 = ajaxPerformanceTimingEvent.ssl;
        if (d9 > 0.0d) {
            networkEventInfoBean.mConnectTimeUs = Math.abs(i13 - i12);
        } else if (d9 == 0.0d) {
            networkEventInfoBean.mConnectTimeUs = Math.abs(i14 - i12);
        }
        if (ajaxPerformanceTimingEvent.ssl > 0.0d && str2.startsWith("https://")) {
            networkEventInfoBean.mSslTimeUs = Math.abs(i14 - i13);
        }
        if (i14 > 0) {
            i11 = i14;
        } else if (i11 <= 0) {
            i11 = i16 > 0 ? i16 : i15;
        }
        int i19 = i15 - i11;
        int i20 = i18 - i15;
        networkEventInfoBean.mRequestTimeUs = 999;
        if (i19 <= 0) {
            i19 = 999;
        }
        networkEventInfoBean.mResponseTimeUs = i19;
        if (i20 > 0) {
            networkEventInfoBean.mDownloadTimeUs = Math.max(i20, 999);
        } else {
            networkEventInfoBean.mDownloadTimeUs = 0;
        }
        networkEventInfoBean.mdownloadSizeByte = ajaxPerformanceTimingEvent.responseLength;
        if (networkEventInfoBean.mRequestUrl.startsWith("file://") && ajaxPerformanceTimingEvent.statusCode == 602) {
            networkEventInfoBean.mErrorCode = 200;
        } else {
            networkEventInfoBean.mErrorCode = Integer.valueOf(ajaxPerformanceTimingEvent.statusCode);
            if (ajaxPerformanceTimingEvent.statusCode != 200) {
                networkEventInfoBean.mErrorOccurrentProcess = 4;
                if (!TextUtils.isEmpty(ajaxPerformanceTimingEvent.errorPlatform)) {
                    networkEventInfoBean.mErrorPlatform = ajaxPerformanceTimingEvent.errorPlatform;
                }
                if (!TextUtils.isEmpty(ajaxPerformanceTimingEvent.errorMessage)) {
                    networkEventInfoBean.mErrorMsg = ajaxPerformanceTimingEvent.errorMessage;
                }
            }
        }
        String d10 = x.d(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(d10)) {
            networkEventInfoBean.mTraceId = d10;
        }
        String e9 = x.e(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(e9)) {
            networkEventInfoBean.xBrResponse = e9;
        }
        String f9 = x.f(ajaxPerformanceTimingEvent.responseHeader);
        if (!TextUtils.isEmpty(f9)) {
            networkEventInfoBean.traceResponse = f9;
        }
        a(i9, networkEventInfoBean.mErrorCode.intValue(), networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, ajaxPerformanceTimingEvent.responseHeader);
        int a9 = h.a(str2, ajaxPerformanceTimingEvent.nextHopProtocol);
        networkEventInfoBean.mProtocolType = a9;
        if (a9 == 3 && networkEventInfoBean.mRequestUrl.startsWith("http://")) {
            String str3 = "https://" + networkEventInfoBean.mRequestUrl.substring(7);
            networkEventInfoBean.mRequestUrl = str3;
            ajaxPerformanceTimingEvent.ajaxUrl = str3;
        }
        String a10 = a.a(ajaxPerformanceTimingEvent.ajaxUrl);
        if (af.b(a10)) {
            a10 = a.a(str2);
        }
        if (!TextUtils.isEmpty(a10)) {
            networkEventInfoBean.mResourceType = a10;
        }
        networkEventInfoBean.mMethod = ajaxPerformanceTimingEvent.method;
        networkEventInfoBean.mAppRequestType = 3;
        networkEventInfoBean.mPageId = ajaxPerformanceTimingEvent.pvid;
        networkEventInfoBean.isCustom = false;
        networkEventInfoBean.mRequestDataSize = a(ajaxPerformanceTimingEvent.requestHeader);
        a(networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, list);
        b(networkEventInfoBean, ajaxPerformanceTimingEvent.responseHeader, list4);
        c(networkEventInfoBean, ajaxPerformanceTimingEvent.requestHeader, list3);
        networkEventInfoBean.mCustomBusinessBody = a(ajaxPerformanceTimingEvent.requestBody, list2);
        return networkEventInfoBean;
    }

    private static long a(String str) {
        String substring;
        if (TextUtils.isEmpty(str)) {
            return 0L;
        }
        String str2 = null;
        try {
            if (str.contains("Content-Length:")) {
                String substring2 = str.substring(str.indexOf("Content-Length:"));
                if (substring2.contains("\n")) {
                    substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1, substring2.indexOf("\n"));
                } else {
                    substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1);
                }
                if (substring.startsWith(HanziToPinyin.Token.SEPARATOR)) {
                    substring = substring.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                }
                if (substring.contains("\r")) {
                    substring = substring.replaceAll("\r", "");
                }
                str2 = substring;
            }
            if (TextUtils.isEmpty(str2)) {
                return 0L;
            }
            return Long.parseLong(str2);
        } catch (Throwable unused) {
            return 0L;
        }
    }

    public static NetworkEventInfoBean a(NetworkEventInfoBean networkEventInfoBean, NetworkEventInfoBean networkEventInfoBean2) {
        networkEventInfoBean.mErrorCode = networkEventInfoBean2.mErrorCode;
        int i9 = networkEventInfoBean.mdownloadSizeByte;
        if (i9 == 0) {
            i9 = networkEventInfoBean2.mdownloadSizeByte;
        }
        networkEventInfoBean.mdownloadSizeByte = i9;
        if (!TextUtils.isEmpty(networkEventInfoBean2.mRequestHeader)) {
            networkEventInfoBean.mRequestHeader = af.b(networkEventInfoBean.mRequestHeader) ? networkEventInfoBean2.mRequestHeader : networkEventInfoBean.mRequestHeader;
        }
        if (!TextUtils.isEmpty(networkEventInfoBean2.mResponseHeader)) {
            networkEventInfoBean.mResponseHeader = af.b(networkEventInfoBean.mResponseHeader) ? networkEventInfoBean2.mResponseHeader : networkEventInfoBean.mResponseHeader;
        }
        networkEventInfoBean.mErrorMsg = networkEventInfoBean2.mErrorMsg;
        networkEventInfoBean.mErrorOccurrentProcess = networkEventInfoBean2.mErrorOccurrentProcess;
        return networkEventInfoBean;
    }

    private static boolean a(com.bonree.sdk.o.b bVar) {
        if (bVar.u() != null) {
            return bVar.u().equals("ws_send") || bVar.u().equals("wss_send");
        }
        return false;
    }

    public static void a(NetworkEventInfoBean networkEventInfoBean, com.bonree.sdk.o.b bVar, boolean z8, String[] strArr) {
        Map<String, String> O;
        if (z8) {
            try {
                if (networkEventInfoBean.mErrorCode.intValue() >= 200 && networkEventInfoBean.mErrorCode.intValue() < 400 && (O = bVar.O()) != null && !O.isEmpty()) {
                    HashMap hashMap = new HashMap();
                    String str = null;
                    for (String str2 : O.keySet()) {
                        if (str2 != null) {
                            if (str2.toLowerCase().equals(strArr[0].toLowerCase())) {
                                str = af.a((Object) O.get(str2));
                                if (Integer.parseInt(str) == 1000) {
                                    return;
                                }
                                hashMap.put(str2, str);
                            }
                            if (str2.toLowerCase().equals(strArr[1].toLowerCase())) {
                                hashMap.put(str2, af.a((Object) O.get(str2)));
                            }
                            if (str2.toLowerCase().equals(strArr[2].toLowerCase())) {
                                hashMap.put(str2, af.a((Object) O.get(str2)));
                            }
                            if (str2.toLowerCase().equals(strArr[3].toLowerCase())) {
                                hashMap.put(str2, af.a((Object) O.get(str2)));
                            }
                        }
                    }
                    if (hashMap.isEmpty() || str == null) {
                        return;
                    }
                    networkEventInfoBean.mErrorCode = 0;
                    networkEventInfoBean.mErrorMsg = str + Constants.COLON_SEPARATOR + af.b((Map<String, String>) hashMap);
                    networkEventInfoBean.mErrorPlatform = "mpaas";
                    networkEventInfoBean.mErrorOccurrentProcess = 4;
                }
            } catch (Throwable th) {
                f3941a.a(th.toString(), new Object[0]);
            }
        }
    }

    public static synchronized void a(NetworkEventInfoBean networkEventInfoBean, String str, List<String> list) {
        String substring;
        synchronized (g.class) {
            if (list != null) {
                try {
                    if (!list.isEmpty()) {
                        if (TextUtils.isEmpty(str)) {
                            return;
                        }
                        String replaceAll = str.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                        StringBuilder sb = new StringBuilder();
                        String lowerCase = replaceAll.toLowerCase();
                        for (String str2 : list) {
                            if (!TextUtils.isEmpty(str2)) {
                                String replaceAll2 = str2.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                                String lowerCase2 = replaceAll2.toLowerCase();
                                if (lowerCase.contains(lowerCase2 + Constants.COLON_SEPARATOR)) {
                                    int indexOf = lowerCase.indexOf(lowerCase2) - 1;
                                    if (indexOf != -1) {
                                        String valueOf = String.valueOf(lowerCase.charAt(indexOf));
                                        if (!valueOf.equals(Constants.COLON_SEPARATOR) && !valueOf.equals("\n") && !valueOf.equals("\r")) {
                                        }
                                    }
                                    String substring2 = replaceAll.substring(lowerCase.indexOf(lowerCase2 + Constants.COLON_SEPARATOR));
                                    if (substring2.contains("\n")) {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1, substring2.indexOf("\n"));
                                    } else {
                                        substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1);
                                    }
                                    if (substring.startsWith(HanziToPinyin.Token.SEPARATOR)) {
                                        substring = substring.replaceFirst(HanziToPinyin.Token.SEPARATOR, "");
                                    }
                                    String p9 = af.p(substring.replace("\r", "").replace("\n", ""));
                                    if (sb.length() > 0) {
                                        sb.append("&");
                                    }
                                    sb.append(replaceAll2);
                                    sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                                    sb.append(p9);
                                }
                            }
                        }
                        if (sb.length() > 0) {
                            networkEventInfoBean.mCustomBusinessHeader = sb.toString();
                        }
                    }
                } catch (Throwable th) {
                    f3941a.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
                }
            }
        }
    }

    public static String a(Map<String, String> map, List<String> list) {
        if (list != null && !list.isEmpty() && map != null && map.size() > 0) {
            HashMap hashMap = new HashMap();
            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (entry != null) {
                    hashMap.put(entry.getKey().toLowerCase(), entry.getValue());
                }
            }
            StringBuilder sb = new StringBuilder();
            try {
                synchronized (list) {
                    for (String str : list) {
                        if (!TextUtils.isEmpty(str)) {
                            String p9 = af.p((String) hashMap.get(str.toLowerCase()));
                            if (!TextUtils.isEmpty(p9)) {
                                if (sb.length() > 0) {
                                    sb.append("&");
                                }
                                sb.append(str);
                                sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                                sb.append(p9);
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                f fVar = f3941a;
                fVar.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
            }
            if (sb.length() > 0) {
                return sb.toString();
            }
        }
        return null;
    }

    public static synchronized String a(Object obj, List<String> list) {
        String sb;
        Object obj2;
        JSONObject jSONObject;
        boolean z8;
        String[] split;
        synchronized (g.class) {
            String str = "";
            if (obj != null) {
                try {
                    if (obj instanceof Map) {
                        Map map = (Map) obj;
                        if (map.size() <= 0) {
                            sb = null;
                        } else {
                            StringBuilder sb2 = new StringBuilder();
                            for (Object obj3 : map.keySet()) {
                                if (obj3 != null && (obj2 = map.get(obj3)) != null) {
                                    if (sb2.length() > 0) {
                                        sb2.append("&");
                                    }
                                    sb2.append(obj3.toString());
                                    sb2.append(ContainerUtils.KEY_VALUE_DELIMITER);
                                    sb2.append(obj2.toString());
                                }
                            }
                            sb = sb2.toString();
                        }
                        if (TextUtils.isEmpty(sb)) {
                            return null;
                        }
                        return sb;
                    }
                    str = obj.toString();
                } catch (Throwable th) {
                    f3941a.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
                }
            }
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            try {
                jSONObject = new JSONObject(str);
                z8 = true;
            } catch (JSONException unused) {
                jSONObject = null;
                z8 = false;
            }
            if (list != null && !list.isEmpty()) {
                StringBuilder sb3 = new StringBuilder();
                if (z8) {
                    for (String str2 : list) {
                        if (!TextUtils.isEmpty(str2) && jSONObject.has(str2)) {
                            if (sb3.length() > 0) {
                                sb3.append("&");
                            }
                            sb3.append(str2);
                            sb3.append(ContainerUtils.KEY_VALUE_DELIMITER);
                            sb3.append(af.p(jSONObject.get(str2).toString()));
                        }
                    }
                } else {
                    for (String str3 : str.split("&")) {
                        int indexOf = str3.indexOf(ContainerUtils.KEY_VALUE_DELIMITER);
                        if (indexOf > 0 && indexOf < str3.length() - 1 && list.contains(str3.substring(0, indexOf))) {
                            if (sb3.length() > 0) {
                                sb3.append("&");
                            }
                            sb3.append(str3);
                        }
                    }
                }
                if (sb3.length() > 0) {
                    return sb3.toString();
                }
                return null;
            }
            return null;
        }
    }

    private static String a(Map<?, ?> map) {
        Object obj;
        if (map == null || map.size() <= 0) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        for (Object obj2 : map.keySet()) {
            if (obj2 != null && (obj = map.get(obj2)) != null) {
                if (sb.length() > 0) {
                    sb.append("&");
                }
                sb.append(obj2.toString());
                sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                sb.append(obj.toString());
            }
        }
        return sb.toString();
    }

    public static String a(String str, List<String> list) {
        String[] split;
        if (!TextUtils.isEmpty(str) && str.contains("?") && list != null && !list.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            HashMap hashMap = new HashMap();
            boolean z8 = false;
            try {
                synchronized (list) {
                    for (String str2 : str.substring(str.indexOf("?") + 1).split("&")) {
                        if (str2.contains(ContainerUtils.KEY_VALUE_DELIMITER)) {
                            String[] split2 = str2.split(ContainerUtils.KEY_VALUE_DELIMITER);
                            if (split2.length == 2 && list.contains(split2[0])) {
                                hashMap.put(split2[0], af.p(split2[1]));
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                f3941a.e("parse CustomBusiness fail:" + th.toString(), new Object[0]);
            }
            for (Map.Entry entry : hashMap.entrySet()) {
                if (z8) {
                    sb.append("&");
                }
                sb.append((String) entry.getKey());
                sb.append(ContainerUtils.KEY_VALUE_DELIMITER);
                sb.append(af.p((String) entry.getValue()));
                z8 = true;
            }
            if (sb.length() > 0) {
                return sb.toString();
            }
        }
        return null;
    }

    public static void a(com.bonree.sdk.o.b bVar, NetworkEventInfoBean networkEventInfoBean) {
        if (bVar.P()) {
            networkEventInfoBean.mDnsTimeUs = 0;
            networkEventInfoBean.mConnectTimeUs = 0;
            networkEventInfoBean.mSslTimeUs = 0;
            networkEventInfoBean.mRequestTimeUs = 999;
            networkEventInfoBean.mDownloadTimeUs = 999;
            networkEventInfoBean.mResponseTimeUs = 999;
            networkEventInfoBean.mdownloadSizeByte = 0;
        }
    }

    public static void a(com.bonree.sdk.o.a aVar, NetworkEventInfoBean networkEventInfoBean) {
        if (aVar.s()) {
            networkEventInfoBean.mDnsTimeUs = 0;
            networkEventInfoBean.mConnectTimeUs = 0;
            networkEventInfoBean.mSslTimeUs = 0;
            networkEventInfoBean.mRequestTimeUs = 999;
            networkEventInfoBean.mDownloadTimeUs = 999;
            networkEventInfoBean.mResponseTimeUs = 999;
            networkEventInfoBean.mdownloadSizeByte = 0;
        }
    }

    public static boolean a(com.bonree.sdk.ah.f fVar, List<EventBean> list, int i9) {
        if (fVar == null || af.b(fVar.f3450a)) {
            return false;
        }
        String o9 = af.o(fVar.f3450a);
        fVar.f3450a = o9;
        if (af.d(o9) && o9.endsWith("/")) {
            o9 = o9.substring(0, o9.length() - 1);
        }
        Iterator<EventBean> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            NetworkEventInfoBean networkEventInfoBean = (NetworkEventInfoBean) it.next().mEventInfo;
            if (!o9.equals(networkEventInfoBean.mRequestUrl) && o9.startsWith(networkEventInfoBean.mRequestUrl) && o9.substring(networkEventInfoBean.mRequestUrl.length()).startsWith("#")) {
                o9 = networkEventInfoBean.mRequestUrl;
            }
            String str = networkEventInfoBean.mRequestUrl;
            if (af.d(str) && str.endsWith("/")) {
                str = str.substring(0, str.length() - 1);
            }
            if (networkEventInfoBean.mAppRequestType != 10 && networkEventInfoBean.mErrorCode.intValue() != 200 && o9.equals(str)) {
                int i10 = fVar.f3451b;
                if (200 < i10 && i10 < 600) {
                    Integer valueOf = Integer.valueOf(i10);
                    networkEventInfoBean.mErrorCode = valueOf;
                    int i11 = networkEventInfoBean.mdownloadSizeByte;
                    if (i11 == 0) {
                        i11 = fVar.f3454e;
                    }
                    networkEventInfoBean.mdownloadSizeByte = i11;
                    a(i9, valueOf.intValue(), networkEventInfoBean, af.b(networkEventInfoBean.mRequestHeader) ? fVar.f3452c : networkEventInfoBean.mRequestHeader, af.b(networkEventInfoBean.mResponseHeader) ? fVar.f3453d : networkEventInfoBean.mResponseHeader);
                    networkEventInfoBean.mErrorMsg = fVar.f3456g;
                    networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(fVar.f3457h);
                    networkEventInfoBean.mErrorPlatform = af.b(networkEventInfoBean.mErrorPlatform) ? fVar.f3459j : networkEventInfoBean.mErrorPlatform;
                    f3941a.d("replace correct webview netresult data:%s", networkEventInfoBean);
                    return false;
                }
                it.remove();
                f3941a.d("remove correct webview netresult data:%s", networkEventInfoBean);
            } else if (networkEventInfoBean.mAppRequestType == 1 && networkEventInfoBean.mErrorCode.intValue() != 200 && o9.equals(networkEventInfoBean.mRequestUrl)) {
                if (networkEventInfoBean.mErrorCode.intValue() == 652) {
                    f3941a.d("will replace js NetResult subErrorId!old:%s", networkEventInfoBean);
                    Integer valueOf2 = Integer.valueOf(fVar.f3451b);
                    networkEventInfoBean.mErrorCode = valueOf2;
                    f3941a.d("new js NetResult subErrorId:%d", valueOf2);
                    int i12 = networkEventInfoBean.mdownloadSizeByte;
                    if (i12 == 0) {
                        i12 = fVar.f3454e;
                    }
                    networkEventInfoBean.mdownloadSizeByte = i12;
                    if (!TextUtils.isEmpty(fVar.f3452c)) {
                        networkEventInfoBean.mRequestHeader = af.b(networkEventInfoBean.mRequestHeader) ? fVar.f3452c : networkEventInfoBean.mRequestHeader;
                    }
                    if (!TextUtils.isEmpty(fVar.f3453d)) {
                        networkEventInfoBean.mResponseHeader = af.b(networkEventInfoBean.mResponseHeader) ? fVar.f3453d : networkEventInfoBean.mResponseHeader;
                    }
                    networkEventInfoBean.mErrorMsg = fVar.f3456g;
                    networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(fVar.f3457h);
                    networkEventInfoBean.mErrorPlatform = af.b(networkEventInfoBean.mErrorPlatform) ? fVar.f3459j : networkEventInfoBean.mErrorPlatform;
                    return false;
                } else if (networkEventInfoBean.mErrorCode.intValue() == fVar.f3451b) {
                    int i13 = networkEventInfoBean.mdownloadSizeByte;
                    if (i13 == 0) {
                        i13 = fVar.f3454e;
                    }
                    networkEventInfoBean.mdownloadSizeByte = i13;
                    if (!TextUtils.isEmpty(fVar.f3452c)) {
                        networkEventInfoBean.mRequestHeader = af.b(networkEventInfoBean.mRequestHeader) ? fVar.f3452c : networkEventInfoBean.mRequestHeader;
                    }
                    if (!TextUtils.isEmpty(fVar.f3453d)) {
                        networkEventInfoBean.mResponseHeader = af.b(networkEventInfoBean.mResponseHeader) ? fVar.f3453d : networkEventInfoBean.mResponseHeader;
                    }
                    networkEventInfoBean.mErrorMsg = fVar.f3456g;
                    networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(fVar.f3457h);
                    networkEventInfoBean.mErrorPlatform = af.b(networkEventInfoBean.mErrorPlatform) ? fVar.f3459j : networkEventInfoBean.mErrorPlatform;
                    f3941a.d("no need add webview error NetResult!", new Object[0]);
                    return false;
                }
            }
        }
        return true;
    }

    public static NetworkEventInfoBean a(com.bonree.sdk.ah.f fVar, List<String> list, List<String> list2, List<String> list3, int i9) {
        if (fVar == null) {
            return null;
        }
        String str = fVar.f3450a;
        if (af.b(str)) {
            return null;
        }
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mRequestUrl = str;
        networkEventInfoBean.startTime = com.bonree.sdk.c.a.g();
        String l9 = af.l(str);
        if (!af.b(l9)) {
            String[] b9 = h.b(str, l9);
            if (!TextUtils.isEmpty(b9[0])) {
                networkEventInfoBean.mTargetIp = b9[0];
            }
            if (!TextUtils.isEmpty(networkEventInfoBean.mTargetIp) && l9.contains(networkEventInfoBean.mTargetIp) && fVar.f3451b == -2) {
                return null;
            }
            networkEventInfoBean.mTargetPort = Integer.parseInt(b9[1]);
        }
        if (!af.b(fVar.f3452c)) {
            a(networkEventInfoBean, fVar.f3452c, list);
        }
        if (!af.b(fVar.f3453d)) {
            b(networkEventInfoBean, fVar.f3453d, list3);
            networkEventInfoBean.mdownloadSizeByte = fVar.f3454e;
        }
        if (!af.b(fVar.f3452c)) {
            c(networkEventInfoBean, fVar.f3452c, list2);
            networkEventInfoBean.mdownloadSizeByte = fVar.f3454e;
        }
        String d9 = x.d(fVar.f3453d);
        if (!TextUtils.isEmpty(d9)) {
            networkEventInfoBean.mTraceId = d9;
        }
        String e9 = x.e(fVar.f3453d);
        if (!TextUtils.isEmpty(e9)) {
            networkEventInfoBean.xBrResponse = e9;
        }
        String f9 = x.f(fVar.f3453d);
        if (!TextUtils.isEmpty(f9)) {
            networkEventInfoBean.traceResponse = f9;
        }
        a(i9, fVar.f3451b, networkEventInfoBean, fVar.f3452c, fVar.f3453d);
        Integer valueOf = Integer.valueOf(fVar.f3451b);
        networkEventInfoBean.mErrorCode = valueOf;
        if (valueOf.intValue() >= 600 || networkEventInfoBean.mErrorCode.intValue() < 400) {
            networkEventInfoBean.mErrorMsg = fVar.f3456g;
        }
        networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(fVar.f3457h);
        networkEventInfoBean.mErrorPlatform = fVar.f3459j;
        if (!af.b(fVar.f3455f)) {
            networkEventInfoBean.mResourceType = fVar.f3455f;
        } else {
            String a9 = a.a(str);
            if (!TextUtils.isEmpty(a9)) {
                networkEventInfoBean.mResourceType = a9;
            }
        }
        if (str.startsWith("http://") || str.startsWith("https://")) {
            networkEventInfoBean.mMethod = "GET";
        }
        networkEventInfoBean.mProtocolType = h.c(str);
        if (!TextUtils.isEmpty(fVar.f3458i) && networkEventInfoBean.mRequestUrl.equals(fVar.f3458i)) {
            networkEventInfoBean.mAppRequestType = 1;
        }
        return networkEventInfoBean;
    }

    public static NetworkEventInfoBean a(com.bonree.sdk.o.a aVar, int i9) {
        if (aVar == null || aVar.b() == null) {
            return null;
        }
        NetworkEventInfoBean networkEventInfoBean = new NetworkEventInfoBean();
        networkEventInfoBean.mIdentifier = aVar.X();
        networkEventInfoBean.startTime = aVar.d();
        networkEventInfoBean.mRequestUrl = aVar.b();
        networkEventInfoBean.mDnsTimeUs = aVar.e() * 1000;
        networkEventInfoBean.mConnectTimeUs = aVar.f() * 1000;
        networkEventInfoBean.mSslTimeUs = aVar.g() * 1000;
        networkEventInfoBean.mRequestTimeUs = aVar.h() * 1000;
        networkEventInfoBean.mResponseTimeUs = aVar.i() * 1000;
        networkEventInfoBean.mDownloadTimeUs = aVar.j() * 1000;
        networkEventInfoBean.mdownloadSizeByte = (int) aVar.k();
        networkEventInfoBean.mProtocolType = h.a(aVar.b(), aVar.l());
        if (aVar.c() != null) {
            networkEventInfoBean.mMethod = aVar.c();
        }
        if (aVar.r() != null) {
            networkEventInfoBean.mResourceType = aVar.r();
        }
        a(i9, aVar.a(), networkEventInfoBean, aVar.m(), aVar.p());
        networkEventInfoBean.mErrorCode = Integer.valueOf(aVar.a());
        if (aVar.q() != null || (400 <= aVar.a() && aVar.a() <= 600)) {
            String q9 = aVar.q();
            networkEventInfoBean.mErrorMsg = q9;
            int i10 = 3;
            if (!TextUtils.isEmpty(q9)) {
                if (q9.contains("ERR_CERT_AUTHORITY_INVALID") || q9.contains("ERR_SSL_PROTOCOL_ERROR") || q9.contains("ERR_SSL_OBSOLETE_VERSION")) {
                    i10 = 1;
                } else if (q9.contains("ERR_NAME_NOT_RESOLVED")) {
                    i10 = 2;
                } else if (!q9.contains("ERR_CONNECTION_TIMED_OUT")) {
                }
                aVar.f6363a = i10;
                networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(i10);
                a(networkEventInfoBean);
                if (aVar.f6363a == 2) {
                    networkEventInfoBean.mErrorCode = 659;
                }
            }
            i10 = 4;
            aVar.f6363a = i10;
            networkEventInfoBean.mErrorOccurrentProcess = Integer.valueOf(i10);
            a(networkEventInfoBean);
            if (aVar.f6363a == 2) {
            }
        }
        networkEventInfoBean.mAppRequestType = 10;
        networkEventInfoBean.isCustom = false;
        return networkEventInfoBean;
    }

    public static void a(NetworkEventInfoBean networkEventInfoBean, Map<String, String> map, c cVar) {
        NetworkRequestExtraBean a9;
        if (cVar == null || cVar.c() == 0 || map == null || map.size() <= 0) {
            return;
        }
        for (String str : cVar.a()) {
            if (!TextUtils.isEmpty(str)) {
                String str2 = map.get(str);
                if (!TextUtils.isEmpty(str2) && (a9 = cVar.a(str, str2)) != null) {
                    networkEventInfoBean.mRequestExtraInfo = a9.getInfo();
                    cVar.b(str, str2);
                    return;
                }
            }
        }
    }

    public static void a(NetworkEventInfoBean networkEventInfoBean, String str, c cVar) {
        String substring;
        if (cVar == null || cVar.c() == 0 || TextUtils.isEmpty(str)) {
            return;
        }
        List<String> a9 = cVar.a();
        try {
            String replaceAll = str.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
            for (String str2 : a9) {
                if (!TextUtils.isEmpty(str2)) {
                    String replaceAll2 = str2.replaceAll(HanziToPinyin.Token.SEPARATOR, "");
                    if (replaceAll.contains(replaceAll2 + Constants.COLON_SEPARATOR)) {
                        String substring2 = replaceAll.substring(replaceAll.indexOf(replaceAll2 + Constants.COLON_SEPARATOR));
                        if (substring2.contains("\n")) {
                            substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1, substring2.indexOf("\n"));
                        } else {
                            substring = substring2.substring(substring2.indexOf(Constants.COLON_SEPARATOR) + 1);
                        }
                        if (substring2.contains("\r")) {
                            substring = substring.substring(0, substring.indexOf("\r"));
                        }
                        if (substring.startsWith(HanziToPinyin.Token.SEPARATOR)) {
                            substring = substring.replaceFirst(HanziToPinyin.Token.SEPARATOR, "");
                        }
                        NetworkRequestExtraBean a10 = cVar.a(replaceAll2, substring);
                        if (a10 != null) {
                            networkEventInfoBean.mRequestExtraInfo = a10.getInfo();
                            cVar.b(replaceAll2, substring);
                            return;
                        }
                    } else {
                        continue;
                    }
                }
            }
        } catch (Throwable th) {
            f fVar = f3941a;
            fVar.e("parse checkRequestExtra fail:" + th.toString(), new Object[0]);
        }
    }
}