TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c

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


package com.tencent.mobileqq.webview.webso;

import android.net.Uri;
import android.os.SystemClock;
import android.text.TextUtils;
import com.tencent.mobileqq.app.ThreadManager;
import com.tencent.qphone.base.util.QLog;
import com.tencent.smtt.utils.SysCoreQUA2Utils;
import common.config.service.QzoneConfig;
import cooperation.qzone.LocalMultiProcConfig;
import cooperation.qzone.QUA;
import cooperation.qzone.util.NetworkState;
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONArray;
import org.json.JSONObject;
public class HybridWebReporter {
    private static HybridWebReporter f35082a = null;
    public static final String f35084a = "urlPrefixConfig";
    public static final String f95149b = "{\"urlPrefixConfig\":[{\"prefix\":\"http://h5.qzone.qq.com\",\"sampling\":20},{\"prefix\":\"https://h5s.qzone.qq.com\",\"sampling\":20}]}";
    public static String f95150c = null;
    private static final String d = "HybridWebReporter";
    private Random f35086a;
    private static ArrayList f35085a = new ArrayList();
    private static long f95148a = SystemClock.uptimeMillis();
    private static final Object f35083a = new Object();

    private HybridWebReporter() {
    }

    public static HybridWebReporter a() {
        if (f35082a == null) {
            synchronized (f35083a) {
                if (f35082a == null) {
                    f35082a = new HybridWebReporter();
                }
            }
        }
        return f35082a;
    }

    private boolean a(int i) {
        if (i <= 0) {
            return false;
        }
        if (this.f35086a == null) {
            this.f35086a = new Random(System.currentTimeMillis());
        }
        return this.f35086a.nextInt() % i == 0;
    }

    public static void m9706a() {
        ArrayList arrayList;
        if (!f35085a.isEmpty()) {
            synchronized (f35085a) {
                arrayList = new ArrayList(f35085a);
                f35085a.clear();
                f95148a = SystemClock.uptimeMillis();
            }
            ThreadManager.d(new vyy(arrayList));
        }
    }

    public static void b() {
        if (TextUtils.isEmpty(f95150c)) {
            f95150c = LocalMultiProcConfig.a(f35084a, f95149b);
        }
    }

    public static int a(String str) {
        if (TextUtils.isEmpty(str)) {
            return 0;
        }
        b();
        if (str.contains("_qzhw_stat=0")) {
            return 0;
        }
        if (str.contains("_qzhw_stat_sampling=")) {
            try {
                return Integer.valueOf(Uri.parse(str).getQueryParameter("_qzhw_stat_sampling")).intValue();
            } catch (Exception e) {
            }
        }
        if (!TextUtils.isEmpty(f95150c)) {
            try {
                Object opt = new JSONObject(f95150c).opt(f35084a);
                if (!(opt instanceof JSONArray)) {
                    return -1;
                }
                JSONArray jSONArray = (JSONArray) opt;
                int length = jSONArray.length();
                for (int i = 0; i < length; i++) {
                    JSONObject jSONObject = (JSONObject) jSONArray.get(i);
                    if (str.startsWith(jSONObject.optString("prefix"))) {
                        return jSONObject.optInt("sampling", -1);
                    }
                }
            } catch (Exception e2) {
                return -1;
            }
        }
        return -1;
    }

    public void a(HybridWebReportInfo hybridWebReportInfo) {
        int i;
        if (hybridWebReportInfo != null) {
            long uptimeMillis = SystemClock.uptimeMillis() - f95148a;
            int config = QzoneConfig.getInstance().getConfig("QzUrlCache", QzoneConfig.SECONDARY_WEBSO_REPORT_BATCH_INTERVAL, 600) * 1000;
            int config2 = QzoneConfig.getInstance().getConfig("QzUrlCache", QzoneConfig.SECONDARY_WEBSO_REPORT_BATCH_COUNT, 10);
            if (QLog.isColorLevel()) {
                QLog.d(d, 2, "add report, isreported(" + hybridWebReportInfo.f35096d + "), url: " + hybridWebReportInfo.f35088a);
            }
            if (hybridWebReportInfo.e != 0 && !hybridWebReportInfo.f35096d) {
                hybridWebReportInfo.f35096d = true;
                if (hybridWebReportInfo.e < 0) {
                    hybridWebReportInfo.e = QzoneConfig.getInstance().getConfig("QzUrlCache", QzoneConfig.SECONDARY_WEBSO_REPORT_DEFAULT_SAMPLING, 20);
                }
                try {
                    i = Integer.valueOf(hybridWebReportInfo.f35095d).intValue();
                } catch (Exception e) {
                    i = 200;
                }
                if ((hybridWebReportInfo.f95152b != 1000 && hybridWebReportInfo.f95152b != 0) || i < 100 || i > 400) {
                    hybridWebReportInfo.e = 1;
                }
                if (QLog.isColorLevel()) {
                    hybridWebReportInfo.e = 1;
                }
                if (a(hybridWebReportInfo.e)) {
                    synchronized (f35085a) {
                        f35085a.add(hybridWebReportInfo);
                    }
                    if (f35085a.size() >= config2 || (uptimeMillis >= config && f35085a.size() > 0)) {
                        m9706a();
                    }
                }
            }
        }
    }

    public class HybridWebReportInfo {
        private static final int f = 16;
        public int f95151a;
        public long f35087a;
        public String f35088a;
        public boolean f35090a;
        public int f95152b;
        public boolean f35092b;
        public int f95153c;
        public boolean f35094c;
        public int d;
        public boolean f35096d;
        public String f35091b = "";
        public String f35093c = "";
        public String f35095d = "";
        public String f35097e = "";
        public String f35098f = "";
        public String g = "";
        public String h = "";
        public String i = "";
        public String j = NetworkState.m11077b();
        public String k = SysCoreQUA2Utils.PR_QQ;
        public String l = QUA.a();
        public String m = "Android";
        public int e = -1;
        private AtomicInteger f35089a = new AtomicInteger(0);

        public boolean m9707a() {
            if (this.f35089a.incrementAndGet() >= 16) {
                this.f35089a.set(0);
                return true;
            }
            return false;
        }

        public JSONObject a() {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("uin", this.f35087a);
                String str = this.f35088a;
                if (!TextUtils.isEmpty(this.f35088a)) {
                    int indexOf = this.f35088a.indexOf(63);
                    if (indexOf < 0) {
                        indexOf = this.f35088a.length();
                    }
                    str = this.f35088a.substring(0, indexOf);
                }
                jSONObject.put("url", this.f35088a);
                jSONObject.put("path", str);
                jSONObject.put("errordomain", this.f35091b);
                jSONObject.put("errorcode", this.f35093c);
                jSONObject.put("httpstatus", this.f35095d);
                jSONObject.put("userip", this.f35097e);
                jSONObject.put("serverip", this.f35098f);
                jSONObject.put("port", this.g);
                jSONObject.put("dnsresult", this.h);
                jSONObject.put("apn", this.j);
                jSONObject.put("timecost", this.f95151a / 1000.0f);
                jSONObject.put("app", this.k);
                jSONObject.put("appversion", this.l);
                jSONObject.put("platform", this.m);
                jSONObject.put("sampling", this.e);
                jSONObject.put("usewns", this.f35090a);
                int i = this.f95152b;
                jSONObject.put("wnscode", (i == 1000 || i == 0) ? 0 : this.f95152b + 300000);
                jSONObject.put("detail", this.i);
                jSONObject.put("usecache", this.f35092b);
                jSONObject.put("cachehasdata", this.f35094c);
                jSONObject.put("cacheupdatepolicy", this.f95153c);
                jSONObject.put("cacheupdatetimecost", this.d / 1000.0f);
                return jSONObject;
            } catch (Exception e) {
                QLog.e(HybridWebReporter.d, 1, e, new Object[0]);
                return null;
            }
        }
    }
}