package com.tencent.mm.modelvideo;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Looper;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.a.g;
import com.tencent.mm.cd.h;
import com.tencent.mm.sdk.e.l;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.vfs.b;
import com.tencent.mm.vfs.e;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;
import com.tencent.ttpic.baseutils.FileUtils;
import com.tencent.ytcommon.BuildConfig;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import junit.framework.Assert;

public final class t {
    private static long fXo = 0;
    public static final String[] fnj = new String[]{"CREATE TABLE IF NOT EXISTS videoinfo2 ( filename text  PRIMARY KEY , clientid text  , msgsvrid int  , netoffset int  , filenowsize int  , totallen int  , thumbnetoffset int  , thumblen int  , status int  , createtime long  , lastmodifytime long  , downloadtime long  , videolength int  , msglocalid int  , nettimes int  , cameratype int  , user text  , human text  , reserved1 int  , reserved2 int  , reserved3 text  , reserved4 text  , videofuncflag int ,masssendid long ,masssendlist text,videomd5 text, streamvideo byte[], statextstr text, downloadscene int, mmsightextinfo byte[], preloadsize int, videoformat int )", "CREATE INDEX IF NOT EXISTS  video_status_index ON videoinfo2 ( status,downloadtime )", "CREATE TABLE IF NOT EXISTS videoinfo ( filename text  PRIMARY KEY , clientid text  , msgsvrid int  , netoffset int  , filenowsize int  , totallen int  , thumbnetoffset int  , thumblen int  , status int  , createtime long  , lastmodifytime long  , downloadtime long  , videolength int  , msglocalid int  , nettimes int  , cameratype int  , user text  , human text  , reserved1 int  , reserved2 int  , reserved3 text  , reserved4 text  , videofuncflag int ,masssendid long ,masssendlist text,videomd5 text, streamvideo byte[], statextstr text, downloadscene int, mmsightextinfo byte[], preloadsize int, videoformat int )", "alter table videoinfo2 add videofuncflag int ;", "alter table videoinfo2 add masssendid long default 0;", "alter table videoinfo2 add masssendlist text ;", "alter table videoinfo2 add videomd5 text ;", "alter table videoinfo2 add streamvideo byte[] ;", "alter table videoinfo2 add statextstr text ;", "alter table videoinfo2 add downloadscene int ;", "alter table videoinfo2 add mmsightextinfo byte[] ;", "alter table videoinfo2 add preloadsize int ;", "alter table videoinfo2 add videoformat int ;", "alter table videoinfo add videofuncflag int ;", "alter table videoinfo add masssendid long default 0;", "alter table videoinfo add masssendlist text ;", "alter table videoinfo add videomd5 text ;", "alter table videoinfo add streamvideo byte[] ;", "alter table videoinfo add statextstr text ;", "alter table videoinfo add downloadscene int ;", "alter table videoinfo add mmsightextinfo byte[] ;", "alter table videoinfo add preloadsize int ;", "alter table videoinfo add videoformat int ;", "insert into videoinfo2 select * from videoinfo ;", "delete from videoinfo ;", "CREATE INDEX IF NOT EXISTS  massSendIdIndex ON videoinfo2 ( masssendid )", "CREATE INDEX IF NOT EXISTS  LastModifyTimeIndex ON videoinfo2 ( lastmodifytime )", "CREATE TABLE IF NOT EXISTS  VideoHash  (size int , CreateTime long, hash text ,  cdnxml text, orgpath text);", "CREATE INDEX IF NOT EXISTS  VideoHashSizeIndex ON VideoHash ( size  )", "CREATE INDEX IF NOT EXISTS  VideoHashTimeIndex ON VideoHash ( CreateTime  )"};
    public h fni;
    l<a, t$a$a> fry = new 1(this);

    public final void a(a aVar, Looper looper) {
        AppMethodBeat.i(50798);
        this.fry.a(aVar, looper);
        AppMethodBeat.o(50798);
    }

    public final void a(a aVar) {
        AppMethodBeat.i(50799);
        this.fry.remove(aVar);
        AppMethodBeat.o(50799);
    }

    public t(h hVar) {
        AppMethodBeat.i(50800);
        this.fni = hVar;
        AppMethodBeat.o(50800);
    }

    public final boolean b(s sVar) {
        AppMethodBeat.i(50801);
        if (sVar == null) {
            AppMethodBeat.o(50801);
            return false;
        }
        sVar.bJt = -1;
        if (((int) this.fni.insert("videoinfo2", "filename", sVar.Hl())) != -1) {
            this.fry.cF(new t$a$a(sVar.getFileName(), b.fXv, t$a$c.NORMAL, sVar.fXk, sVar.fVs));
            this.fry.doNotify();
            AppMethodBeat.o(50801);
            return true;
        }
        AppMethodBeat.o(50801);
        return false;
    }

    public final s uf(String str) {
        s sVar = null;
        AppMethodBeat.i(50802);
        Cursor a = this.fni.a("select videoinfo2.filename,videoinfo2.clientid,videoinfo2.msgsvrid,videoinfo2.netoffset,videoinfo2.filenowsize,videoinfo2.totallen,videoinfo2.thumbnetoffset,videoinfo2.thumblen,videoinfo2.status,videoinfo2.createtime,videoinfo2.lastmodifytime,videoinfo2.downloadtime,videoinfo2.videolength,videoinfo2.msglocalid,videoinfo2.nettimes,videoinfo2.cameratype,videoinfo2.user,videoinfo2.human,videoinfo2.reserved1,videoinfo2.reserved2,videoinfo2.reserved3,videoinfo2.reserved4,videoinfo2.videofuncflag,videoinfo2.masssendid,videoinfo2.masssendlist,videoinfo2.videomd5,videoinfo2.streamvideo,videoinfo2.statextstr,videoinfo2.downloadscene,videoinfo2.mmsightextinfo,videoinfo2.preloadsize,videoinfo2.videoformat from videoinfo2   where videoinfo2.filename = \"" + bo.vA(String.valueOf(str)) + "\"", null, 2);
        if (a == null) {
            AppMethodBeat.o(50802);
        } else {
            if (a.moveToFirst()) {
                sVar = new s();
                sVar.d(a);
            }
            a.close();
            AppMethodBeat.o(50802);
        }
        return sVar;
    }

    public final List<s> fU(long j) {
        List<s> list = null;
        AppMethodBeat.i(50803);
        Cursor a = this.fni.a("select videoinfo2.filename,videoinfo2.clientid,videoinfo2.msgsvrid,videoinfo2.netoffset,videoinfo2.filenowsize,videoinfo2.totallen,videoinfo2.thumbnetoffset,videoinfo2.thumblen,videoinfo2.status,videoinfo2.createtime,videoinfo2.lastmodifytime,videoinfo2.downloadtime,videoinfo2.videolength,videoinfo2.msglocalid,videoinfo2.nettimes,videoinfo2.cameratype,videoinfo2.user,videoinfo2.human,videoinfo2.reserved1,videoinfo2.reserved2,videoinfo2.reserved3,videoinfo2.reserved4,videoinfo2.videofuncflag,videoinfo2.masssendid,videoinfo2.masssendlist,videoinfo2.videomd5,videoinfo2.streamvideo,videoinfo2.statextstr,videoinfo2.downloadscene,videoinfo2.mmsightextinfo,videoinfo2.preloadsize,videoinfo2.videoformat from videoinfo2   where videoinfo2.masssendid = ".concat(String.valueOf(j)), null, 2);
        if (a == null) {
            AppMethodBeat.o(50803);
        } else {
            list = new ArrayList();
            while (a.moveToNext()) {
                s sVar = new s();
                sVar.d(a);
                list.add(sVar);
            }
            a.close();
            AppMethodBeat.o(50803);
        }
        return list;
    }

    public final List<s> alB() {
        AppMethodBeat.i(50804);
        String str = "select videoinfo2.filename,videoinfo2.clientid,videoinfo2.msgsvrid,videoinfo2.netoffset,videoinfo2.filenowsize,videoinfo2.totallen,videoinfo2.thumbnetoffset,videoinfo2.thumblen,videoinfo2.status,videoinfo2.createtime,videoinfo2.lastmodifytime,videoinfo2.downloadtime,videoinfo2.videolength,videoinfo2.msglocalid,videoinfo2.nettimes,videoinfo2.cameratype,videoinfo2.user,videoinfo2.human,videoinfo2.reserved1,videoinfo2.reserved2,videoinfo2.reserved3,videoinfo2.reserved4,videoinfo2.videofuncflag,videoinfo2.masssendid,videoinfo2.masssendlist,videoinfo2.videomd5,videoinfo2.streamvideo,videoinfo2.statextstr,videoinfo2.downloadscene,videoinfo2.mmsightextinfo,videoinfo2.preloadsize,videoinfo2.videoformat from videoinfo2  " + " WHERE status=200 order by masssendid desc";
        ArrayList arrayList = new ArrayList();
        Cursor a = this.fni.a(str, null, 2);
        int i = 0;
        while (a.moveToNext()) {
            s sVar = new s();
            sVar.d(a);
            arrayList.add(sVar);
            i++;
        }
        a.close();
        ab.d("MicroMsg.VideoInfoStorage", "getUnfinishMassInfo resCount:".concat(String.valueOf(i)));
        AppMethodBeat.o(50804);
        return arrayList;
    }

    public final List<s> alC() {
        AppMethodBeat.i(50805);
        String str = "select videoinfo2.filename,videoinfo2.clientid,videoinfo2.msgsvrid,videoinfo2.netoffset,videoinfo2.filenowsize,videoinfo2.totallen,videoinfo2.thumbnetoffset,videoinfo2.thumblen,videoinfo2.status,videoinfo2.createtime,videoinfo2.lastmodifytime,videoinfo2.downloadtime,videoinfo2.videolength,videoinfo2.msglocalid,videoinfo2.nettimes,videoinfo2.cameratype,videoinfo2.user,videoinfo2.human,videoinfo2.reserved1,videoinfo2.reserved2,videoinfo2.reserved3,videoinfo2.reserved4,videoinfo2.videofuncflag,videoinfo2.masssendid,videoinfo2.masssendlist,videoinfo2.videomd5,videoinfo2.streamvideo,videoinfo2.statextstr,videoinfo2.downloadscene,videoinfo2.mmsightextinfo,videoinfo2.preloadsize,videoinfo2.videoformat from videoinfo2  " + " WHERE status=198 AND masssendid > 0 order by masssendid desc";
        ArrayList arrayList = new ArrayList();
        Cursor a = this.fni.a(str, null, 2);
        while (a.moveToNext()) {
            s sVar = new s();
            sVar.d(a);
            arrayList.add(sVar);
        }
        a.close();
        AppMethodBeat.o(50805);
        return arrayList;
    }

    public final boolean c(s sVar) {
        boolean z;
        AppMethodBeat.i(50806);
        Assert.assertTrue(sVar != null);
        if (sVar.getFileName().length() > 0) {
            z = true;
        } else {
            z = false;
        }
        Assert.assertTrue(z);
        ContentValues Hl = sVar.Hl();
        if (Hl.size() <= 0) {
            ab.e("MicroMsg.VideoInfoStorage", "update failed, no values set");
        } else {
            if (this.fni.update("videoinfo2", Hl, "filename= ?", new String[]{sVar.getFileName()}) > 0) {
                t$a$c t_a_c = t$a$c.NORMAL;
                if (sVar.status == 112) {
                    t_a_c = t$a$c.DOWNLOAD;
                } else if (sVar.status == TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_EXTRA_AUDIOTRACK_TITLES || sVar.status == TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_EXTRA_AUDIOTRACK_INDEX) {
                    t_a_c = t$a$c.UPLOAD;
                }
                this.fry.cF(new t$a$a(sVar.getFileName(), b.fXx, t_a_c, sVar.fXk, sVar.fVs));
                this.fry.doNotify();
                AppMethodBeat.o(50806);
                return true;
            }
        }
        AppMethodBeat.o(50806);
        return false;
    }

    public final List<String> alD() {
        Throwable th;
        List<String> list = null;
        AppMethodBeat.i(50807);
        Cursor a;
        try {
            a = this.fni.a("select videoinfo2.filename,downloadtime from videoinfo2  " + " WHERE status=112 ORDER BY downloadtime DESC " + " LIMIT 10", null, 2);
            try {
                if (a.moveToFirst()) {
                    list = new ArrayList();
                    do {
                        list.add(a.getString(0));
                    } while (a.moveToNext());
                }
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50807);
                return list;
            } catch (Throwable th2) {
                th = th2;
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50807);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            a = null;
        }
    }

    public final List<String> alE() {
        Throwable th;
        List<String> list = null;
        AppMethodBeat.i(50808);
        String str = " LIMIT 10 )";
        Cursor a;
        try {
            a = this.fni.a((((" SELECT * FROM ( " + "select videoinfo2.filename,downloadtime from videoinfo2   WHERE status=122" + str) + " UNION SELECT * FROM ( ") + "select videoinfo2.filename,downloadtime from videoinfo2   WHERE status=120" + str) + " ORDER BY downloadtime DESC", null, 2);
            try {
                if (a.moveToFirst()) {
                    list = new ArrayList();
                    do {
                        list.add(a.getString(0));
                    } while (a.moveToNext());
                }
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50808);
                return list;
            } catch (Throwable th2) {
                th = th2;
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50808);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            a = null;
        }
    }

    public final List<s> v(int i, long j) {
        Throwable th;
        List<s> list = null;
        AppMethodBeat.i(50809);
        Cursor a;
        try {
            a = this.fni.a("select videoinfo2.filename,videoinfo2.clientid,videoinfo2.msgsvrid,videoinfo2.netoffset,videoinfo2.filenowsize,videoinfo2.totallen,videoinfo2.thumbnetoffset,videoinfo2.thumblen,videoinfo2.status,videoinfo2.createtime,videoinfo2.lastmodifytime,videoinfo2.downloadtime,videoinfo2.videolength,videoinfo2.msglocalid,videoinfo2.nettimes,videoinfo2.cameratype,videoinfo2.user,videoinfo2.human,videoinfo2.reserved1,videoinfo2.reserved2,videoinfo2.reserved3,videoinfo2.reserved4,videoinfo2.videofuncflag,videoinfo2.masssendid,videoinfo2.masssendlist,videoinfo2.videomd5,videoinfo2.streamvideo,videoinfo2.statextstr,videoinfo2.downloadscene,videoinfo2.mmsightextinfo,videoinfo2.preloadsize,videoinfo2.videoformat from videoinfo2   where status=" + i + " AND preloadsize > 0 AND lastmodifytime <= " + j + " ORDER BY createtime LIMIT 1", null, 2);
            try {
                if (a.moveToFirst()) {
                    list = new ArrayList();
                    do {
                        s sVar = new s();
                        sVar.d(a);
                        list.add(sVar);
                    } while (a.moveToNext());
                }
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50809);
                return list;
            } catch (Throwable th2) {
                th = th2;
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50809);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            a = null;
        }
    }

    public final List<String> alF() {
        Throwable th;
        List<String> list = null;
        AppMethodBeat.i(50810);
        String str = " LIMIT 10 )";
        Cursor a;
        try {
            a = this.fni.a((((" SELECT * FROM ( " + "select videoinfo2.filename,downloadtime from videoinfo2   WHERE status=103" + str) + " UNION SELECT * FROM ( ") + "select videoinfo2.filename,downloadtime from videoinfo2   WHERE status=104" + str) + " ORDER BY downloadtime DESC", null, 2);
            try {
                if (a.moveToFirst()) {
                    list = new ArrayList();
                    do {
                        list.add(a.getString(0));
                    } while (a.moveToNext());
                }
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50810);
                return list;
            } catch (Throwable th2) {
                th = th2;
                if (a != null) {
                    a.close();
                }
                AppMethodBeat.o(50810);
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            a = null;
        }
    }

    public static String ug(String str) {
        AppMethodBeat.i(50811);
        long currentTimeMillis = System.currentTimeMillis();
        String format = new SimpleDateFormat("HHmmssddMMyy").format(new Date(currentTimeMillis));
        if (str != null && str.length() > 1) {
            format = format + g.x(str.getBytes()).substring(0, 7);
        }
        StringBuilder append = new StringBuilder().append(format + (currentTimeMillis % 10000));
        currentTimeMillis = fXo;
        fXo = 1 + currentTimeMillis;
        format = append.append(currentTimeMillis).toString();
        AppMethodBeat.o(50811);
        return format;
    }

    private static String getVideoPath() {
        AppMethodBeat.i(50812);
        String str = com.tencent.mm.kernel.g.RP().eJM + "video/";
        AppMethodBeat.o(50812);
        return str;
    }

    public static String uh(String str) {
        AppMethodBeat.i(50813);
        if (bo.isNullOrNil(str)) {
            AppMethodBeat.o(50813);
            return null;
        }
        String str2 = getVideoPath() + str;
        if (e.ct(str2)) {
            AppMethodBeat.o(50813);
            return str2;
        }
        str2 = str2 + ".mp4";
        AppMethodBeat.o(50813);
        return str2;
    }

    public static String ui(String str) {
        AppMethodBeat.i(50814);
        if (bo.isNullOrNil(str)) {
            AppMethodBeat.o(50814);
            return null;
        }
        String str2 = getVideoPath() + str + FileUtils.PIC_POSTFIX_JPEG;
        AppMethodBeat.o(50814);
        return str2;
    }

    /* JADX WARNING: Removed duplicated region for block: B:28:0x01cc A:{SYNTHETIC, Splitter:B:28:0x01cc} */
    public static int a(java.lang.String r13, int r14, byte[] r15) {
        /*
        r12 = 50815; // 0xc67f float:7.1207E-41 double:2.5106E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r12);
        r0 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r13);
        if (r0 == 0) goto L_0x0037;
    L_0x000c:
        r0 = "MicroMsg.VideoInfoStorage";
        r1 = new java.lang.StringBuilder;
        r2 = "ERR:";
        r1.<init>(r2);
        r2 = com.tencent.mm.compatible.util.g.Mq();
        r1 = r1.append(r2);
        r2 = " invalid fileName";
        r1 = r1.append(r2);
        r1 = r1.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r0 = com.tencent.mm.compatible.util.g.getLine();
        r0 = 0 - r0;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
    L_0x0036:
        return r0;
    L_0x0037:
        if (r14 >= 0) goto L_0x0073;
    L_0x0039:
        r0 = "MicroMsg.VideoInfoStorage";
        r1 = new java.lang.StringBuilder;
        r2 = "ERR:";
        r1.<init>(r2);
        r2 = com.tencent.mm.compatible.util.g.Mq();
        r1 = r1.append(r2);
        r2 = "[";
        r1 = r1.append(r2);
        r1 = r1.append(r13);
        r2 = "]  invalid startOffset:";
        r1 = r1.append(r2);
        r1 = r1.append(r14);
        r1 = r1.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r0 = com.tencent.mm.compatible.util.g.getLine();
        r0 = 0 - r0;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x0036;
    L_0x0073:
        r0 = com.tencent.mm.sdk.platformtools.bo.cb(r15);
        if (r0 == 0) goto L_0x00af;
    L_0x0079:
        r0 = "MicroMsg.VideoInfoStorage";
        r1 = new java.lang.StringBuilder;
        r2 = "ERR:";
        r1.<init>(r2);
        r2 = com.tencent.mm.compatible.util.g.Mq();
        r1 = r1.append(r2);
        r2 = "[";
        r1 = r1.append(r2);
        r1 = r1.append(r13);
        r2 = "]  invalid writeBuf";
        r1 = r1.append(r2);
        r1 = r1.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1);
        r0 = com.tencent.mm.compatible.util.g.getLine();
        r0 = 0 - r0;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x0036;
    L_0x00af:
        r3 = new com.tencent.mm.compatible.util.g$a;
        r3.<init>();
        r2 = 0;
        r1 = new java.io.RandomAccessFile;	 Catch:{ Exception -> 0x0170, all -> 0x01c8 }
        r0 = "rw";
        r1.<init>(r13, r0);	 Catch:{ Exception -> 0x0170, all -> 0x01c8 }
        r4 = r3.Mr();	 Catch:{ Exception -> 0x01dc }
        r6 = (long) r14;	 Catch:{ Exception -> 0x01dc }
        r1.seek(r6);	 Catch:{ Exception -> 0x01dc }
        r6 = r3.Mr();	 Catch:{ Exception -> 0x01dc }
        r0 = 0;
        r2 = r15.length;	 Catch:{ Exception -> 0x01dc }
        r1.write(r15, r0, r2);	 Catch:{ Exception -> 0x01dc }
        r8 = r3.Mr();	 Catch:{ Exception -> 0x01dc }
        r10 = r1.getFilePointer();	 Catch:{ Exception -> 0x01dc }
        r0 = (int) r10;	 Catch:{ Exception -> 0x01dc }
        r2 = r3.Mr();	 Catch:{ Exception -> 0x01dc }
        r1.close();	 Catch:{ Exception -> 0x01d3 }
    L_0x00de:
        r1 = "MicroMsg.VideoInfoStorage";
        r10 = new java.lang.StringBuilder;
        r11 = "FIN:";
        r10.<init>(r11);
        r11 = com.tencent.mm.compatible.util.g.Mq();
        r10 = r10.append(r11);
        r11 = "[";
        r10 = r10.append(r11);
        r10 = r10.append(r13);
        r11 = "]  Offset:";
        r10 = r10.append(r11);
        r10 = r10.append(r14);
        r11 = " buf:";
        r10 = r10.append(r11);
        r11 = r15.length;
        r10 = r10.append(r11);
        r10 = r10.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r1, r10);
        r1 = "MicroMsg.VideoInfoStorage";
        r10 = new java.lang.StringBuilder;
        r11 = "FIN:";
        r10.<init>(r11);
        r11 = com.tencent.mm.compatible.util.g.Mq();
        r10 = r10.append(r11);
        r11 = "[";
        r10 = r10.append(r11);
        r10 = r10.append(r13);
        r11 = "] open:";
        r10 = r10.append(r11);
        r4 = r10.append(r4);
        r5 = " seek:";
        r4 = r4.append(r5);
        r4 = r4.append(r6);
        r5 = " write:";
        r4 = r4.append(r5);
        r4 = r4.append(r8);
        r5 = " close:";
        r4 = r4.append(r5);
        r2 = r4.append(r2);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x0036;
    L_0x0170:
        r0 = move-exception;
        r1 = r2;
    L_0x0172:
        r2 = "MicroMsg.VideoInfoStorage";
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x01da }
        r4 = "ERR:";
        r3.<init>(r4);	 Catch:{ all -> 0x01da }
        r4 = com.tencent.mm.compatible.util.g.Mq();	 Catch:{ all -> 0x01da }
        r3 = r3.append(r4);	 Catch:{ all -> 0x01da }
        r4 = "[";
        r3 = r3.append(r4);	 Catch:{ all -> 0x01da }
        r3 = r3.append(r13);	 Catch:{ all -> 0x01da }
        r4 = "] \t\tOffset:";
        r3 = r3.append(r4);	 Catch:{ all -> 0x01da }
        r3 = r3.append(r14);	 Catch:{ all -> 0x01da }
        r4 = " failed:[";
        r3 = r3.append(r4);	 Catch:{ all -> 0x01da }
        r0 = r0.getMessage();	 Catch:{ all -> 0x01da }
        r0 = r3.append(r0);	 Catch:{ all -> 0x01da }
        r3 = "]";
        r0 = r0.append(r3);	 Catch:{ all -> 0x01da }
        r0 = r0.toString();	 Catch:{ all -> 0x01da }
        com.tencent.mm.sdk.platformtools.ab.e(r2, r0);	 Catch:{ all -> 0x01da }
        r0 = com.tencent.mm.compatible.util.g.getLine();	 Catch:{ all -> 0x01da }
        r0 = 0 - r0;
        if (r1 == 0) goto L_0x01c3;
    L_0x01c0:
        r1.close();	 Catch:{ Exception -> 0x01d6 }
    L_0x01c3:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x0036;
    L_0x01c8:
        r0 = move-exception;
        r1 = r2;
    L_0x01ca:
        if (r1 == 0) goto L_0x01cf;
    L_0x01cc:
        r1.close();	 Catch:{ Exception -> 0x01d8 }
    L_0x01cf:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        throw r0;
    L_0x01d3:
        r1 = move-exception;
        goto L_0x00de;
    L_0x01d6:
        r1 = move-exception;
        goto L_0x01c3;
    L_0x01d8:
        r1 = move-exception;
        goto L_0x01cf;
    L_0x01da:
        r0 = move-exception;
        goto L_0x01ca;
    L_0x01dc:
        r0 = move-exception;
        goto L_0x0172;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.modelvideo.t.a(java.lang.String, int, byte[]):int");
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x01d3 A:{SYNTHETIC, Splitter:B:23:0x01d3} */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x01df A:{SYNTHETIC, Splitter:B:29:0x01df} */
    public static com.tencent.mm.modelvideo.t.b m(java.lang.String r13, int r14, int r15) {
        /*
        r1 = 0;
        r12 = 50816; // 0xc680 float:7.1208E-41 double:2.51064E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r12);
        r0 = new com.tencent.mm.modelvideo.t$b;
        r0.<init>();
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r13);
        if (r2 == 0) goto L_0x003f;
    L_0x0012:
        r1 = "MicroMsg.VideoInfoStorage";
        r2 = new java.lang.StringBuilder;
        r3 = "ERR:";
        r2.<init>(r3);
        r3 = com.tencent.mm.compatible.util.g.Mq();
        r2 = r2.append(r3);
        r3 = " invalid fileName";
        r2 = r2.append(r3);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2);
        r1 = com.tencent.mm.compatible.util.g.getLine();
        r1 = 0 - r1;
        r0.ret = r1;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
    L_0x003e:
        return r0;
    L_0x003f:
        if (r14 >= 0) goto L_0x007d;
    L_0x0041:
        r1 = "MicroMsg.VideoInfoStorage";
        r2 = new java.lang.StringBuilder;
        r3 = "ERR:";
        r2.<init>(r3);
        r3 = com.tencent.mm.compatible.util.g.Mq();
        r2 = r2.append(r3);
        r3 = "[";
        r2 = r2.append(r3);
        r2 = r2.append(r13);
        r3 = "]  invalid readOffset:";
        r2 = r2.append(r3);
        r2 = r2.append(r14);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2);
        r1 = com.tencent.mm.compatible.util.g.getLine();
        r1 = 0 - r1;
        r0.ret = r1;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x003e;
    L_0x007d:
        if (r15 > 0) goto L_0x00b7;
    L_0x007f:
        r1 = "MicroMsg.VideoInfoStorage";
        r2 = new java.lang.StringBuilder;
        r3 = "ERR:";
        r2.<init>(r3);
        r3 = com.tencent.mm.compatible.util.g.Mq();
        r2 = r2.append(r3);
        r3 = "[";
        r2 = r2.append(r3);
        r2 = r2.append(r13);
        r3 = "]  invalid readLen";
        r2 = r2.append(r3);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2);
        r1 = com.tencent.mm.compatible.util.g.getLine();
        r1 = 0 - r1;
        r0.ret = r1;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x003e;
    L_0x00b7:
        r4 = new com.tencent.mm.compatible.util.g$a;
        r4.<init>();
        r3 = 0;
        r2 = new byte[r15];
        r0.buf = r2;
        r2 = new java.io.RandomAccessFile;	 Catch:{ Exception -> 0x017f, all -> 0x01db }
        r5 = "r";
        r2.<init>(r13, r5);	 Catch:{ Exception -> 0x017f, all -> 0x01db }
        r6 = r4.Mr();	 Catch:{ Exception -> 0x01ef }
        r8 = (long) r14;	 Catch:{ Exception -> 0x01ef }
        r2.seek(r8);	 Catch:{ Exception -> 0x01ef }
        r8 = r4.Mr();	 Catch:{ Exception -> 0x01ef }
        r3 = r0.buf;	 Catch:{ Exception -> 0x01ef }
        r5 = 0;
        r3 = r2.read(r3, r5, r15);	 Catch:{ Exception -> 0x01ef }
        r10 = r4.Mr();	 Catch:{ Exception -> 0x01ef }
        r4 = r4.Mr();	 Catch:{ Exception -> 0x01ef }
        if (r3 >= 0) goto L_0x01f1;
    L_0x00e6:
        r0.cqs = r1;	 Catch:{ Exception -> 0x01ef }
        r1 = r1 + r14;
        r0.fXD = r1;	 Catch:{ Exception -> 0x01ef }
        r2.close();	 Catch:{ Exception -> 0x01e6 }
    L_0x00ee:
        r1 = "MicroMsg.VideoInfoStorage";
        r2 = new java.lang.StringBuilder;
        r3 = "FIN:";
        r2.<init>(r3);
        r3 = com.tencent.mm.compatible.util.g.Mq();
        r2 = r2.append(r3);
        r3 = "[";
        r2 = r2.append(r3);
        r2 = r2.append(r13);
        r3 = "]  Offset:";
        r2 = r2.append(r3);
        r2 = r2.append(r14);
        r3 = " readlen:";
        r2 = r2.append(r3);
        r2 = r2.append(r15);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);
        r1 = "MicroMsg.VideoInfoStorage";
        r2 = new java.lang.StringBuilder;
        r3 = "FIN:";
        r2.<init>(r3);
        r3 = com.tencent.mm.compatible.util.g.Mq();
        r2 = r2.append(r3);
        r3 = "[";
        r2 = r2.append(r3);
        r2 = r2.append(r13);
        r3 = "] open:";
        r2 = r2.append(r3);
        r2 = r2.append(r6);
        r3 = " seek:";
        r2 = r2.append(r3);
        r2 = r2.append(r8);
        r3 = " write:";
        r2 = r2.append(r3);
        r2 = r2.append(r10);
        r3 = " close:";
        r2 = r2.append(r3);
        r2 = r2.append(r4);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.d(r1, r2);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x003e;
    L_0x017f:
        r1 = move-exception;
        r2 = r3;
    L_0x0181:
        r3 = "MicroMsg.VideoInfoStorage";
        r4 = new java.lang.StringBuilder;	 Catch:{ all -> 0x01ed }
        r5 = "ERR:";
        r4.<init>(r5);	 Catch:{ all -> 0x01ed }
        r5 = com.tencent.mm.compatible.util.g.Mq();	 Catch:{ all -> 0x01ed }
        r4 = r4.append(r5);	 Catch:{ all -> 0x01ed }
        r5 = "[";
        r4 = r4.append(r5);	 Catch:{ all -> 0x01ed }
        r4 = r4.append(r13);	 Catch:{ all -> 0x01ed }
        r5 = "] \t\tOffset:";
        r4 = r4.append(r5);	 Catch:{ all -> 0x01ed }
        r5 = r0.fXD;	 Catch:{ all -> 0x01ed }
        r4 = r4.append(r5);	 Catch:{ all -> 0x01ed }
        r5 = " failed:[";
        r4 = r4.append(r5);	 Catch:{ all -> 0x01ed }
        r1 = r1.getMessage();	 Catch:{ all -> 0x01ed }
        r1 = r4.append(r1);	 Catch:{ all -> 0x01ed }
        r4 = "]";
        r1 = r1.append(r4);	 Catch:{ all -> 0x01ed }
        r1 = r1.toString();	 Catch:{ all -> 0x01ed }
        com.tencent.mm.sdk.platformtools.ab.e(r3, r1);	 Catch:{ all -> 0x01ed }
        r1 = com.tencent.mm.compatible.util.g.getLine();	 Catch:{ all -> 0x01ed }
        r1 = 0 - r1;
        r0.ret = r1;	 Catch:{ all -> 0x01ed }
        if (r2 == 0) goto L_0x01d6;
    L_0x01d3:
        r2.close();	 Catch:{ Exception -> 0x01e9 }
    L_0x01d6:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x003e;
    L_0x01db:
        r0 = move-exception;
        r2 = r3;
    L_0x01dd:
        if (r2 == 0) goto L_0x01e2;
    L_0x01df:
        r2.close();	 Catch:{ Exception -> 0x01eb }
    L_0x01e2:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        throw r0;
    L_0x01e6:
        r1 = move-exception;
        goto L_0x00ee;
    L_0x01e9:
        r1 = move-exception;
        goto L_0x01d6;
    L_0x01eb:
        r1 = move-exception;
        goto L_0x01e2;
    L_0x01ed:
        r0 = move-exception;
        goto L_0x01dd;
    L_0x01ef:
        r1 = move-exception;
        goto L_0x0181;
    L_0x01f1:
        r1 = r3;
        goto L_0x00e6;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.modelvideo.t.m(java.lang.String, int, int):com.tencent.mm.modelvideo.t$b");
    }

    public static int uj(String str) {
        AppMethodBeat.i(50817);
        if (bo.isNullOrNil(str)) {
            AppMethodBeat.o(50817);
            return -1;
        }
        b bVar = new b(str);
        if (bVar.exists()) {
            int length = (int) bVar.length();
            if (length <= 0) {
                AppMethodBeat.o(50817);
                return 0;
            }
            AppMethodBeat.o(50817);
            return length;
        }
        AppMethodBeat.o(50817);
        return 0;
    }

    public final boolean s(String str, String str2, String str3) {
        AppMethodBeat.i(50818);
        boolean aW = aW(str, str2 + "##" + str3);
        AppMethodBeat.o(50818);
        return aW;
    }

    /* JADX WARNING: Removed duplicated region for block: B:26:0x00d2 A:{SYNTHETIC, Splitter:B:26:0x00d2} */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x00df A:{SYNTHETIC, Splitter:B:32:0x00df} */
    static int[] uk(java.lang.String r13) {
        /*
        r1 = 0;
        r9 = 2;
        r8 = 1;
        r12 = 50819; // 0xc683 float:7.1213E-41 double:2.5108E-319;
        r3 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r12);
        r0 = 33;
        r0 = new int[r0];
        r4 = com.tencent.mm.sdk.platformtools.bo.anU();
        r6 = com.tencent.mm.vfs.e.asZ(r13);
        r6 = (int) r6;
        r2 = 102400; // 0x19000 float:1.43493E-40 double:5.05923E-319;
        if (r6 < r2) goto L_0x0020;
    L_0x001c:
        r2 = 104857600; // 0x6400000 float:3.6111186E-35 double:5.1806538E-316;
        if (r6 < r2) goto L_0x0059;
    L_0x0020:
        r0 = "MicroMsg.VideoInfoStorage";
        r2 = "genVideoHash file size :%d , give up. :%s ";
        r4 = new java.lang.Object[r9];
        r5 = java.lang.Integer.valueOf(r6);
        r4[r3] = r5;
        r4[r8] = r13;
        com.tencent.mm.sdk.platformtools.ab.e(r0, r2, r4);
        r2 = com.tencent.mm.plugin.report.service.h.pYm;
        r4 = 12696; // 0x3198 float:1.7791E-41 double:6.2727E-320;
        r5 = new java.lang.Object[r9];
        r0 = 102400; // 0x19000 float:1.43493E-40 double:5.05923E-319;
        if (r6 >= r0) goto L_0x0056;
    L_0x003e:
        r0 = 10;
    L_0x0040:
        r0 = r0 + 101;
        r0 = java.lang.Integer.valueOf(r0);
        r5[r3] = r0;
        r0 = java.lang.Integer.valueOf(r6);
        r5[r8] = r0;
        r2.e(r4, r5);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        r0 = r1;
    L_0x0055:
        return r0;
    L_0x0056:
        r0 = 20;
        goto L_0x0040;
    L_0x0059:
        r2 = 32;
        r0[r2] = r6;
        r2 = r6 + -20480;
        r7 = r2 / 32;
        r2 = 512; // 0x200 float:7.175E-43 double:2.53E-321;
        r8 = new byte[r2];
        r2 = new java.io.RandomAccessFile;	 Catch:{ Exception -> 0x00b8, all -> 0x00db }
        r9 = "r";
        r2.<init>(r13, r9);	 Catch:{ Exception -> 0x00b8, all -> 0x00db }
    L_0x006d:
        r9 = 32;
        if (r3 >= r9) goto L_0x008d;
    L_0x0071:
        r9 = r3 * r7;
        r9 = r9 + 10240;
        r10 = (long) r9;
        r2.seek(r10);	 Catch:{ Exception -> 0x00ee }
        r2.readFully(r8);	 Catch:{ Exception -> 0x00ee }
        r9 = 512; // 0x200 float:7.175E-43 double:2.53E-321;
        r9 = com.tencent.mm.a.i.s(r8, r9);	 Catch:{ Exception -> 0x00ee }
        r10 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        r9 = r9 % r10;
        r10 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        r9 = r9 | r10;
        r0[r3] = r9;	 Catch:{ Exception -> 0x00ee }
        r3 = r3 + 1;
        goto L_0x006d;
    L_0x008d:
        r2.close();	 Catch:{ Exception -> 0x00ee }
        r3 = "MicroMsg.VideoInfoStorage";
        r7 = "genVideoHash finish time:%d size:%d path:%s";
        r8 = 3;
        r8 = new java.lang.Object[r8];	 Catch:{ Exception -> 0x00ee }
        r9 = 0;
        r4 = com.tencent.mm.sdk.platformtools.bo.gb(r4);	 Catch:{ Exception -> 0x00ee }
        r4 = java.lang.Long.valueOf(r4);	 Catch:{ Exception -> 0x00ee }
        r8[r9] = r4;	 Catch:{ Exception -> 0x00ee }
        r4 = 1;
        r5 = java.lang.Integer.valueOf(r6);	 Catch:{ Exception -> 0x00ee }
        r8[r4] = r5;	 Catch:{ Exception -> 0x00ee }
        r4 = 2;
        r8[r4] = r13;	 Catch:{ Exception -> 0x00ee }
        com.tencent.mm.sdk.platformtools.ab.i(r3, r7, r8);	 Catch:{ Exception -> 0x00ee }
        r2.close();	 Catch:{ Exception -> 0x00e6 }
    L_0x00b4:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        goto L_0x0055;
    L_0x00b8:
        r0 = move-exception;
        r2 = r1;
    L_0x00ba:
        r3 = "MicroMsg.VideoInfoStorage";
        r4 = "genVideoHash path:%s e:%s";
        r5 = 2;
        r5 = new java.lang.Object[r5];	 Catch:{ all -> 0x00ec }
        r6 = 0;
        r5[r6] = r13;	 Catch:{ all -> 0x00ec }
        r6 = 1;
        r0 = com.tencent.mm.sdk.platformtools.bo.l(r0);	 Catch:{ all -> 0x00ec }
        r5[r6] = r0;	 Catch:{ all -> 0x00ec }
        com.tencent.mm.sdk.platformtools.ab.e(r3, r4, r5);	 Catch:{ all -> 0x00ec }
        if (r2 == 0) goto L_0x00d5;
    L_0x00d2:
        r2.close();	 Catch:{ Exception -> 0x00e8 }
    L_0x00d5:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        r0 = r1;
        goto L_0x0055;
    L_0x00db:
        r0 = move-exception;
        r2 = r1;
    L_0x00dd:
        if (r2 == 0) goto L_0x00e2;
    L_0x00df:
        r2.close();	 Catch:{ Exception -> 0x00ea }
    L_0x00e2:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r12);
        throw r0;
    L_0x00e6:
        r1 = move-exception;
        goto L_0x00b4;
    L_0x00e8:
        r0 = move-exception;
        goto L_0x00d5;
    L_0x00ea:
        r1 = move-exception;
        goto L_0x00e2;
    L_0x00ec:
        r0 = move-exception;
        goto L_0x00dd;
    L_0x00ee:
        r0 = move-exception;
        goto L_0x00ba;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.modelvideo.t.uk(java.lang.String):int[]");
    }

    private boolean aW(String str, String str2) {
        AppMethodBeat.i(50820);
        ab.i("MicroMsg.VideoInfoStorage", "saveVideoHash path:%s xml:%s stack:%s", new Object[]{str, str2, bo.dpG()});
        long anU = bo.anU();
        if (bo.isNullOrNil(str) || bo.isNullOrNil(str2)) {
            ab.e("MicroMsg.VideoInfoStorage", "saveVideoHash failed , path:%s xml:%s", new Object[]{str, str2});
            AppMethodBeat.o(50820);
            return false;
        }
        int[] uk = uk(str);
        if (uk == null || uk.length < 33) {
            ab.e("MicroMsg.VideoInfoStorage", "saveVideoHash  readHash failed :%s", new Object[]{str});
            AppMethodBeat.o(50820);
            return false;
        }
        int i = uk[32];
        StringBuffer stringBuffer = new StringBuffer();
        for (int i2 = 0; i2 < 32; i2++) {
            stringBuffer.append(Integer.toHexString(uk[i2]));
        }
        Cursor a = this.fni.a("select cdnxml from VideoHash where size = " + i + " and hash = \"" + stringBuffer.toString() + "\"", null, 2);
        Vector vector = new Vector();
        while (a.moveToNext()) {
            vector.add(a.getString(0));
            ab.v("MicroMsg.VideoInfoStorage", "saveVideoHash index:%s get:%s", new Object[]{Integer.valueOf(vector.size()), vector.get(vector.size() - 1)});
        }
        a.close();
        if (vector.size() == 1 && str2.equals(vector.get(0))) {
            ab.w("MicroMsg.VideoInfoStorage", "saveVideoHash Check exist now return,time:%d,  path:%s xml:%s", new Object[]{Long.valueOf(bo.gb(anU)), str, str2});
            AppMethodBeat.o(50820);
            return true;
        }
        if (vector.size() > 0) {
            com.tencent.mm.plugin.report.service.h.pYm.e(12696, new Object[]{Integer.valueOf(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_EXTRA_SUBTITLE_INDEX), Integer.valueOf(i), BuildConfig.FLAVOR, BuildConfig.FLAVOR, Integer.valueOf(vector.size())});
            ab.e("MicroMsg.VideoInfoStorage", "saveVideoHash Err Check  xml diff OR  select more than one row,  rowCount:%d size:%d ", new Object[]{Integer.valueOf(vector.size()), Integer.valueOf(i)});
            this.fni.hY("VideoHash", "delete from VideoHash where size = " + i + " and hash = \"" + stringBuffer.toString() + "\"");
        }
        ContentValues contentValues = new ContentValues();
        contentValues.put("size", Integer.valueOf(i));
        contentValues.put("CreateTime", Long.valueOf(bo.anT()));
        contentValues.put("hash", stringBuffer.toString());
        contentValues.put("cdnxml", str2);
        contentValues.put("orgpath", str);
        ab.i("MicroMsg.VideoInfoStorage", "summersafecdn saveVideoHash time:%d insert:%d path:%s hash:%s xml:%s", new Object[]{Long.valueOf(bo.gb(anU)), Long.valueOf(this.fni.insert("VideoHash", BuildConfig.FLAVOR, contentValues)), str, stringBuffer, str2});
        if (this.fni.insert("VideoHash", BuildConfig.FLAVOR, contentValues) < 0) {
            com.tencent.mm.plugin.report.service.h.pYm.e(12696, new Object[]{Integer.valueOf(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_EXTRA_AUDIOTRACK_TITLES), Integer.valueOf(i)});
            ab.e("MicroMsg.VideoInfoStorage", "saveVideoHash insert failed :%d  path:%s", new Object[]{Long.valueOf(r0), str});
        }
        AppMethodBeat.o(50820);
        return true;
    }
}
