package com.tencent.mm.plugin.appbrand.appcache;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.appbrand.a.d;
import com.tencent.mm.plugin.appbrand.appcache.a.b$a$a;
import com.tencent.mm.plugin.appbrand.appcache.az.a;
import com.tencent.mm.pluginsdk.g.a.c.m;
import com.tencent.mm.sdk.platformtools.ab;

public final class bd {
    public static boolean a(String str, String str2, int i, int i2, a aVar) {
        AppMethodBeat.i(59550);
        boolean a = az.a(new bc(str, str2, i, i2, aVar), aVar);
        AppMethodBeat.o(59550);
        return a;
    }

    public static void a(bc bcVar, m mVar, z.a aVar) {
        AppMethodBeat.i(59551);
        ab.e("MicroMsg.AppBrand.ZstdLogic", "onZstdPkgDownloadFail, request(%s %d)", new Object[]{bcVar.appId, Integer.valueOf(bcVar.gVu)});
        aVar.a(mVar);
        ax xF = ((d) g.K(d.class)).xF();
        if (xF == null) {
            ab.e("MicroMsg.AppBrand.ZstdLogic", "onIncrementalPkgDownloadFail, before fallback full_pkg, nil storage");
            az.a(bcVar.vdC, bcVar.appId, b$a$a.ENV_ERR, null);
            AppMethodBeat.o(59551);
            return;
        }
        az.xJ(bcVar.vdC);
        at a = xF.a(bcVar.appId, bcVar.gVu, bcVar.cBc, new String[]{"downloadURL"});
        if (a == null) {
            ab.e("MicroMsg.AppBrand.ZstdLogic", "onIncrementalPkgDownloadFail, before fallback full_pkg, nil record(%s %d)", new Object[]{bcVar.appId, Integer.valueOf(bcVar.gVu)});
            AppMethodBeat.o(59551);
            return;
        }
        az.b(bcVar.appId, bcVar.cBc, bcVar.gVu, a.field_downloadURL, bcVar.gTR);
        AppMethodBeat.o(59551);
    }

    /* JADX WARNING: Removed duplicated region for block: B:39:0x009d A:{SYNTHETIC, Splitter:B:39:0x009d} */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x00a2 A:{SYNTHETIC, Splitter:B:42:0x00a2} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x007b A:{SYNTHETIC, Splitter:B:23:0x007b} */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x0080 A:{SYNTHETIC, Splitter:B:26:0x0080} */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x007b A:{SYNTHETIC, Splitter:B:23:0x007b} */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x0080 A:{SYNTHETIC, Splitter:B:26:0x0080} */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x009d A:{SYNTHETIC, Splitter:B:39:0x009d} */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x00a2 A:{SYNTHETIC, Splitter:B:42:0x00a2} */
    static boolean a(com.tencent.mm.plugin.appbrand.appcache.bc r9) {
        /*
        r3 = 0;
        r1 = 1;
        r8 = 59552; // 0xe8a0 float:8.345E-41 double:2.94226E-319;
        r0 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r8);
        r5 = r9.getFilePath();
        r2 = new java.io.File;
        r2.<init>(r5);
        r4 = r2.exists();
        if (r4 != 0) goto L_0x0025;
    L_0x0018:
        r1 = "MicroMsg.AppBrand.ZstdLogic";
        r2 = "mayProcessZstd downloadFile not exists";
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
    L_0x0024:
        return r0;
    L_0x0025:
        r6 = new java.io.File;
        r4 = r9.aws();
        r6.<init>(r4);
        r4 = r6.exists();
        if (r4 == 0) goto L_0x0047;
    L_0x0034:
        r4 = r6.delete();
        if (r4 != 0) goto L_0x0047;
    L_0x003a:
        r1 = "MicroMsg.AppBrand.ZstdLogic";
        r2 = "mayProcessZstd targetFile delete failed";
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        goto L_0x0024;
    L_0x0047:
        r4 = new com.tencent.mars.zstd.ZstdInputStream;	 Catch:{ Exception -> 0x00ba, all -> 0x0098 }
        r7 = new java.io.FileInputStream;	 Catch:{ Exception -> 0x00ba, all -> 0x0098 }
        r7.<init>(r2);	 Catch:{ Exception -> 0x00ba, all -> 0x0098 }
        r4.<init>(r7);	 Catch:{ Exception -> 0x00ba, all -> 0x0098 }
        r2 = new java.io.FileOutputStream;	 Catch:{ Exception -> 0x00be, all -> 0x00b5 }
        r2.<init>(r6);	 Catch:{ Exception -> 0x00be, all -> 0x00b5 }
        r3 = 8192; // 0x2000 float:1.14794E-41 double:4.0474E-320;
        r3 = new byte[r3];	 Catch:{ Exception -> 0x0069 }
    L_0x005a:
        r6 = 0;
        r7 = 8192; // 0x2000 float:1.14794E-41 double:4.0474E-320;
        r6 = r4.read(r3, r6, r7);	 Catch:{ Exception -> 0x0069 }
        r7 = -1;
        if (r6 == r7) goto L_0x0087;
    L_0x0064:
        r7 = 0;
        r2.write(r3, r7, r6);	 Catch:{ Exception -> 0x0069 }
        goto L_0x005a;
    L_0x0069:
        r1 = move-exception;
    L_0x006a:
        r3 = "MicroMsg.AppBrand.ZstdLogic";
        r5 = "mayProcessZstd exp: %s";
        r6 = 1;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x00b8 }
        r7 = 0;
        r6[r7] = r1;	 Catch:{ all -> 0x00b8 }
        com.tencent.mm.sdk.platformtools.ab.e(r3, r5, r6);	 Catch:{ all -> 0x00b8 }
        if (r2 == 0) goto L_0x007e;
    L_0x007b:
        r2.close();	 Catch:{ IOException -> 0x00ad }
    L_0x007e:
        if (r4 == 0) goto L_0x0083;
    L_0x0080:
        r4.close();	 Catch:{ IOException -> 0x00af }
    L_0x0083:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        goto L_0x0024;
    L_0x0087:
        r2.flush();	 Catch:{ Exception -> 0x0069 }
        com.tencent.mm.vfs.e.deleteFile(r5);	 Catch:{ Exception -> 0x0069 }
        r2.close();	 Catch:{ IOException -> 0x00a9 }
    L_0x0090:
        r4.close();	 Catch:{ IOException -> 0x00ab }
    L_0x0093:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        r0 = r1;
        goto L_0x0024;
    L_0x0098:
        r0 = move-exception;
        r2 = r3;
        r4 = r3;
    L_0x009b:
        if (r2 == 0) goto L_0x00a0;
    L_0x009d:
        r2.close();	 Catch:{ IOException -> 0x00b1 }
    L_0x00a0:
        if (r4 == 0) goto L_0x00a5;
    L_0x00a2:
        r4.close();	 Catch:{ IOException -> 0x00b3 }
    L_0x00a5:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        throw r0;
    L_0x00a9:
        r0 = move-exception;
        goto L_0x0090;
    L_0x00ab:
        r0 = move-exception;
        goto L_0x0093;
    L_0x00ad:
        r1 = move-exception;
        goto L_0x007e;
    L_0x00af:
        r1 = move-exception;
        goto L_0x0083;
    L_0x00b1:
        r1 = move-exception;
        goto L_0x00a0;
    L_0x00b3:
        r1 = move-exception;
        goto L_0x00a5;
    L_0x00b5:
        r0 = move-exception;
        r2 = r3;
        goto L_0x009b;
    L_0x00b8:
        r0 = move-exception;
        goto L_0x009b;
    L_0x00ba:
        r1 = move-exception;
        r2 = r3;
        r4 = r3;
        goto L_0x006a;
    L_0x00be:
        r1 = move-exception;
        r2 = r3;
        goto L_0x006a;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.appbrand.appcache.bd.a(com.tencent.mm.plugin.appbrand.appcache.bc):boolean");
    }
}
