package com.tencent.mm.plugin.backup.c;

import android.text.TextUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.model.s;
import com.tencent.mm.model.t;
import com.tencent.mm.plugin.backup.b.f;
import com.tencent.mm.plugin.backup.c.c.a;
import com.tencent.mm.plugin.backup.f.h;
import com.tencent.mm.plugin.backup.g.c;
import com.tencent.mm.plugin.backup.g.c.b;
import com.tencent.mm.plugin.backup.i.u;
import com.tencent.mm.protocal.protobuf.gu;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.an;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.ytcommon.BuildConfig;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
import java.util.concurrent.LinkedBlockingQueue;
import junit.framework.Assert;

class c$b {
    String TAG;
    String bCu;
    boolean hkm;
    final /* synthetic */ c jrL;
    LinkedBlockingQueue<Runnable> jrP;
    a jrQ;
    private long jrR;
    String jrS;
    Vector<String> jrT;
    private Vector<gu> jrU;
    HashMap<Long, h.a> jrV;
    long jrW;
    private final b jrX;
    private final Runnable jrY;
    final Runnable jrZ;
    int jre;
    long jrg;
    long jrh;
    String talker;

    public final String toString() {
        return this.TAG;
    }

    public c$b(c cVar, a aVar, f.a aVar2) {
        String displayName;
        this.jrL = cVar;
        AppMethodBeat.i(17187);
        this.TAG = BuildConfig.FLAVOR;
        this.jrP = new LinkedBlockingQueue();
        this.jrg = 0;
        this.jrh = 0;
        this.jrR = 0;
        this.jrS = BuildConfig.FLAVOR;
        this.jrT = new Vector();
        this.jrU = new Vector();
        this.jrV = new HashMap();
        this.jrW = 0;
        this.hkm = false;
        this.jrX = new 1(this);
        this.jrY = new 3(this);
        this.jrZ = new 4(this);
        this.jrW = bo.anU();
        this.jrQ = aVar;
        this.talker = aVar2.jrd;
        this.jre = aVar2.jre;
        if (t.kH(this.talker)) {
            displayName = s.getDisplayName(this.talker, this.talker);
        } else {
            displayName = s.mJ(this.talker);
        }
        this.bCu = displayName;
        this.TAG = "MicroMsg.BackupPackAndSend.tag." + (this.hkm ? "S." : "W.") + this.jre + "." + this.bCu;
        ab.i(this.TAG, "initTagNow [%d,%s,%s] [%s]", new Object[]{Integer.valueOf(this.jre), this.bCu, this.talker, an.doQ()});
        AppMethodBeat.o(17187);
    }

    public final boolean a(gu guVar, long j, long j2, LinkedList<u> linkedList, HashMap<Long, h.a> hashMap) {
        AppMethodBeat.i(17188);
        this.jrU.add(guVar);
        this.jrR = (j > 0 ? j : 0) + this.jrR;
        if (this.jrg == 0) {
            this.jrg = j2;
        }
        this.jrh = j2;
        this.jrV.putAll(hashMap);
        Iterator it = linkedList.iterator();
        while (it.hasNext()) {
            u uVar = (u) it.next();
            m(uVar.cHr, uVar.path, false);
        }
        ab.i(this.TAG, "addToTag msgtime[%d,%d] size[%d,%d] baklist:%d media:%d timeDiff:%d", new Object[]{Long.valueOf(this.jrg), Long.valueOf(this.jrh), Long.valueOf(j), Long.valueOf(this.jrR), Integer.valueOf(this.jrU.size()), Integer.valueOf(linkedList.size()), Long.valueOf(bo.gb(this.jrW))});
        if (this.jrR > 83886080 || this.jrU.size() > 80) {
            aSJ();
            AppMethodBeat.o(17188);
            return true;
        }
        AppMethodBeat.o(17188);
        return false;
    }

    public final void aSJ() {
        AppMethodBeat.i(17189);
        this.jrS = "MSG_" + this.jrU.size() + "_" + this.talker + "_" + bo.anU();
        ab.i(this.TAG, "setTagEnd msgtime[%d,%d], size:%d baklist:%d bigfile:%d id:%s timeDiff:%d", new Object[]{Long.valueOf(this.jrg), Long.valueOf(this.jrh), Long.valueOf(this.jrR), Integer.valueOf(this.jrU.size()), Integer.valueOf(this.jrV.size()), this.jrS, Long.valueOf(bo.gb(this.jrW))});
        if (this.jrU.size() > 0) {
            m(this.jrS, null, false);
            if (this.jrV.isEmpty()) {
                this.jrP.offer(this.jrZ);
                AppMethodBeat.o(17189);
                return;
            }
            this.jrP.offer(this.jrY);
            AppMethodBeat.o(17189);
            return;
        }
        ab.w(this.TAG, "setTagEnd NoFileSend, Go Send Tag: Direct. baklist:%d media:%d bigFileMap:%d ", new Object[]{Integer.valueOf(this.jrU.size()), Integer.valueOf(this.jrT.size()), Integer.valueOf(this.jrV.size())});
        Assert.assertTrue("cursorEnd NOMsg, chatMsgList should empty", this.jrU.isEmpty());
        Assert.assertTrue("cursorEnd NOMsg, MediaList should empty", this.jrT.isEmpty());
        Assert.assertTrue("cursorEnd NOMsg, BigFileList should empty", this.jrV.isEmpty());
        this.jrP.offer(this.jrZ);
        AppMethodBeat.o(17189);
    }

    /* Access modifiers changed, original: final */
    public final void m(String str, String str2, boolean z) {
        boolean z2 = true;
        AppMethodBeat.i(17190);
        2 2 = new 2(this);
        ab.i(this.TAG, "postSendFile isBigFile[%b], baklst:%d Id:%s path:%s", new Object[]{Boolean.valueOf(z), Integer.valueOf(this.jrU.size()), str, str2});
        if (TextUtils.isEmpty(str2)) {
            String str3 = "chatMsgList should not empty";
            if (this.jrU.isEmpty()) {
                z2 = false;
            }
            Assert.assertTrue(str3, z2);
            if (str != null) {
                c.a(this.jrX, 2, str, new LinkedList(this.jrU), this.jrL.jrF.jqU);
            }
        } else {
            this.jrT.add(str);
            if (str != null) {
                c.a(this.jrX, 2, str, str2, this.jrL.jrF.jqU);
                AppMethodBeat.o(17190);
                return;
            }
        }
        AppMethodBeat.o(17190);
    }
}
