package com.tencent.mm.plugin.cdndownloader.service;

import com.tencent.mars.BaseEvent;
import com.tencent.mars.cdn.CdnLogic;
import com.tencent.mars.cdn.CdnLogic.CdnTaskStateInfo;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.i.g;
import com.tencent.mm.ipcinvoker.wx_extension.b.b$a;
import com.tencent.mm.plugin.cdndownloader.a.a.a;
import com.tencent.mm.plugin.cdndownloader.a.b;
import com.tencent.mm.plugin.cdndownloader.ipc.CDNTaskInfo;
import com.tencent.mm.plugin.cdndownloader.ipc.CDNTaskState;
import com.tencent.mm.plugin.downloader.a.c;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;

class CDNDownloadService$1 extends a {
    final /* synthetic */ CDNDownloadService ktA;

    CDNDownloadService$1(CDNDownloadService cDNDownloadService) {
        this.ktA = cDNDownloadService;
    }

    public final int a(CDNTaskInfo cDNTaskInfo) {
        AppMethodBeat.i(938);
        ab.i("MicroMsg.CDNDownloadService", "addDownloadTask: %s filepath:%s", new Object[]{cDNTaskInfo.downloadUrl, cDNTaskInfo.filePath});
        g gVar = new g();
        gVar.egs = cDNTaskInfo.egs;
        gVar.field_mediaId = cDNTaskInfo.cHr;
        gVar.field_fullpath = cDNTaskInfo.filePath;
        gVar.egm = c.Ij(cDNTaskInfo.downloadUrl);
        gVar.egt = c.Ij(cDNTaskInfo.ktq);
        gVar.egl = CDNDownloadService.bfb();
        gVar.egn = cDNTaskInfo.kts;
        gVar.ego = cDNTaskInfo.ktt;
        gVar.allow_mobile_net_download = cDNTaskInfo.ktu;
        gVar.egr = cDNTaskInfo.ktv;
        CDNDownloadService.a(gVar, cDNTaskInfo.ktr);
        int f = com.tencent.mm.plugin.cdndownloader.c.a.beU().f(gVar);
        ab.i("MicroMsg.CDNDownloadService", "addDownloadTask: ".concat(String.valueOf(f)));
        AppMethodBeat.o(938);
        return f;
    }

    public final int b(CDNTaskInfo cDNTaskInfo) {
        int resumeHttpMultiSocketDownloadTask;
        AppMethodBeat.i(939);
        ab.i("MicroMsg.CDNDownloadService", "resumeDownloadTask: %s", new Object[]{cDNTaskInfo.downloadUrl});
        g gVar = new g();
        gVar.egs = cDNTaskInfo.egs;
        gVar.field_mediaId = cDNTaskInfo.cHr;
        gVar.field_fullpath = cDNTaskInfo.filePath;
        gVar.egm = c.Ij(cDNTaskInfo.downloadUrl);
        gVar.egt = c.Ij(cDNTaskInfo.ktq);
        gVar.egl = CDNDownloadService.bfb();
        gVar.egn = cDNTaskInfo.kts;
        gVar.ego = cDNTaskInfo.ktt;
        gVar.egr = cDNTaskInfo.ktv;
        gVar.allow_mobile_net_download = cDNTaskInfo.ktu;
        CDNDownloadService.a(gVar, cDNTaskInfo.ktr);
        com.tencent.mm.plugin.cdndownloader.c.a beU = com.tencent.mm.plugin.cdndownloader.c.a.beU();
        if (beU.fyM.containsKey(gVar.field_mediaId)) {
            resumeHttpMultiSocketDownloadTask = CdnLogic.resumeHttpMultiSocketDownloadTask(gVar.field_mediaId);
            ab.i("MicroMsg.CdnDownloadNativeService", "summersafecdn cdntra resumeRecvTask task resume mediaid:%s, ret:%d", new Object[]{gVar.field_mediaId, Integer.valueOf(resumeHttpMultiSocketDownloadTask)});
        } else {
            ab.i("MicroMsg.CdnDownloadNativeService", "summersafecdn cdntra resumeRecvTask task add new mediaid:%s", new Object[]{gVar.field_mediaId});
            resumeHttpMultiSocketDownloadTask = beU.f(gVar);
        }
        ab.i("MicroMsg.CDNDownloadService", "resumeDownloadTask: ".concat(String.valueOf(resumeHttpMultiSocketDownloadTask)));
        AppMethodBeat.o(939);
        return resumeHttpMultiSocketDownloadTask;
    }

    public final boolean HA(String str) {
        AppMethodBeat.i(940);
        com.tencent.mm.plugin.cdndownloader.c.a.beU();
        boolean HD = com.tencent.mm.plugin.cdndownloader.c.a.HD(str);
        ab.i("MicroMsg.CDNDownloadService", "pauseDownloadTask: ".concat(String.valueOf(HD)));
        AppMethodBeat.o(940);
        return HD;
    }

    public final boolean HB(String str) {
        AppMethodBeat.i(941);
        com.tencent.mm.plugin.cdndownloader.c.a beU = com.tencent.mm.plugin.cdndownloader.c.a.beU();
        g gVar = (g) beU.fyM.remove(str);
        if (gVar != null) {
            if (gVar.field_fileType == com.tencent.mm.i.a.efP || gVar.field_fileType == com.tencent.mm.i.a.efR) {
                beU.afy();
                com.tencent.mm.al.a.rK(str);
            } else if (gVar.egs) {
                beU.afy();
                com.tencent.mm.al.a.rL(str);
            } else {
                beU.afy();
                com.tencent.mm.al.a.rG(str);
            }
            h.pYm.e(10769, new Object[]{Integer.valueOf(com.tencent.mm.al.c.fzg), Integer.valueOf(gVar.field_fileType), Long.valueOf(bo.anU() - gVar.field_startTime)});
        }
        beU.fyL.remove(str);
        beU.fyN.remove(str);
        ab.i("MicroMsg.CdnDownloadNativeService", "summersafecdn cdntra cancelRecvTask mediaid:%s mapremove:%s engine ret:%d", new Object[]{str, gVar, Integer.valueOf(0)});
        ab.i("MicroMsg.CDNDownloadService", "removeDownloadTask: true");
        AppMethodBeat.o(941);
        return true;
    }

    public final CDNTaskState HC(String str) {
        AppMethodBeat.i(942);
        CdnTaskStateInfo httpMultiSocketDownloadTaskState = CdnLogic.httpMultiSocketDownloadTaskState(str);
        CDNTaskState cDNTaskState = new CDNTaskState();
        if (httpMultiSocketDownloadTaskState != null) {
            cDNTaskState.taskState = httpMultiSocketDownloadTaskState.taskState;
            cDNTaskState.fileTotalSize = httpMultiSocketDownloadTaskState.fileTotalSize;
            cDNTaskState.completeSize = httpMultiSocketDownloadTaskState.completeSize;
        }
        AppMethodBeat.o(942);
        return cDNTaskState;
    }

    public final void a(b bVar) {
        AppMethodBeat.i(943);
        ab.i("MicroMsg.CDNDownloadService", "registerCallback");
        CDNDownloadService.c(bVar);
        AppMethodBeat.o(943);
    }

    public final void b(b bVar) {
        AppMethodBeat.i(944);
        CDNDownloadService.c(null);
        AppMethodBeat.o(944);
    }

    public final void tr(int i) {
        AppMethodBeat.i(945);
        ab.i("MicroMsg.CDNDownloadService", "notifyNetworkChange: ".concat(String.valueOf(i)));
        BaseEvent.onNetworkChange();
        AppMethodBeat.o(945);
    }

    public final void beS() {
        AppMethodBeat.i(947);
        ab.i("MicroMsg.CDNDownloadService", "removeIPCTaskMarker");
        b$a.eGP.b(this.ktA);
        AppMethodBeat.o(947);
    }

    public final void beT() {
    }

    public final void beR() {
        AppMethodBeat.i(946);
        if (!b$a.eGP.c(this.ktA)) {
            ab.i("MicroMsg.CDNDownloadService", "addIPCTaskMarker");
            b$a.eGP.a(this.ktA);
        }
        AppMethodBeat.o(946);
    }
}
