package com.tencent.mm.modelmulti;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.ai.g;
import com.tencent.mm.ai.m;
import com.tencent.mm.ai.m.b;
import com.tencent.mm.compatible.util.g.a;
import com.tencent.mm.network.k;
import com.tencent.mm.network.q;
import com.tencent.mm.protocal.protobuf.SKBuiltinBuffer_t;
import com.tencent.mm.protocal.protobuf.beb;
import com.tencent.mm.protocal.protobuf.bec;
import com.tencent.mm.protocal.s$a;
import com.tencent.mm.sdk.platformtools.aa;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.ap;
import com.tencent.mm.sdk.platformtools.at;
import com.tencent.mm.sdk.platformtools.bo;
import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.Queue;
import junit.framework.Assert;

public final class e extends m implements k {
    a eOm;
    f ehi;
    final Queue<a> fCB = new LinkedList();
    private StringBuilder fHL = new StringBuilder();
    WeakReference<g> fHU = null;
    final beb fHV = new beb();
    int fHW = 0;
    boolean fHX = false;
    int fHY = 0;
    int fHZ = 0;
    boolean fIa = false;
    private final ap frk = new ap(com.tencent.mm.kernel.g.RS().oAl.getLooper(), new 1(this), true);
    private int retryCount = 3;

    public e(g gVar) {
        AppMethodBeat.i(58362);
        ab.i("MicroMsg.NetSceneInit.dkInit", "NetSceneInit hash:%d stack:%s", new Object[]{Integer.valueOf(hashCode()), bo.dpG()});
        this.fHL.append("stack:" + bo.dpG() + " time:" + bo.anT());
        this.fHU = new WeakReference(gVar);
        AppMethodBeat.o(58362);
    }

    public final int a(com.tencent.mm.network.e eVar, f fVar) {
        AppMethodBeat.i(58363);
        this.eOm = new a();
        this.ehi = fVar;
        beb beb = this.fHV;
        com.tencent.mm.kernel.g.RQ();
        beb.jBB = (String) com.tencent.mm.kernel.g.RP().Ry().get(2, null);
        Assert.assertTrue("by DK: req.UserName is null", !bo.isNullOrNil(this.fHV.jBB));
        this.fHV.luQ = aa.dor();
        int a = a(eVar, null, null);
        AppMethodBeat.o(58363);
        return a;
    }

    private int a(com.tencent.mm.network.e eVar, SKBuiltinBuffer_t sKBuiltinBuffer_t, SKBuiltinBuffer_t sKBuiltinBuffer_t2) {
        AppMethodBeat.i(58364);
        this.fHL.append(" lastd:" + this.ftg + " dotime:" + bo.anT() + " net:" + at.getNetType(ah.getContext()));
        b bVar = new b();
        if (sKBuiltinBuffer_t == null) {
            com.tencent.mm.kernel.g.RQ();
            sKBuiltinBuffer_t = com.tencent.mm.platformtools.aa.ad(bo.anf(bo.nullAsNil((String) com.tencent.mm.kernel.g.RP().Ry().get(8197, null))));
        }
        if (sKBuiltinBuffer_t2 == null) {
            com.tencent.mm.kernel.g.RQ();
            sKBuiltinBuffer_t2 = com.tencent.mm.platformtools.aa.ad(bo.anf(bo.nullAsNil((String) com.tencent.mm.kernel.g.RP().Ry().get(8198, null))));
        }
        com.tencent.mm.kernel.g.RQ();
        if (bo.h((Integer) com.tencent.mm.kernel.g.RP().Ry().get(16, null)) == 0 || (sKBuiltinBuffer_t != null && sKBuiltinBuffer_t.getILen() > 0)) {
            com.tencent.mm.kernel.g.RQ();
            if (bo.nullAsNil((String) com.tencent.mm.kernel.g.RP().Ry().get(8195, null)).length() <= 0) {
                bVar.acF().vyf = 3;
            } else {
                bVar.acF().vyf = 4;
            }
        } else {
            bVar.acF().vyf = 7;
        }
        this.fHV.wHH = sKBuiltinBuffer_t;
        this.fHV.wHI = sKBuiltinBuffer_t2;
        ((s$a) bVar.acF()).vyE = this.fHV;
        ab.i("MicroMsg.NetSceneInit.dkInit", "doScene hash:%d time:%d count:%d user%s lan:%s status:%d cur[%s] max[%s]", new Object[]{Integer.valueOf(hashCode()), Long.valueOf(this.eOm.Mr()), Integer.valueOf(this.fHW), this.fHV.jBB, this.fHV.luQ, Integer.valueOf(bVar.acF().vyf), bo.cd(com.tencent.mm.platformtools.aa.a(sKBuiltinBuffer_t)), bo.cd(com.tencent.mm.platformtools.aa.a(sKBuiltinBuffer_t2))});
        this.fHW++;
        int a = a(eVar, bVar, this);
        AppMethodBeat.o(58364);
        return a;
    }

    /* JADX WARNING: Missing block: B:14:0x00d0, code skipped:
            if (a(r8.ftf, null, null) == -1) goto L_0x00d2;
     */
    public final void a(int r9, int r10, int r11, java.lang.String r12, com.tencent.mm.network.q r13, byte[] r14) {
        /*
        r8 = this;
        r0 = 58365; // 0xe3fd float:8.1787E-41 double:2.8836E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r0);
        r0 = r8.fHL;
        r1 = new java.lang.StringBuilder;
        r2 = " endtime:";
        r1.<init>(r2);
        r2 = com.tencent.mm.sdk.platformtools.bo.anT();
        r1 = r1.append(r2);
        r1 = r1.toString();
        r0.append(r1);
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "summerinit onGYNetEnd [%d, %d, %s], tid:%d";
        r2 = 4;
        r2 = new java.lang.Object[r2];
        r3 = 0;
        r4 = java.lang.Integer.valueOf(r10);
        r2[r3] = r4;
        r3 = 1;
        r4 = java.lang.Integer.valueOf(r11);
        r2[r3] = r4;
        r3 = 2;
        r2[r3] = r12;
        r3 = 3;
        r4 = java.lang.Integer.valueOf(r9);
        r2[r3] = r4;
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1, r2);
        r0 = 4;
        if (r10 != r0) goto L_0x0081;
    L_0x0046:
        r0 = -100;
        if (r11 != r0) goto L_0x0081;
    L_0x004a:
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "onGYNetEnd ERROR hash:%d [%d,%d] KICK OUT : %s";
        r2 = 4;
        r2 = new java.lang.Object[r2];
        r3 = 0;
        r4 = r8.hashCode();
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 1;
        r4 = java.lang.Integer.valueOf(r10);
        r2[r3] = r4;
        r3 = 2;
        r4 = java.lang.Integer.valueOf(r11);
        r2[r3] = r4;
        r3 = 3;
        r2[r3] = r12;
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1, r2);
        r0 = 1;
        r8.fIa = r0;
        r0 = r8.ehi;
        r0.onSceneEnd(r10, r11, r12, r8);
        r0 = 58365; // 0xe3fd float:8.1787E-41 double:2.8836E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r0);
    L_0x0080:
        return;
    L_0x0081:
        if (r10 != 0) goto L_0x0085;
    L_0x0083:
        if (r11 == 0) goto L_0x00e6;
    L_0x0085:
        r0 = 4;
        if (r10 != r0) goto L_0x008c;
    L_0x0088:
        r0 = -17;
        if (r11 == r0) goto L_0x00e6;
    L_0x008c:
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "onGYNetEnd ERROR retry:%d hash:%d [%d,%d] %s";
        r2 = 5;
        r2 = new java.lang.Object[r2];
        r3 = 0;
        r4 = r8.retryCount;
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 1;
        r4 = r8.hashCode();
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 2;
        r4 = java.lang.Integer.valueOf(r10);
        r2[r3] = r4;
        r3 = 3;
        r4 = java.lang.Integer.valueOf(r11);
        r2[r3] = r4;
        r3 = 4;
        r2[r3] = r12;
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1, r2);
        r0 = r8.retryCount;
        if (r0 <= 0) goto L_0x00d2;
    L_0x00c1:
        r0 = r8.retryCount;
        r0 = r0 + -1;
        r8.retryCount = r0;
        r0 = r8.ftf;
        r1 = 0;
        r2 = 0;
        r0 = r8.a(r0, r1, r2);
        r1 = -1;
        if (r0 != r1) goto L_0x00df;
    L_0x00d2:
        r0 = 1;
        r8.fIa = r0;
        r0 = r8.ehi;
        r1 = 3;
        r2 = -1;
        r3 = "";
        r0.onSceneEnd(r1, r2, r3, r8);
    L_0x00df:
        r0 = 58365; // 0xe3fd float:8.1787E-41 double:2.8836E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r0);
        goto L_0x0080;
    L_0x00e6:
        r0 = r13.ZS();
        r0 = (com.tencent.mm.protocal.s.b) r0;
        r0 = (com.tencent.mm.protocal.s.b) r0;
        r5 = r0.vyF;
        r0 = r8.fHY;
        r1 = r5.wHK;
        r0 = r0 + r1;
        r8.fHY = r0;
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "onGYNetEnd hash:%d [%d,%d] time:%d cmdSum:%d doscenecount:%d conFlag:%d";
        r2 = 7;
        r2 = new java.lang.Object[r2];
        r3 = 0;
        r4 = r8.hashCode();
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 1;
        r4 = java.lang.Integer.valueOf(r10);
        r2[r3] = r4;
        r3 = 2;
        r4 = java.lang.Integer.valueOf(r11);
        r2[r3] = r4;
        r3 = 3;
        r4 = r8.eOm;
        r6 = r4.Mr();
        r4 = java.lang.Long.valueOf(r6);
        r2[r3] = r4;
        r3 = 4;
        r4 = r8.fHY;
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 5;
        r4 = r8.fHW;
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 6;
        r4 = r5.vQe;
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1, r2);
        r0 = r8.fHW;
        r1 = r0 + -1;
        r0 = r8;
        r2 = r10;
        r3 = r11;
        r4 = r12;
        r0.a(r1, r2, r3, r4, r5);
        r0 = r5.vQe;
        r0 = r0 & 7;
        if (r0 == 0) goto L_0x0186;
    L_0x0155:
        r0 = super.acJ();
        if (r0 != 0) goto L_0x0186;
    L_0x015b:
        r0 = r8.ftf;
        r1 = r5.wHH;
        r2 = r5.wHI;
        r0 = r8.a(r0, r1, r2);
        r1 = -1;
        if (r0 != r1) goto L_0x01c3;
    L_0x0168:
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "doScene Failed stop init";
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r1 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r2 = 3;
        r3 = -1;
        r4 = "";
        r5 = 0;
        r0 = r8;
        r0.a(r1, r2, r3, r4, r5);
        r0 = 58365; // 0xe3fd float:8.1787E-41 double:2.8836E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r0);
        goto L_0x0080;
    L_0x0186:
        r0 = "MicroMsg.NetSceneInit.dkInit";
        r1 = "NETWORK FINISH onGYNetEnd hash:%d time:%d netCnt:%d";
        r2 = 3;
        r2 = new java.lang.Object[r2];
        r3 = 0;
        r4 = r8.hashCode();
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        r3 = 1;
        r4 = r8.eOm;
        r4 = r4.Mr();
        r4 = java.lang.Long.valueOf(r4);
        r2[r3] = r4;
        r3 = 2;
        r4 = r8.fHW;
        r4 = java.lang.Integer.valueOf(r4);
        r2[r3] = r4;
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1, r2);
        r0 = 1;
        r8.fHX = r0;
        r1 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r2 = 0;
        r3 = 0;
        r4 = "";
        r5 = 0;
        r0 = r8;
        r0.a(r1, r2, r3, r4, r5);
    L_0x01c3:
        r0 = 58365; // 0xe3fd float:8.1787E-41 double:2.8836E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r0);
        goto L_0x0080;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.modelmulti.e.a(int, int, int, java.lang.String, com.tencent.mm.network.q, byte[]):void");
    }

    public final boolean acI() {
        return true;
    }

    public final void cancel() {
        AppMethodBeat.i(58366);
        ab.w("MicroMsg.NetSceneInit.dkInit", "init cancel by :%s", new Object[]{bo.dpG()});
        super.cancel();
        this.fIa = true;
        AppMethodBeat.o(58366);
    }

    private void a(int i, int i2, int i3, String str, bec bec) {
        AppMethodBeat.i(58367);
        a aVar = new a(this);
        aVar.fIf = i;
        aVar.errCode = i3;
        aVar.errType = i2;
        aVar.aIm = str;
        aVar.fIe = bec;
        this.fCB.add(aVar);
        if (this.frk.doT()) {
            this.frk.ae(50, 50);
        }
        AppMethodBeat.o(58367);
    }

    public final String getInfo() {
        AppMethodBeat.i(58368);
        String stringBuilder = this.fHL.toString();
        AppMethodBeat.o(58368);
        return stringBuilder;
    }

    public final int acn() {
        return 500;
    }

    public final b b(q qVar) {
        return b.ftu;
    }

    public final boolean acJ() {
        AppMethodBeat.i(138432);
        boolean acJ = super.acJ();
        AppMethodBeat.o(138432);
        return acJ;
    }

    public final int getType() {
        return 139;
    }
}
