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

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


package com.bonree.sdk.agent.engine.network.cronet;

import android.text.TextUtils;
import com.bonree.sdk.bz.x;
import com.bonree.sdk.n.g;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import org.chromium.net.CronetException;
import org.chromium.net.RequestFinishedInfo;
import org.chromium.net.UrlRequest;
import org.chromium.net.UrlResponseInfo;
public class b {
    private int f3267a;
    private long f3268b;
    private long f3269c;

    public b() {
    }

    public static void a(RequestFinishedInfo requestFinishedInfo, com.bonree.sdk.o.a aVar) {
        CronetException exception;
        if (requestFinishedInfo == null || requestFinishedInfo.getUrl() == null || !g.a().b()) {
            return;
        }
        if (requestFinishedInfo.getResponseInfo() != null) {
            UrlResponseInfo responseInfo = requestFinishedInfo.getResponseInfo();
            RequestFinishedInfo.Metrics metrics = requestFinishedInfo.getMetrics();
            if (responseInfo == null || metrics == null || aVar == null) {
                return;
            }
            if (responseInfo.getNegotiatedProtocol() != null && !responseInfo.getNegotiatedProtocol().equals("unknown")) {
                aVar.c(responseInfo.getNegotiatedProtocol());
            }
            if (!TextUtils.isEmpty(responseInfo.getUrl())) {
                aVar.a(responseInfo.getUrl());
            }
            aVar.a(responseInfo.getHttpStatusCode());
            aVar.b((int) a(metrics.getDnsEnd(), metrics.getDnsStart()));
            aVar.c((int) a(metrics.getConnectEnd(), metrics.getConnectStart()));
            aVar.d((int) a(metrics.getSslEnd(), metrics.getSslStart()));
            aVar.e((int) a(metrics.getSendingEnd(), metrics.getSendingStart()));
            aVar.f((int) a(metrics.getResponseStart(), metrics.getSendingEnd()));
            aVar.g((int) a(metrics.getRequestEnd(), metrics.getResponseStart()));
            Long sentByteCount = metrics.getSentByteCount();
            if (sentByteCount != null) {
                aVar.a(sentByteCount.longValue());
            }
            Long receivedByteCount = metrics.getReceivedByteCount();
            if (receivedByteCount != null) {
                aVar.b(receivedByteCount.longValue());
            }
            String a9 = com.bonree.sdk.ax.a.a(aVar.b());
            if (!TextUtils.isEmpty(a9)) {
                aVar.g(a9);
            }
            if (responseInfo.getAllHeaders() != null) {
                aVar.e(responseInfo.getAllHeaders().toString());
                aVar.b(x.d(responseInfo.getAllHeaders()));
            }
            aVar.a(responseInfo.wasCached());
            com.bonree.sdk.bl.a.a().c("cronetData data:%s", aVar);
            g.a().notifyService(aVar);
        } else if (requestFinishedInfo.getException() == null || (exception = requestFinishedInfo.getException()) == null || aVar == null) {
        } else {
            try {
                Method declaredMethod = exception.getClass().getDeclaredMethod("getErrorCode", new Class[0]);
                if (declaredMethod != null) {
                    int intValue = ((Integer) declaredMethod.invoke(exception, new Object[0])).intValue();
                    aVar.a(intValue);
                    if (intValue != 1) {
                        switch (intValue) {
                            case 4:
                            case 5:
                            case 6:
                            case 7:
                            case 8:
                                aVar.f6363a = 3;
                                break;
                        }
                    }
                    aVar.f6363a = 2;
                }
            } catch (Exception e9) {
                com.bonree.sdk.bl.a.a().a("cronetData assmbleExceptionData:%s", e9);
            }
            aVar.f(exception.getLocalizedMessage());
            com.bonree.sdk.bl.a.a().c("cronetData data:%s", aVar);
            g.a().notifyService(aVar);
        }
    }

    public long b() {
        return this.f3268b;
    }

    public long c() {
        return this.f3269c;
    }

    public String toString() {
        return "SocketSendPacketData{sendByte=" + this.f3267a + ", sendStartTimeMs=" + this.f3268b + ", sendEndTimeMs=" + this.f3269c + '}';
    }

    public b(int i9, long j9, long j10) {
        this.f3267a = i9;
        this.f3268b = j9;
        this.f3269c = j10;
    }

    public static void a(UrlRequest urlRequest, com.bonree.sdk.o.a aVar) {
        try {
            try {
                a(urlRequest, aVar, "mInitialMethod", "mRequestHeaders");
            } catch (Throwable unused) {
                a(urlRequest, aVar, "q", "r");
            }
        } catch (Throwable unused2) {
        }
    }

    private static void a(UrlRequest urlRequest, com.bonree.sdk.o.a aVar, String str, String str2) throws Exception {
        Class<?> cls = urlRequest.getClass();
        Field declaredField = cls.getDeclaredField(str);
        declaredField.setAccessible(true);
        String str3 = (String) declaredField.get(urlRequest);
        if (str3 != null) {
            aVar.b(str3);
        } else {
            aVar.b("GET");
        }
        Field declaredField2 = cls.getDeclaredField(str2);
        declaredField2.setAccessible(true);
        Object obj = declaredField2.get(urlRequest);
        if (obj != null) {
            Map<String, String> linkedHashMap = new LinkedHashMap<>();
            if (obj instanceof ArrayList) {
                for (int i9 = 0; i9 < ((ArrayList) obj).size(); i9++) {
                    try {
                        Object obj2 = ((ArrayList) obj).get(i9);
                        if (obj2 instanceof Map.Entry) {
                            Map.Entry entry = (Map.Entry) obj2;
                            linkedHashMap.put(entry.getKey(), entry.getValue());
                        }
                    } catch (Throwable unused) {
                    }
                }
                aVar.a(linkedHashMap);
            }
            String replace = obj.toString().replace("]", "").replace("[", "");
            if (replace.toString().length() > 0) {
                aVar.d(replace.toString());
            }
        }
    }

    private static void a(UrlResponseInfo urlResponseInfo, RequestFinishedInfo.Metrics metrics, com.bonree.sdk.o.a aVar) {
        if (urlResponseInfo == null || metrics == null || aVar == null) {
            return;
        }
        if (urlResponseInfo.getNegotiatedProtocol() != null && !urlResponseInfo.getNegotiatedProtocol().equals("unknown")) {
            aVar.c(urlResponseInfo.getNegotiatedProtocol());
        }
        if (!TextUtils.isEmpty(urlResponseInfo.getUrl())) {
            aVar.a(urlResponseInfo.getUrl());
        }
        aVar.a(urlResponseInfo.getHttpStatusCode());
        aVar.b((int) a(metrics.getDnsEnd(), metrics.getDnsStart()));
        aVar.c((int) a(metrics.getConnectEnd(), metrics.getConnectStart()));
        aVar.d((int) a(metrics.getSslEnd(), metrics.getSslStart()));
        aVar.e((int) a(metrics.getSendingEnd(), metrics.getSendingStart()));
        aVar.f((int) a(metrics.getResponseStart(), metrics.getSendingEnd()));
        aVar.g((int) a(metrics.getRequestEnd(), metrics.getResponseStart()));
        Long sentByteCount = metrics.getSentByteCount();
        if (sentByteCount != null) {
            aVar.a(sentByteCount.longValue());
        }
        Long receivedByteCount = metrics.getReceivedByteCount();
        if (receivedByteCount != null) {
            aVar.b(receivedByteCount.longValue());
        }
        String a9 = com.bonree.sdk.ax.a.a(aVar.b());
        if (!TextUtils.isEmpty(a9)) {
            aVar.g(a9);
        }
        if (urlResponseInfo.getAllHeaders() != null) {
            aVar.e(urlResponseInfo.getAllHeaders().toString());
            aVar.b(x.d(urlResponseInfo.getAllHeaders()));
        }
        aVar.a(urlResponseInfo.wasCached());
        com.bonree.sdk.bl.a.a().c("cronetData data:%s", aVar);
        g.a().notifyService(aVar);
    }

    private static long a(Date date, Date date2) {
        if (date2 == null || date == null) {
            return 0L;
        }
        long time = date.getTime() - date2.getTime();
        if (time < 0) {
            return 0L;
        }
        return time;
    }

    private static void a(CronetException cronetException, com.bonree.sdk.o.a aVar) {
        if (cronetException == null || aVar == null) {
            return;
        }
        try {
            Method declaredMethod = cronetException.getClass().getDeclaredMethod("getErrorCode", new Class[0]);
            if (declaredMethod != null) {
                int intValue = ((Integer) declaredMethod.invoke(cronetException, new Object[0])).intValue();
                aVar.a(intValue);
                a(intValue, aVar);
            }
        } catch (Exception e9) {
            com.bonree.sdk.bl.a.a().a("cronetData assmbleExceptionData:%s", e9);
        }
        aVar.f(cronetException.getLocalizedMessage());
        com.bonree.sdk.bl.a.a().c("cronetData data:%s", aVar);
        g.a().notifyService(aVar);
    }

    private static void a(int i9, com.bonree.sdk.o.a aVar) {
        if (i9 != 1) {
            switch (i9) {
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                    aVar.f6363a = 3;
                    return;
                case 9:
                    break;
                default:
                    return;
            }
        }
        aVar.f6363a = 2;
    }

    public int a() {
        return this.f3267a;
    }
}