package com.tencent.mm.ar;

import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.model.aw;
import com.tencent.mm.model.c;
import com.tencent.mm.model.n;
import com.tencent.mm.platformtools.aa;
import com.tencent.mm.plugin.report.e;
import com.tencent.mm.plugin.subapp.b;
import com.tencent.mm.protocal.protobuf.bbv;
import com.tencent.mm.protocal.protobuf.cnj;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.ap.a;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.LinkedList;

class c$7 implements a {
    final /* synthetic */ c fCH;

    c$7(c cVar) {
        this.fCH = cVar;
    }

    public final boolean BI() {
        AppMethodBeat.i(16477);
        if (this.fCH.fCB.isEmpty()) {
            ab.i("MicroMsg.GetContactService", "tryStartNetscene respHandler queue maybe this time is null , wait doscene!");
            AppMethodBeat.o(16477);
            return false;
        }
        boolean z;
        int i;
        int intValue;
        long anU = bo.anU();
        int i2 = this.fCH.frc ? 5 : 15;
        ArrayList arrayList = new ArrayList(i2 * 2);
        int i3 = 0;
        while (true) {
            int i4 = i3;
            if (i4 < i2) {
                c.a aVar = (c.a) this.fCH.fCB.peek();
                if (aVar == null) {
                    ab.i("MicroMsg.GetContactService", "tryStartNetscene respHandler queue maybe this time is null , break and wait doscene!");
                    z = false;
                } else {
                    LinkedList linkedList = aVar.fCO.woe;
                    LinkedList linkedList2 = aVar.fCO.wof;
                    i = aVar.fCP;
                    if (linkedList2.size() != linkedList.size()) {
                        ab.w("MicroMsg.GetContactService", "find warn %s %s", new Object[]{Integer.valueOf(linkedList2.size()), Integer.valueOf(linkedList.size())});
                    }
                    if (Math.min(linkedList2.size(), linkedList.size()) <= i) {
                        this.fCH.fCB.poll();
                        if (this.fCH.fCB.isEmpty()) {
                            ab.i("MicroMsg.GetContactService", "tryStartNetscene respHandler resp proc fin gr.curIdx:%d size:%d and retList is empty break", new Object[]{Integer.valueOf(i), Integer.valueOf(r8)});
                            this.fCH.fCC = 0;
                            this.fCH.fCF.ae(0, 0);
                            z = false;
                        } else {
                            ab.i("MicroMsg.GetContactService", "tryStartNetscene respHandler resp proc fin gr.curIdx:%d size:%d and retList is not empty continue next", new Object[]{Integer.valueOf(i), Integer.valueOf(r8)});
                        }
                    } else {
                        bbv bbv = (bbv) linkedList.get(i);
                        intValue = ((Integer) linkedList2.get(i)).intValue();
                        String bc = bo.bc(aa.a(bbv.wcB), BuildConfig.FLAVOR);
                        String bc2 = bo.bc(bbv.guS, BuildConfig.FLAVOR);
                        arrayList.add(bc);
                        arrayList.add(bc2);
                        switch (intValue) {
                            case -477:
                                z = d.agM().rY(bc);
                                boolean rY = d.agM().rY(bc2);
                                boolean mu = n.mu(bc);
                                ab.e("MicroMsg.GetContactService", "respHandler getFailed USERNAME_INVAILD :%d ErrName: %s %s %s %s %s", new Object[]{Integer.valueOf(intValue), bc, bc2, Boolean.valueOf(z), Boolean.valueOf(rY), Boolean.valueOf(mu)});
                                e.pXa.a(832, 1, 1, false);
                                z = false;
                                break;
                            case 0:
                                String bc3;
                                if (aVar.fCO.wog != null && aVar.fCO.wog.size() > i) {
                                    if (bc.equals(((cnj) aVar.fCO.wog.get(i)).username)) {
                                        bc3 = bo.bc(((cnj) aVar.fCO.wog.get(i)).xkS, BuildConfig.FLAVOR);
                                        ab.i("MicroMsg.GetContactService", "dkverify respHandler mod contact: %s %s %s", new Object[]{bc, bc2, bc3});
                                        b.gkF.a(bbv, bc3);
                                        e.pXa.a(832, 0, 1, false);
                                        z = true;
                                        break;
                                    }
                                }
                                String str = "MicroMsg.GetContactService";
                                String str2 = "get antispamticket from resp failed: list:%s idx:%d  user:%s";
                                Object[] objArr = new Object[3];
                                if (aVar.fCO.wog == null) {
                                    bc3 = "null";
                                } else {
                                    bc3 = Integer.valueOf(aVar.fCO.wog.size());
                                }
                                objArr[0] = bc3;
                                objArr[1] = Integer.valueOf(i);
                                objArr[2] = bc;
                                ab.w(str, str2, objArr);
                                bc3 = BuildConfig.FLAVOR;
                                ab.i("MicroMsg.GetContactService", "dkverify respHandler mod contact: %s %s %s", new Object[]{bc, bc2, bc3});
                                b.gkF.a(bbv, bc3);
                                e.pXa.a(832, 0, 1, false);
                                z = true;
                            default:
                                z = n.mu(bc);
                                ab.e("MicroMsg.GetContactService", "respHandler getFailed :%d ErrName: %s %s %s", new Object[]{Integer.valueOf(intValue), bc, bc2, Boolean.valueOf(z)});
                                e.pXa.a(832, 2, 1, false);
                                z = false;
                                break;
                        }
                        new ak(Looper.getMainLooper()).post(new 1(this, bc, bc2, z));
                        aVar.fCP++;
                    }
                    i3 = i4 + 1;
                }
            } else {
                z = true;
            }
        }
        i = arrayList.size();
        if (i > 0) {
            aw.ZK();
            long iV = c.Ru().iV(Thread.currentThread().getId());
            b agM = d.agM();
            for (intValue = 0; intValue < i; intValue++) {
                agM.rY((String) arrayList.get(intValue));
            }
            aw.ZK();
            c.Ru().mB(iV);
        }
        ab.i("MicroMsg.GetContactService", "tryStartNetscene respHandler onTimerExpired netSceneRunning : " + this.fCH.frc + " ret: " + z + " maxCnt: " + i2 + " deleteCount: " + i + " take: " + (bo.anU() - anU) + "ms");
        AppMethodBeat.o(16477);
        return z;
    }
}
