米游社.apk(点击下载) / d.java


package com.mihoyo.hyperion.video.upload.sdk.impl;

import android.content.Context;
import android.os.Build;
import com.mihoyo.commlib.utils.LogUtils;
import com.mihoyo.hotfix.runtime.patch.RuntimeDirector;
import ek.h;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import sy.c0;
import sy.d0;
import sy.e;
import sy.e0;
import sy.f;
import sy.x;

/* compiled from: UGCReport */
public class d {

    /* renamed from: f  reason: collision with root package name */
    public static final String f37376f = "TVC-UGCReport";

    /* renamed from: g  reason: collision with root package name */
    public static final int f37377g = 100;

    /* renamed from: h  reason: collision with root package name */
    public static d f37378h;
    public static RuntimeDirector m__m;

    /* renamed from: a  reason: collision with root package name */
    public Context f37379a;

    /* renamed from: b  reason: collision with root package name */
    public OkHttpClient f37380b;

    /* renamed from: c  reason: collision with root package name */
    public List<c> f37381c = new ArrayList();

    /* renamed from: d  reason: collision with root package name */
    public TimerTask f37382d = null;

    /* renamed from: e  reason: collision with root package name */
    public Timer f37383e;

    /* compiled from: UGCReport */
    public class a extends TimerTask {
        public static RuntimeDirector m__m;

        public a() {
        }

        public void run() {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                d.this.f();
            } else {
                runtimeDirector.invocationDispatch(0, this, ga.a.f66507a);
            }
        }
    }

    /* compiled from: UGCReport */
    public class b implements f {
        public static RuntimeDirector m__m;

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ c f37385a;

        public b(c cVar) {
            this.f37385a = cVar;
        }

        @Override // sy.f
        public void onFailure(e eVar, IOException iOException) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                this.f37385a.f37409w = false;
                return;
            }
            runtimeDirector.invocationDispatch(0, this, eVar, iOException);
        }

        @Override // sy.f
        public void onResponse(e eVar, e0 e0Var) throws IOException {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector != null && runtimeDirector.isRedirect(1)) {
                runtimeDirector.invocationDispatch(1, this, eVar, e0Var);
            } else if (e0Var == null || !e0Var.k0()) {
                this.f37385a.f37409w = false;
            } else {
                synchronized (d.this.f37381c) {
                    d.this.f37381c.remove(this.f37385a);
                }
            }
        }
    }

    public d(Context context) {
        this.f37379a = context;
        OkHttpClient.a newBuilder = new OkHttpClient().newBuilder();
        TimeUnit timeUnit = TimeUnit.SECONDS;
        this.f37380b = newBuilder.k(10, timeUnit).j0(10, timeUnit).R0(10, timeUnit).f();
        this.f37382d = new a();
        if (this.f37383e == null) {
            Timer timer = new Timer(true);
            this.f37383e = timer;
            timer.schedule(this.f37382d, 0, 10000);
        }
    }

    public static d d(Context context) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
            if (f37378h == null) {
                synchronized (d.class) {
                    if (f37378h == null) {
                        f37378h = new d(context);
                    }
                }
            }
            return f37378h;
        }
        return (d) runtimeDirector.invocationDispatch(0, null, context);
    }

    public void c(c cVar) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(2)) {
            c cVar2 = new c(cVar);
            synchronized (this.f37381c) {
                if (this.f37381c.size() > 100) {
                    this.f37381c.remove(0);
                }
                this.f37381c.add(cVar2);
            }
            f();
            return;
        }
        runtimeDirector.invocationDispatch(2, this, cVar);
    }

    public void e(c cVar) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(3)) {
            LogUtils logUtils = LogUtils.INSTANCE;
            logUtils.i(f37376f, "report: info = " + cVar.toString());
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("version", ek.c.f57732a);
                jSONObject.put("reqType", cVar.f37387a);
                jSONObject.put("errCode", cVar.f37388b);
                jSONObject.put("vodErrCode", cVar.f37389c);
                jSONObject.put("cosErrCode", cVar.f37390d);
                jSONObject.put("errMsg", cVar.f37391e);
                jSONObject.put("reqTimeCost", cVar.f37393g);
                jSONObject.put("reqServerIp", cVar.f37399m);
                jSONObject.put("useHttpDNS", cVar.f37400n);
                jSONObject.put("platform", 2000);
                jSONObject.put("osType", String.valueOf(Build.VERSION.SDK_INT));
                jSONObject.put("netType", h.g(this.f37379a));
                jSONObject.put("reqTime", cVar.f37392f);
                jSONObject.put("reportId", cVar.f37401o);
                jSONObject.put("uuid", h.e(this.f37379a));
                jSONObject.put("reqKey", cVar.f37402p);
                jSONObject.put("appId", cVar.f37398l);
                jSONObject.put("fileSize", cVar.f37394h);
                jSONObject.put("fileType", cVar.f37395i);
                jSONObject.put("fileName", cVar.f37396j);
                jSONObject.put("vodSessionKey", cVar.f37403q);
                jSONObject.put("fileId", cVar.f37397k);
                jSONObject.put(c.f37341j, cVar.f37404r);
                jSONObject.put("useCosAcc", cVar.f37405s);
                jSONObject.put("tcpConnTimeCost", cVar.f37406t);
                jSONObject.put("recvRespTimeCost", cVar.f37407u);
                jSONObject.put("packageName", h.h(this.f37379a));
                jSONObject.put("appName", h.c(this.f37379a));
                jSONObject.put("requestId", cVar.f37410x);
                cVar.f37408v++;
                cVar.f37409w = true;
                String jSONObject2 = jSONObject.toString();
                logUtils.i(f37376f, "reportUGCEvent->request url:" + "https://vodreport.qcloud.com/ugcupload_new" + " body:" + jSONObject2);
                this.f37380b.newCall(new c0.a().B("https://vodreport.qcloud.com/ugcupload_new").r(d0.create(x.j("application/json"), jSONObject2)).b()).G(new b(cVar));
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
        } else {
            runtimeDirector.invocationDispatch(3, this, cVar);
        }
    }

    public final synchronized void f() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(1)) {
            runtimeDirector.invocationDispatch(1, this, ga.a.f66507a);
        } else if (h.n(this.f37379a)) {
            synchronized (this.f37381c) {
                Iterator<c> it2 = this.f37381c.iterator();
                while (it2.hasNext()) {
                    c next = it2.next();
                    if (next.f37408v >= 4) {
                        it2.remove();
                    } else if (!next.f37409w) {
                        e(next);
                    }
                }
            }
        }
    }

    /* compiled from: UGCReport */
    public static class c {
        public static RuntimeDirector m__m;

        /* renamed from: a  reason: collision with root package name */
        public int f37387a = 0;

        /* renamed from: b  reason: collision with root package name */
        public int f37388b = 0;

        /* renamed from: c  reason: collision with root package name */
        public int f37389c = 0;

        /* renamed from: d  reason: collision with root package name */
        public String f37390d = "";

        /* renamed from: e  reason: collision with root package name */
        public String f37391e = "";

        /* renamed from: f  reason: collision with root package name */
        public long f37392f = 0;

        /* renamed from: g  reason: collision with root package name */
        public long f37393g = 0;

        /* renamed from: h  reason: collision with root package name */
        public long f37394h = 0;

        /* renamed from: i  reason: collision with root package name */
        public String f37395i = "";

        /* renamed from: j  reason: collision with root package name */
        public String f37396j = "";

        /* renamed from: k  reason: collision with root package name */
        public String f37397k = "";

        /* renamed from: l  reason: collision with root package name */
        public int f37398l = 0;

        /* renamed from: m  reason: collision with root package name */
        public String f37399m = "";

        /* renamed from: n  reason: collision with root package name */
        public int f37400n = 0;

        /* renamed from: o  reason: collision with root package name */
        public String f37401o = "";

        /* renamed from: p  reason: collision with root package name */
        public String f37402p = "";

        /* renamed from: q  reason: collision with root package name */
        public String f37403q = "";

        /* renamed from: r  reason: collision with root package name */
        public String f37404r = "";

        /* renamed from: s  reason: collision with root package name */
        public int f37405s = 0;

        /* renamed from: t  reason: collision with root package name */
        public long f37406t = 0;

        /* renamed from: u  reason: collision with root package name */
        public long f37407u = 0;

        /* renamed from: v  reason: collision with root package name */
        public int f37408v = 0;

        /* renamed from: w  reason: collision with root package name */
        public boolean f37409w = false;

        /* renamed from: x  reason: collision with root package name */
        public String f37410x = "";

        public c() {
        }

        public String toString() {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector != null && runtimeDirector.isRedirect(0)) {
                return (String) runtimeDirector.invocationDispatch(0, this, ga.a.f66507a);
            }
            return "ReportInfo{reqType=" + this.f37387a + ", errCode=" + this.f37388b + ", vodErrCode=" + this.f37389c + ", cosErrCode='" + this.f37390d + '\'' + ", errMsg='" + this.f37391e + '\'' + ", reqTime=" + this.f37392f + ", reqTimeCost=" + this.f37393g + ", fileSize=" + this.f37394h + ", fileType='" + this.f37395i + '\'' + ", fileName='" + this.f37396j + '\'' + ", fileId='" + this.f37397k + '\'' + ", appId=" + this.f37398l + ", reqServerIp='" + this.f37399m + '\'' + ", useHttpDNS=" + this.f37400n + ", reportId='" + this.f37401o + '\'' + ", reqKey='" + this.f37402p + '\'' + ", vodSessionKey='" + this.f37403q + '\'' + ", cosRegion='" + this.f37404r + '\'' + ", useCosAcc=" + this.f37405s + ", retryCount=" + this.f37408v + ", reporting=" + this.f37409w + ", requestId='" + this.f37410x + '\'' + ", tcpConnTimeCost=" + this.f37406t + ", recvRespTimeCost=" + this.f37407u + '}';
        }

        public c(c cVar) {
            this.f37387a = cVar.f37387a;
            this.f37388b = cVar.f37388b;
            this.f37391e = cVar.f37391e;
            this.f37389c = cVar.f37389c;
            this.f37390d = cVar.f37390d;
            this.f37392f = cVar.f37392f;
            this.f37393g = cVar.f37393g;
            this.f37394h = cVar.f37394h;
            this.f37395i = cVar.f37395i;
            this.f37396j = cVar.f37396j;
            this.f37397k = cVar.f37397k;
            this.f37398l = cVar.f37398l;
            this.f37399m = cVar.f37399m;
            this.f37400n = cVar.f37400n;
            this.f37401o = cVar.f37401o;
            this.f37402p = cVar.f37402p;
            this.f37403q = cVar.f37403q;
            this.f37404r = cVar.f37404r;
            this.f37405s = cVar.f37405s;
            this.f37406t = cVar.f37406t;
            this.f37407u = cVar.f37407u;
            this.f37408v = 0;
            this.f37409w = false;
            this.f37410x = cVar.f37410x;
        }
    }
}