package com.tencent.mm.plugin.wepkg.downloader;

import android.text.TextUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import java.net.HttpURLConnection;
import java.util.concurrent.Future;
import javax.net.ssl.SSLContext;

public final class c implements Runnable {
    private String mContentType;
    private int mStatusCode;
    private int retCode = 0;
    f uVO;
    Future<?> uVP;
    HttpURLConnection uVQ;
    private String uVR;
    private String uVS;
    private String uVT;
    boolean uVU;
    private boolean uVV;
    private boolean uVW = false;

    public c(f fVar) {
        this.uVO = fVar;
    }

    /* JADX WARNING: Removed duplicated region for block: B:63:0x01e2  */
    public final void run() {
        /*
        r15 = this;
        r6 = -1;
        r14 = 1013; // 0x3f5 float:1.42E-42 double:5.005E-321;
        r13 = 63421; // 0xf7bd float:8.8872E-41 double:3.1334E-319;
        r7 = 1;
        r8 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r13);
        r0 = r15.uVO;
        if (r0 != 0) goto L_0x0013;
    L_0x000f:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
    L_0x0012:
        return;
    L_0x0013:
        r0 = r15.uVO;
        r0 = r0.mUrl;
        if (r0 != 0) goto L_0x001d;
    L_0x0019:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        goto L_0x0012;
    L_0x001d:
        r0 = r15.uVO;
        r9 = r0.lqQ;
        r5 = r8;
    L_0x0022:
        r1 = new java.net.URL;	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r0 = r0.mUrl;	 Catch:{ Exception -> 0x018f }
        r1.<init>(r0);	 Catch:{ Exception -> 0x018f }
        r0 = r1.openConnection();	 Catch:{ Exception -> 0x018f }
        r0 = (java.net.HttpURLConnection) r0;	 Catch:{ Exception -> 0x018f }
        r15.uVQ = r0;	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r2 = r2.uWu;	 Catch:{ Exception -> 0x018f }
        r0.setConnectTimeout(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r2 = r2.uWv;	 Catch:{ Exception -> 0x018f }
        r0.setReadTimeout(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = 0;
        r0.setUseCaches(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = 1;
        r0.setDoInput(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = "GET";
        r0.setRequestMethod(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = 0;
        r0.setDoOutput(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = 1;
        r0.setInstanceFollowRedirects(r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r2 = "Accept-Encoding";
        r3 = "gzip, deflate";
        r0.setRequestProperty(r2, r3);	 Catch:{ Exception -> 0x018f }
        r0 = "http.agent";
        r0 = java.lang.System.getProperty(r0);	 Catch:{ Exception -> 0x018f }
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r0);	 Catch:{ Exception -> 0x018f }
        if (r2 != 0) goto L_0x0085;
    L_0x007d:
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r3 = "User-agent";
        r2.setRequestProperty(r3, r0);	 Catch:{ Exception -> 0x018f }
    L_0x0085:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r0 = r0.uWw;	 Catch:{ Exception -> 0x018f }
        if (r0 == 0) goto L_0x0186;
    L_0x008b:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r0 = r0.mFilePath;	 Catch:{ Exception -> 0x018f }
        r2 = com.tencent.mm.pluginsdk.g.a.d.a.ek(r0);	 Catch:{ Exception -> 0x018f }
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r4 = "%s: RangeOffset = %d";
        r10 = 2;
        r10 = new java.lang.Object[r10];	 Catch:{ Exception -> 0x018f }
        r11 = 0;
        r12 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r12 = r12.uWo;	 Catch:{ Exception -> 0x018f }
        r10[r11] = r12;	 Catch:{ Exception -> 0x018f }
        r11 = 1;
        r12 = java.lang.Long.valueOf(r2);	 Catch:{ Exception -> 0x018f }
        r10[r11] = r12;	 Catch:{ Exception -> 0x018f }
        com.tencent.mm.sdk.platformtools.ab.i(r0, r4, r10);	 Catch:{ Exception -> 0x018f }
        r10 = 0;
        r0 = (r2 > r10 ? 1 : (r2 == r10 ? 0 : -1));
        if (r0 != 0) goto L_0x0164;
    L_0x00b3:
        r0 = r8;
    L_0x00b4:
        r15.uVV = r0;	 Catch:{ Exception -> 0x018f }
    L_0x00b6:
        r0 = "https";
        r1 = r1.getProtocol();	 Catch:{ Exception -> 0x018f }
        r0 = r0.equalsIgnoreCase(r1);	 Catch:{ Exception -> 0x018f }
        if (r0 == 0) goto L_0x00f4;
    L_0x00c3:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r2 = r0.uWu;	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r0 = (javax.net.ssl.HttpsURLConnection) r0;	 Catch:{ Exception -> 0x018f }
        r1 = "TLSv1.2";
        r1 = ahL(r1);	 Catch:{ Exception -> 0x018f }
        if (r1 != 0) goto L_0x00e1;
    L_0x00d4:
        r1 = "TLSv1";
        r1 = ahL(r1);	 Catch:{ Exception -> 0x018f }
        if (r1 != 0) goto L_0x00e1;
    L_0x00dd:
        r1 = javax.net.ssl.SSLContext.getDefault();	 Catch:{ Exception -> 0x02db }
    L_0x00e1:
        if (r1 == 0) goto L_0x01fe;
    L_0x00e3:
        r3 = 0;
        r4 = 0;
        r10 = new java.security.SecureRandom;	 Catch:{ Exception -> 0x01fd }
        r10.<init>();	 Catch:{ Exception -> 0x01fd }
        r1.init(r3, r4, r10);	 Catch:{ Exception -> 0x01fd }
        r1 = r1.getSocketFactory();	 Catch:{ Exception -> 0x01fd }
        r0.setSSLSocketFactory(r1);	 Catch:{ Exception -> 0x01fd }
    L_0x00f4:
        r15.dgv();	 Catch:{ Exception -> 0x018f }
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "handle responose retcode:%s";
        r2 = 1;
        r2 = new java.lang.Object[r2];	 Catch:{ Exception -> 0x018f }
        r3 = 0;
        r4 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r4 = java.lang.Integer.valueOf(r4);	 Catch:{ Exception -> 0x018f }
        r2[r3] = r4;	 Catch:{ Exception -> 0x018f }
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1, r2);	 Catch:{ Exception -> 0x018f }
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        if (r0 != 0) goto L_0x024c;
    L_0x0110:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r0 = r0.uWx;	 Catch:{ Exception -> 0x018f }
        if (r0 == 0) goto L_0x02a1;
    L_0x0116:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r10 = r0.uWx;	 Catch:{ Exception -> 0x018f }
        r0 = new com.tencent.mm.plugin.wepkg.downloader.g;	 Catch:{ Exception -> 0x018f }
        r1 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r2 = 1;
        r3 = 0;
        r4 = r15.uVW;	 Catch:{ Exception -> 0x018f }
        if (r4 == 0) goto L_0x0249;
    L_0x0124:
        r4 = r7;
    L_0x0125:
        r0.<init>(r1, r2, r3, r4, r5);	 Catch:{ Exception -> 0x018f }
        r10.a(r0);	 Catch:{ Exception -> 0x018f }
        r0 = r15.uVO;
        r0 = r0.mUrl;
        r1 = "https";
        r0 = r0.startsWith(r1);
        if (r0 == 0) goto L_0x015f;
    L_0x0138:
        r0 = r15.retCode;
        if (r0 != r14) goto L_0x015f;
    L_0x013c:
        r0 = r9 + -1;
        if (r5 < r0) goto L_0x015f;
    L_0x0140:
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "change https to http request";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r15.uVO;
        r1 = r15.uVO;
        r1 = r1.mUrl;
        r2 = "https";
        r3 = "http";
        r1 = r1.replaceFirst(r2, r3);
        r0.mUrl = r1;
        r15.retCode = r8;
        r15.uVW = r8;
    L_0x015f:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        goto L_0x0012;
    L_0x0164:
        r0 = r15.uVQ;	 Catch:{ Exception -> 0x018f }
        r4 = "Range";
        r10 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x018f }
        r11 = "bytes=";
        r10.<init>(r11);	 Catch:{ Exception -> 0x018f }
        r2 = r10.append(r2);	 Catch:{ Exception -> 0x018f }
        r3 = "-";
        r2 = r2.append(r3);	 Catch:{ Exception -> 0x018f }
        r2 = r2.toString();	 Catch:{ Exception -> 0x018f }
        r0.addRequestProperty(r4, r2);	 Catch:{ Exception -> 0x018f }
        r0 = r7;
        goto L_0x00b4;
    L_0x0186:
        r0 = r15.uVO;	 Catch:{ Exception -> 0x018f }
        r0 = r0.mFilePath;	 Catch:{ Exception -> 0x018f }
        com.tencent.mm.pluginsdk.g.a.d.a.ajj(r0);	 Catch:{ Exception -> 0x018f }
        goto L_0x00b6;
    L_0x018f:
        r0 = move-exception;
        r1 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r2 = "run exception : %s";
        r3 = 1;
        r3 = new java.lang.Object[r3];	 Catch:{ all -> 0x0210 }
        r4 = 0;
        r0 = r0.getMessage();	 Catch:{ all -> 0x0210 }
        r3[r4] = r0;	 Catch:{ all -> 0x0210 }
        com.tencent.mm.sdk.platformtools.ab.e(r1, r2, r3);	 Catch:{ all -> 0x0210 }
        r0 = r15.uVO;
        r0 = r0.mUrl;
        r1 = "https";
        r0 = r0.startsWith(r1);
        if (r0 == 0) goto L_0x01d8;
    L_0x01b0:
        r0 = r15.retCode;
        if (r0 != r14) goto L_0x01d8;
    L_0x01b4:
        r0 = r9 + -1;
        if (r5 < r0) goto L_0x01d8;
    L_0x01b8:
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "change https to http request";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r15.uVO;
        r1 = r15.uVO;
        r1 = r1.mUrl;
        r2 = "https";
        r3 = "http";
        r1 = r1.replaceFirst(r2, r3);
        r0.mUrl = r1;
        r15.retCode = r8;
        r15.uVW = r8;
        r5 = r6;
    L_0x01d8:
        r5 = r5 + 1;
        if (r5 < r9) goto L_0x0022;
    L_0x01dc:
        r0 = r15.uVO;
        r0 = r0.uWx;
        if (r0 == 0) goto L_0x01f8;
    L_0x01e2:
        r0 = r15.uVO;
        r6 = r0.uWx;
        r0 = new com.tencent.mm.plugin.wepkg.downloader.g;
        r1 = r15.uVO;
        r2 = 2;
        r3 = r15.retCode;
        r4 = r15.uVW;
        if (r4 == 0) goto L_0x02d8;
    L_0x01f1:
        r4 = r7;
    L_0x01f2:
        r0.<init>(r1, r2, r3, r4, r5);
        r6.a(r0);
    L_0x01f8:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        goto L_0x0012;
    L_0x01fd:
        r1 = move-exception;
    L_0x01fe:
        r1 = new android.net.SSLSessionCache;	 Catch:{ Exception -> 0x018f }
        r3 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x018f }
        r1.<init>(r3);	 Catch:{ Exception -> 0x018f }
        r1 = android.net.SSLCertificateSocketFactory.getDefault(r2, r1);	 Catch:{ Exception -> 0x018f }
        r0.setSSLSocketFactory(r1);	 Catch:{ Exception -> 0x018f }
        goto L_0x00f4;
    L_0x0210:
        r0 = move-exception;
        r1 = r15.uVO;
        r1 = r1.mUrl;
        r2 = "https";
        r1 = r1.startsWith(r2);
        if (r1 == 0) goto L_0x0245;
    L_0x021e:
        r1 = r15.retCode;
        if (r1 != r14) goto L_0x0245;
    L_0x0222:
        r1 = r9 + -1;
        if (r5 < r1) goto L_0x0245;
    L_0x0226:
        r1 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r2 = "change https to http request";
        com.tencent.mm.sdk.platformtools.ab.i(r1, r2);
        r1 = r15.uVO;
        r2 = r15.uVO;
        r2 = r2.mUrl;
        r3 = "https";
        r4 = "http";
        r2 = r2.replaceFirst(r3, r4);
        r1.mUrl = r2;
        r15.retCode = r8;
        r15.uVW = r8;
    L_0x0245:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r13);
        throw r0;
    L_0x0249:
        r4 = r8;
        goto L_0x0125;
    L_0x024c:
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r1 = 1011; // 0x3f3 float:1.417E-42 double:4.995E-321;
        if (r0 == r1) goto L_0x026a;
    L_0x0252:
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r1 = 1001; // 0x3e9 float:1.403E-42 double:4.946E-321;
        if (r0 == r1) goto L_0x026a;
    L_0x0258:
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r1 = 1009; // 0x3f1 float:1.414E-42 double:4.985E-321;
        if (r0 == r1) goto L_0x026a;
    L_0x025e:
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r1 = 1002; // 0x3ea float:1.404E-42 double:4.95E-321;
        if (r0 == r1) goto L_0x026a;
    L_0x0264:
        r0 = r15.retCode;	 Catch:{ Exception -> 0x018f }
        r1 = 1007; // 0x3ef float:1.411E-42 double:4.975E-321;
        if (r0 != r1) goto L_0x02a1;
    L_0x026a:
        r0 = r15.uVO;
        r0 = r0.mUrl;
        r1 = "https";
        r0 = r0.startsWith(r1);
        if (r0 == 0) goto L_0x01dc;
    L_0x0277:
        r0 = r15.retCode;
        if (r0 != r14) goto L_0x01dc;
    L_0x027b:
        r0 = r9 + -1;
        if (r5 < r0) goto L_0x01dc;
    L_0x027f:
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "change https to http request";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r15.uVO;
        r1 = r15.uVO;
        r1 = r1.mUrl;
        r2 = "https";
        r3 = "http";
        r1 = r1.replaceFirst(r2, r3);
        r0.mUrl = r1;
        r15.retCode = r8;
        r15.uVW = r8;
        r5 = r6;
        goto L_0x01dc;
    L_0x02a1:
        r0 = r15.uVO;
        r0 = r0.mUrl;
        r1 = "https";
        r0 = r0.startsWith(r1);
        if (r0 == 0) goto L_0x01d8;
    L_0x02ae:
        r0 = r15.retCode;
        if (r0 != r14) goto L_0x01d8;
    L_0x02b2:
        r0 = r9 + -1;
        if (r5 < r0) goto L_0x01d8;
    L_0x02b6:
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "change https to http request";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r1);
        r0 = r15.uVO;
        r1 = r15.uVO;
        r1 = r1.mUrl;
        r2 = "https";
        r3 = "http";
        r1 = r1.replaceFirst(r2, r3);
        r0.mUrl = r1;
        r15.retCode = r8;
        r15.uVW = r8;
        r5 = r6;
        goto L_0x01d8;
    L_0x02d8:
        r4 = r8;
        goto L_0x01f2;
    L_0x02db:
        r3 = move-exception;
        goto L_0x00e1;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.wepkg.downloader.c.run():void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:63:0x0251 A:{SYNTHETIC, Splitter:B:63:0x0251} */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x01ad A:{Catch:{ all -> 0x0261 }} */
    /* JADX WARNING: Missing block: B:6:0x0038, code skipped:
            com.tencent.mm.pluginsdk.g.a.d.a.e(r2);
            com.tencent.mm.pluginsdk.g.a.d.a.e(r0);
            com.tencent.matrix.trace.core.AppMethodBeat.o(63422);
     */
    /* JADX WARNING: Missing block: B:105:?, code skipped:
            return;
     */
    private void dgv() {
        /*
        r15 = this;
        r14 = 63422; // 0xf7be float:8.8873E-41 double:3.13346E-319;
        r4 = 1;
        r3 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r14);
        r1 = 0;
        r0 = 0;
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r2.getResponseCode();	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.mStatusCode = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r5 = "%s: received status code = %d";
        r6 = 2;
        r6 = new java.lang.Object[r6];	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r7 = 0;
        r8 = r15.uVO;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r8 = r8.uWo;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6[r7] = r8;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r7 = 1;
        r8 = r15.mStatusCode;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6[r7] = r8;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r5, r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.mStatusCode;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        switch(r2) {
            case 200: goto L_0x0042;
            case 206: goto L_0x0042;
            default: goto L_0x0033;
        };	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
    L_0x0033:
        r2 = r15.mStatusCode;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.retCode = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r1;
    L_0x0038:
        com.tencent.mm.pluginsdk.g.a.d.a.e(r2);
        com.tencent.mm.pluginsdk.g.a.d.a.e(r0);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r14);
    L_0x0041:
        return;
    L_0x0042:
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = "Content-Type";
        r2 = r2.getHeaderField(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.mContentType = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2.getHeaderFields();	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = "Content-Range";
        r2 = r2.getHeaderField(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.uVR = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = "Content-Length";
        r2 = r2.getHeaderField(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.uVS = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = "bytes";
        r6 = "Accept-Ranges";
        r2 = r2.getHeaderField(r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r5.equals(r2);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r2 == 0) goto L_0x00d0;
    L_0x007a:
        r2 = r4;
    L_0x007b:
        r5 = r15.uVV;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r5 == 0) goto L_0x0108;
    L_0x007f:
        if (r2 != 0) goto L_0x00e3;
    L_0x0081:
        r5 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r6 = "Header no Accept-Ranges, not support range";
        com.tencent.mm.sdk.platformtools.ab.i(r5, r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r15.uVO;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r5.mFilePath;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        com.tencent.mm.pluginsdk.g.a.d.a.ajj(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r15.uVS;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6 = ahN(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r2;
    L_0x0098:
        r15.uVW = r5;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r8 = "%s: content-range = %s, content-length = %s, content-type = %s, isSupportRange = %b";
        r9 = 5;
        r9 = new java.lang.Object[r9];	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 0;
        r11 = r15.uVO;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r11 = r11.uWo;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 1;
        r11 = r15.uVR;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 2;
        r11 = r15.uVS;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 3;
        r11 = r15.mContentType;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 4;
        r11 = java.lang.Boolean.valueOf(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r8, r9);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r8 = -1;
        r2 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r2 != 0) goto L_0x0119;
    L_0x00c9:
        r2 = 1010; // 0x3f2 float:1.415E-42 double:4.99E-321;
        r15.retCode = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r1;
        goto L_0x0038;
    L_0x00d0:
        r2 = r15.uVR;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r2 == 0) goto L_0x00e1;
    L_0x00d4:
        r2 = r15.uVR;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = "bytes";
        r2 = r2.startsWith(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r2 == 0) goto L_0x00e1;
    L_0x00df:
        r2 = r4;
        goto L_0x007b;
    L_0x00e1:
        r2 = r3;
        goto L_0x007b;
    L_0x00e3:
        r5 = r15.uVR;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = ahM(r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6 = (long) r5;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r8 = -1;
        r5 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r5 != 0) goto L_0x02b8;
    L_0x00f0:
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r5 = "content-range in header is error, not support range";
        com.tencent.mm.sdk.platformtools.ab.i(r2, r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVO;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r2.mFilePath;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        com.tencent.mm.pluginsdk.g.a.d.a.ajj(r2);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVS;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6 = ahN(r2);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r3;
        goto L_0x0098;
    L_0x0108:
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r5 = "local dont have download file. not support range";
        com.tencent.mm.sdk.platformtools.ab.i(r2, r5);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVS;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6 = ahN(r2);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r5 = r3;
        goto L_0x0098;
    L_0x0119:
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r8 = "ServerLength(%d) and HeaderLength(%d)";
        r9 = 2;
        r9 = new java.lang.Object[r9];	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 0;
        r11 = r15.uVO;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r12 = r11.uWs;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r11 = java.lang.Long.valueOf(r12);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r11;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r10 = 1;
        r6 = java.lang.Long.valueOf(r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r9[r10] = r6;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r8, r9);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r2.getContentEncoding();	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r15.uVT = r2;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVQ;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r6 = r2.getInputStream();	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = r15.uVT;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r2);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r2 != 0) goto L_0x01cf;
    L_0x014d:
        r2 = r15.uVT;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r7 = "gzip";
        r2 = r2.contains(r7);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        if (r2 == 0) goto L_0x01cf;
    L_0x0158:
        r2 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r7 = "Content encoding is gzip";
        com.tencent.mm.sdk.platformtools.ab.i(r2, r7);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2 = new java.util.zip.GZIPInputStream;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2.<init>(r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
    L_0x0166:
        r1 = r15.uVO;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r6 = r1.mFilePath;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r1 = r15.uVO;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r1 = r1.uWo;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r7 = r15.uVV;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        if (r7 == 0) goto L_0x01da;
    L_0x0172:
        if (r5 == 0) goto L_0x01da;
    L_0x0174:
        r7 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r8 = "%s: getOutputStream, filePath %s";
        r9 = 2;
        r9 = new java.lang.Object[r9];	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r10 = 0;
        r9[r10] = r1;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r10 = 1;
        r9[r10] = r6;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        com.tencent.mm.sdk.platformtools.ab.d(r7, r8, r9);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r7 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r6);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        if (r7 == 0) goto L_0x01dc;
    L_0x018c:
        r3 = new java.io.FileNotFoundException;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r4 = "%s filePath is null or nil";
        r5 = 1;
        r5 = new java.lang.Object[r5];	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r6 = 0;
        r5[r6] = r1;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r1 = java.lang.String.format(r4, r5);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r3.<init>(r1);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r1 = 63422; // 0xf7be float:8.8873E-41 double:3.13346E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r1);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        throw r3;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
    L_0x01a5:
        r1 = move-exception;
        r3 = r1;
        r4 = r0;
        r5 = r2;
    L_0x01a9:
        r0 = r15.uVU;	 Catch:{ all -> 0x0261 }
        if (r0 == 0) goto L_0x0251;
    L_0x01ad:
        r0 = 1001; // 0x3e9 float:1.403E-42 double:4.946E-321;
        r15.retCode = r0;	 Catch:{ all -> 0x0261 }
    L_0x01b1:
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r1 = "exception : %s";
        r2 = 1;
        r2 = new java.lang.Object[r2];	 Catch:{ all -> 0x0261 }
        r6 = 0;
        r3 = r3.getMessage();	 Catch:{ all -> 0x0261 }
        r2[r6] = r3;	 Catch:{ all -> 0x0261 }
        com.tencent.mm.sdk.platformtools.ab.e(r0, r1, r2);	 Catch:{ all -> 0x0261 }
        com.tencent.mm.pluginsdk.g.a.d.a.e(r5);
        com.tencent.mm.pluginsdk.g.a.d.a.e(r4);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r14);
        goto L_0x0041;
    L_0x01cf:
        r2 = new java.io.BufferedInputStream;	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        r2.<init>(r6);	 Catch:{ Exception -> 0x01d5, all -> 0x02a3 }
        goto L_0x0166;
    L_0x01d5:
        r2 = move-exception;
        r3 = r2;
        r4 = r0;
        r5 = r1;
        goto L_0x01a9;
    L_0x01da:
        r4 = r3;
        goto L_0x0174;
    L_0x01dc:
        r1 = new java.io.BufferedOutputStream;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r7 = new java.io.FileOutputStream;	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r7.<init>(r6, r4);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r1.<init>(r7);	 Catch:{ Exception -> 0x01a5, all -> 0x02a8 }
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r4 = "%s: append = %b, isSupportRange = %s";
        r6 = 3;
        r6 = new java.lang.Object[r6];	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r7 = 0;
        r8 = r15.uVO;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r8 = r8.uWo;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r7 = 1;
        r8 = r15.uVV;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r8 = java.lang.Boolean.valueOf(r8);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6[r7] = r8;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r7 = 2;
        r5 = java.lang.Boolean.valueOf(r5);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6[r7] = r5;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        com.tencent.mm.sdk.platformtools.ab.i(r0, r4, r6);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r0 = 4096; // 0x1000 float:5.74E-42 double:2.0237E-320;
        r4 = new byte[r0];	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r0 = r3;
    L_0x020e:
        r3 = 0;
        r5 = 4096; // 0x1000 float:5.74E-42 double:2.0237E-320;
        r3 = r2.read(r4, r3, r5);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r5 = -1;
        if (r3 == r5) goto L_0x021e;
    L_0x0218:
        r5 = 0;
        r1.write(r4, r5, r3);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r0 = r0 + r3;
        goto L_0x020e;
    L_0x021e:
        r3 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r4 = "%s: read count = %d";
        r5 = 2;
        r5 = new java.lang.Object[r5];	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6 = 0;
        r7 = r15.uVO;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r7 = r7.mUrl;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r5[r6] = r7;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6 = 1;
        r0 = java.lang.Integer.valueOf(r0);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r5[r6] = r0;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        com.tencent.mm.sdk.platformtools.ab.i(r3, r4, r5);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r1.flush();	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r0 = "MicroMsg.Wepkg.WePkgDownloadTask";
        r3 = "%s: download complete, flush and send complete status";
        r4 = 1;
        r4 = new java.lang.Object[r4];	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r5 = 0;
        r6 = r15.uVO;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r6 = r6.mUrl;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r4[r5] = r6;	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        com.tencent.mm.sdk.platformtools.ab.i(r0, r3, r4);	 Catch:{ Exception -> 0x02b2, all -> 0x02ad }
        r0 = r1;
        goto L_0x0038;
    L_0x0251:
        r0 = com.tencent.mm.kernel.g.Rg();	 Catch:{ all -> 0x0261 }
        r0 = r0.acS();	 Catch:{ all -> 0x0261 }
        if (r0 != 0) goto L_0x026d;
    L_0x025b:
        r0 = 1002; // 0x3ea float:1.404E-42 double:4.95E-321;
        r15.retCode = r0;	 Catch:{ all -> 0x0261 }
        goto L_0x01b1;
    L_0x0261:
        r0 = move-exception;
        r3 = r0;
    L_0x0263:
        com.tencent.mm.pluginsdk.g.a.d.a.e(r5);
        com.tencent.mm.pluginsdk.g.a.d.a.e(r4);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r14);
        throw r3;
    L_0x026d:
        r0 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r1 = r3 instanceof javax.net.ssl.SSLException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x0279;
    L_0x0273:
        r0 = 1013; // 0x3f5 float:1.42E-42 double:5.005E-321;
    L_0x0275:
        r15.retCode = r0;	 Catch:{ all -> 0x0261 }
        goto L_0x01b1;
    L_0x0279:
        r1 = r3 instanceof java.net.SocketTimeoutException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x0280;
    L_0x027d:
        r0 = 1003; // 0x3eb float:1.406E-42 double:4.955E-321;
        goto L_0x0275;
    L_0x0280:
        r1 = r3 instanceof java.net.UnknownHostException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x0287;
    L_0x0284:
        r0 = 1004; // 0x3ec float:1.407E-42 double:4.96E-321;
        goto L_0x0275;
    L_0x0287:
        r1 = r3 instanceof java.net.ConnectException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x028e;
    L_0x028b:
        r0 = 1005; // 0x3ed float:1.408E-42 double:4.965E-321;
        goto L_0x0275;
    L_0x028e:
        r1 = r3 instanceof java.net.SocketException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x0295;
    L_0x0292:
        r0 = 1006; // 0x3ee float:1.41E-42 double:4.97E-321;
        goto L_0x0275;
    L_0x0295:
        r1 = r3 instanceof java.io.IOException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x029c;
    L_0x0299:
        r0 = 1007; // 0x3ef float:1.411E-42 double:4.975E-321;
        goto L_0x0275;
    L_0x029c:
        r1 = r3 instanceof java.lang.InterruptedException;	 Catch:{ all -> 0x0261 }
        if (r1 == 0) goto L_0x0275;
    L_0x02a0:
        r0 = 1008; // 0x3f0 float:1.413E-42 double:4.98E-321;
        goto L_0x0275;
    L_0x02a3:
        r2 = move-exception;
        r3 = r2;
        r4 = r0;
        r5 = r1;
        goto L_0x0263;
    L_0x02a8:
        r1 = move-exception;
        r3 = r1;
        r4 = r0;
        r5 = r2;
        goto L_0x0263;
    L_0x02ad:
        r0 = move-exception;
        r3 = r0;
        r4 = r1;
        r5 = r2;
        goto L_0x0263;
    L_0x02b2:
        r0 = move-exception;
        r3 = r0;
        r4 = r1;
        r5 = r2;
        goto L_0x01a9;
    L_0x02b8:
        r5 = r2;
        goto L_0x0098;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.wepkg.downloader.c.dgv():void");
    }

    private static SSLContext ahL(String str) {
        AppMethodBeat.i(63423);
        try {
            SSLContext instance = SSLContext.getInstance(str);
            AppMethodBeat.o(63423);
            return instance;
        } catch (Exception e) {
            AppMethodBeat.o(63423);
            return null;
        }
    }

    private static int ahM(String str) {
        AppMethodBeat.i(63424);
        if (!TextUtils.isEmpty(str)) {
            String[] split = str.split("/");
            if (split != null && split.length == 2) {
                try {
                    int intValue = Integer.valueOf(split[1]).intValue();
                    AppMethodBeat.o(63424);
                    return intValue;
                } catch (NumberFormatException e) {
                }
            }
        }
        AppMethodBeat.o(63424);
        return -1;
    }

    private static long ahN(String str) {
        AppMethodBeat.i(63425);
        if (!TextUtils.isEmpty(str)) {
            try {
                long longValue = Long.valueOf(str).longValue();
                AppMethodBeat.o(63425);
                return longValue;
            } catch (NumberFormatException e) {
            }
        }
        AppMethodBeat.o(63425);
        return -1;
    }
}
