导航菜单

页面标题

页面副标题

moonshot.企业版 v8.14.46 - C9293.java 源代码

正在查看: moonshot.企业版 v8.14.46 应用的 C9293.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package kp1AiJpjqJHu1Tcnj96z.iTeGsf4pEYeDatV5mlQ3.zSFvmU2XOpXZrEfUxlHp;

import ZTD6r3EkaRUOi5CZamJi.zSFvmU2XOpXZrEfUxlHp.zSFvmU2XOpXZrEfUxlHp.C2486;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.StatFs;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.SparseArray;
import com.netease.yunxin.base.http.HttpHeaders;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import kp1AiJpjqJHu1Tcnj96z.Yt7pKkvfomCuROgEX5My.zSFvmU2XOpXZrEfUxlHp.zSFvmU2XOpXZrEfUxlHp.C8511;
import org.apache.http.protocol.HTTP;

public class C9293 extends C9289 implements InterfaceC9298<C9334>, InterfaceC9299 {

    public static final int f32473 = 16385;

    public static final int f32474 = 16401;

    public static final int f32475 = 16386;

    public static final int f32476 = 16388;

    public static final int f32477 = 16391;

    public static final int f32478 = 16387;

    public static final int f32479 = 16384;

    public static final int f32480 = 16400;

    public static final int f32481 = 16393;

    private static final int f32482 = 8192;

    public static final int f32483 = 8192;

    private static final Handler f32484;

    public static final int f32485 = 4016;

    private static final int f32486 = 307;

    private static final int f32487 = 7;

    public static final int f32488 = 16392;

    public static final SparseArray<String> f32489;

    private static final String f32490 = C9286.f32452 + C9293.class.getSimpleName();

    public static final int f32491 = 20483;

    public static final int f32492 = 16390;

    public volatile Throwable f32493;

    public volatile C9334 f32503;

    private volatile long f32496 = 0;

    public volatile long f32501 = -1;

    private long f32505 = 0;

    private long f32497 = 0;

    private long f32502 = 0;

    private volatile long f32494 = 0;

    private volatile long f32506 = 0;

    public long f32500 = Long.MAX_VALUE;

    public long f32504 = C8511.f30508;

    public volatile boolean f32507 = false;

    public boolean f32498 = false;

    public boolean f32495 = false;

    private StringBuffer f32499 = new StringBuffer();

    public class RunnableC9294 implements Runnable {

        public final C9334 f32508;

        public RunnableC9294(C9334 c9334) {
            this.f32508 = c9334;
        }

        @Override
        public void run() {
            InterfaceC9310 m36233 = this.f32508.m36233();
            C9334 c9334 = this.f32508;
            m36233.onStart(c9334.f32530, c9334.f32538, c9334.f32541, c9334.f32533, c9334.f32636, c9334);
        }
    }

    public final class C9295 extends RandomAccessFile {
        public C9295(File file) throws FileNotFoundException {
            super(file, "rw");
        }

        @Override
        public void write(byte[] bArr, int i, int i2) throws IOException {
            super.write(bArr, i, i2);
            C9293.this.f32496 += i2;
            C9334 c9334 = C9293.this.f32503;
            if (c9334 != null) {
                c9334.m36221(C9293.this.f32505 + C9293.this.f32496);
            }
            C9293.this.m36052();
        }
    }

    static {
        SparseArray<String> sparseArray = new SparseArray<>(13);
        f32489 = sparseArray;
        f32484 = new Handler(Looper.getMainLooper());
        sparseArray.append(16384, "Network connection error . ");
        sparseArray.append(f32473, "Response code non-200 or non-206 . ");
        sparseArray.append(16386, "Insufficient memory space . ");
        sparseArray.append(f32477, "Shutdown . ");
        sparseArray.append(f32478, "Download time is overtime . ");
        sparseArray.append(f32492, "The user canceled the download . ");
        sparseArray.append(f32480, "Resource not found . ");
        sparseArray.append(f32476, "paused . ");
        sparseArray.append(f32481, "IO Error . ");
        sparseArray.append(f32491, "Service Unavailable . ");
        sparseArray.append(f32488, "Too many redirects . ");
        sparseArray.append(f32474, "Md5 check fails . ");
        sparseArray.append(8192, "Download successful . ");
    }

    private long m36046(HttpURLConnection httpURLConnection, String str) {
        String headerField = httpURLConnection.getHeaderField(str);
        if (headerField == null) {
            return -1L;
        }
        try {
            return Long.parseLong(headerField);
        } catch (NumberFormatException e) {
            if (C9286.m35978().m36017()) {
                e.printStackTrace();
            }
            return -1L;
        }
    }

    private void m36048(C9334 c9334, HttpURLConnection httpURLConnection) {
        Map<String, String> m36098 = c9334.m36098();
        if (m36098 != null && !m36098.isEmpty()) {
            for (Map.Entry<String, String> entry : m36098.entrySet()) {
                if (!TextUtils.isEmpty(entry.getKey()) && !TextUtils.isEmpty(entry.getValue())) {
                    httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
                }
            }
        }
        String m36061 = m36061();
        if (TextUtils.isEmpty(m36061)) {
            return;
        }
        C9286.m35978().m36000(f32490, "Etag:" + m36061);
        httpURLConnection.setRequestProperty("If-Match", m36061());
    }

    private InputStream m36049(HttpURLConnection httpURLConnection) throws IOException {
        return "gzip".equalsIgnoreCase(httpURLConnection.getContentEncoding()) ? new GZIPInputStream(httpURLConnection.getInputStream()) : "deflate".equalsIgnoreCase(httpURLConnection.getContentEncoding()) ? new InflaterInputStream(httpURLConnection.getInputStream(), new Inflater(true)) : httpURLConnection.getInputStream();
    }

    private void m36050() {
        this.f32502 = SystemClock.elapsedRealtime();
        m36062(1);
    }

    private boolean m36051() {
        C9334 c9334 = this.f32503;
        if (c9334.m36181() - c9334.m36204().length() <= m36053(c9334.m36204().getParent()) - 104857600) {
            return true;
        }
        C9286.m35978().m36014(f32490, " 空间不足");
        return false;
    }

    public void m36052() {
        if (this.f32507) {
            if (!this.f32495) {
                long elapsedRealtime = SystemClock.elapsedRealtime();
                if (elapsedRealtime - this.f32502 < 1200) {
                    return;
                }
                this.f32502 = elapsedRealtime;
                m36062(1);
                return;
            }
            long elapsedRealtime2 = SystemClock.elapsedRealtime();
            if (elapsedRealtime2 - this.f32502 < 1200) {
                m36062(0);
            } else {
                this.f32502 = elapsedRealtime2;
                m36062(1);
            }
        }
    }

    public static long m36053(String str) {
        long blockSize;
        long availableBlocks;
        if (TextUtils.isEmpty(str)) {
            return 0L;
        }
        try {
            StatFs statFs = new StatFs(str);
            if (Build.VERSION.SDK_INT >= 18) {
                blockSize = statFs.getBlockSizeLong();
                availableBlocks = statFs.getAvailableBlocksLong();
            } else {
                blockSize = statFs.getBlockSize();
                availableBlocks = statFs.getAvailableBlocks();
            }
            return blockSize * availableBlocks;
        } catch (Throwable th) {
            th.printStackTrace();
            return 0L;
        }
    }

    public static InterfaceC9299 m36054(C9334 c9334) {
        C9293 c9293 = new C9293();
        c9293.f32503 = c9334;
        c9293.f32501 = c9334.m36181();
        c9293.f32500 = c9334.m36087();
        c9293.f32504 = c9334.m36090();
        c9293.f32495 = c9334.m36093();
        c9293.f32507 = c9334.m36099() || c9334.m36194() != null;
        return c9293;
    }

    private void m36055(HttpURLConnection httpURLConnection) {
        String headerField = httpURLConnection.getHeaderField(HttpHeaders.ETAG);
        if (TextUtils.isEmpty(headerField)) {
            return;
        }
        String m36001 = C9286.m35978().m36001(this.f32503.m36088());
        C9286.m35978().m36000(f32490, "save etag:" + headerField);
        C9286.m35978().m35993(this.f32503.f32630).mo36109(m36001, headerField);
    }

    private void m36056(C9334 c9334, HttpURLConnection httpURLConnection) {
        if (c9334.m36204() != null && c9334.m36204().length() > 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("bytes=");
            long length = c9334.m36204().length();
            this.f32505 = length;
            sb.append(length);
            sb.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
            httpURLConnection.setRequestProperty("Range", sb.toString());
        }
        StringBuffer stringBuffer = this.f32499;
        stringBuffer.append("range=");
        stringBuffer.append(this.f32505);
        stringBuffer.append("\n");
        httpURLConnection.setRequestProperty(HTTP.CONN_DIRECTIVE, "close");
    }

    private int m36057() throws IOException {
        boolean z;
        String str;
        String str2 = "range not satisfiable .";
        C9334 c9334 = this.f32503;
        c9334.m36192(this.f32494);
        c9334.m36187();
        HttpURLConnection httpURLConnection = null;
        URL url = TextUtils.isEmpty(c9334.f32637) ? new URL(c9334.m36088()) : new URL(c9334.m36193());
        int i = 0;
        while (true) {
            int i2 = i + 1;
            if (i > 7) {
                c9334.m36186();
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
                return f32488;
            }
            try {
                StringBuffer stringBuffer = this.f32499;
                stringBuffer.append("redirectionCount=");
                stringBuffer.append(i2);
                stringBuffer.append("\n");
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
                if (c9334.f32618 <= 0) {
                    httpURLConnection = m36064(url);
                    m36048(c9334, httpURLConnection);
                    try {
                        httpURLConnection.connect();
                        if (!c9334.m36239()) {
                            c9334.m36226();
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            return f32476;
                        }
                        if (c9334.m36229()) {
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            return f32476;
                        }
                        if (c9334.m36238()) {
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            return f32492;
                        }
                        try {
                            z = HTTP.CHUNK_CODING.equalsIgnoreCase(httpURLConnection.getHeaderField(HTTP.TRANSFER_ENCODING));
                        } catch (Throwable th) {
                            th.printStackTrace();
                            z = false;
                        }
                        long m36046 = m36046(httpURLConnection, HTTP.CONTENT_LEN);
                        boolean z2 = m36046 > 0;
                        boolean z3 = (z && z2) || !(z || z2);
                        int responseCode = httpURLConnection.getResponseCode();
                        C9286 m35978 = C9286.m35978();
                        String str3 = f32490;
                        m35978.m36000(str3, "responseCode:" + responseCode);
                        StringBuffer stringBuffer2 = this.f32499;
                        stringBuffer2.append("responseCode=");
                        stringBuffer2.append(responseCode);
                        stringBuffer2.append("\n");
                        if (responseCode == 206 && !z2) {
                            c9334.m36197();
                            if (httpURLConnection != null) {
                                httpURLConnection.disconnect();
                            }
                            return 8192;
                        }
                        if (responseCode == 200) {
                            str = str2;
                            if (z3) {
                                C9286.m35978().m36014(str3, " error , giving up ,  EncodingChunked:" + z + "  hasLength:" + z2 + " response length:" + m36046 + " responseCode:" + responseCode);
                                c9334.m36186();
                                if (httpURLConnection != null) {
                                    httpURLConnection.disconnect();
                                }
                                return f32481;
                            }
                            this.f32501 = m36046;
                            if (c9334.f32618 <= 0) {
                                m36065(httpURLConnection);
                                c9334.f32618++;
                                if (c9334.m36204().length() > 0 && !z) {
                                    if (c9334.m36204().length() == m36046) {
                                        StringBuffer stringBuffer3 = this.f32499;
                                        stringBuffer3.append("file already exist, file name=");
                                        stringBuffer3.append(c9334.m36204().getName());
                                        stringBuffer3.append(", file length==contentLength");
                                        stringBuffer3.append(",contentLength=");
                                        stringBuffer3.append(m36046);
                                        stringBuffer3.append("\n");
                                        String m36002 = C9286.m35978().m36002(c9334.m36204());
                                        int mo36021 = C9286.m35978().m35996().mo36021(c9334.m36088(), c9334.m36204(), c9334.m36094(), m36002);
                                        StringBuffer stringBuffer4 = this.f32499;
                                        stringBuffer4.append("compareResult=");
                                        stringBuffer4.append(mo36021);
                                        stringBuffer4.append("\n");
                                        StringBuffer stringBuffer5 = this.f32499;
                                        stringBuffer5.append("compare Result table:");
                                        stringBuffer5.append("COMPARE_RESULT_SUCCESSFUL = 1");
                                        stringBuffer5.append(",COMPARE_RESULT_REDOWNLOAD_COVER = 2");
                                        stringBuffer5.append(",COMPARE_RESULT_REDOWNLOAD_RENAME = 3");
                                        stringBuffer5.append("\n");
                                        if (mo36021 == 1) {
                                            c9334.m36214(m36002);
                                            this.f32505 = m36046;
                                            m36062(1);
                                            c9334.m36197();
                                            if (httpURLConnection == null) {
                                                return 8192;
                                            }
                                            httpURLConnection.disconnect();
                                            return 8192;
                                        }
                                        if (mo36021 == 2) {
                                            c9334.m36204().delete();
                                            c9334.m36204().createNewFile();
                                        } else {
                                            int i3 = 1;
                                            while (true) {
                                                if (i3 < Integer.MAX_VALUE) {
                                                    File file = new File(c9334.m36204().getParent(), C2486.C2488.f7759 + i3 + C2486.C2488.f7757 + c9334.m36204().getName());
                                                    if (!file.exists()) {
                                                        StringBuffer stringBuffer6 = this.f32499;
                                                        stringBuffer6.append("target file is not exist, create new target file ,file name=");
                                                        stringBuffer6.append(file.getName());
                                                        stringBuffer6.append("\n");
                                                        file.createNewFile();
                                                        c9334.m36230(file);
                                                    } else if (file.length() >= m36046) {
                                                        C9286.m35978().m36000(f32490, "rename download , targetFile exists:" + file.getName());
                                                        i3++;
                                                    } else {
                                                        StringBuffer stringBuffer7 = this.f32499;
                                                        stringBuffer7.append("origin file name=");
                                                        stringBuffer7.append(c9334.m36204().getName());
                                                        stringBuffer7.append(" target file name=");
                                                        stringBuffer7.append(file.getName());
                                                        stringBuffer7.append(",current target file length=");
                                                        stringBuffer7.append(file.length());
                                                        stringBuffer7.append("\n");
                                                        c9334.m36230(file);
                                                    }
                                                }
                                            }
                                        }
                                    } else if (c9334.m36204().length() >= m36046) {
                                        StringBuffer stringBuffer8 = this.f32499;
                                        stringBuffer8.append("file length error .");
                                        stringBuffer8.append("\n");
                                        c9334.m36204().delete();
                                        c9334.m36204().createNewFile();
                                    }
                                }
                            }
                        } else {
                            if (responseCode == 206) {
                                if (z3) {
                                    C9286.m35978().m36014(str3, " error , giving up ,  EncodingChunked:" + z + "  hasLength:" + z2 + " response length:" + m36046 + " responseCode:" + responseCode);
                                    c9334.m36186();
                                    if (httpURLConnection != null) {
                                        httpURLConnection.disconnect();
                                    }
                                    return f32481;
                                }
                                if (this.f32501 <= 0) {
                                    this.f32501 = c9334.m36204().length() + m36046;
                                }
                                if (this.f32501 > 0 && c9334.m36204().length() + m36046 != this.f32501) {
                                    c9334.m36186();
                                    C9286.m35978().m36014(str3, "length error, this.mTotals:" + this.f32501 + " contentLength:" + m36046 + " file length:" + c9334.m36204().length());
                                    if (httpURLConnection != null) {
                                        httpURLConnection.disconnect();
                                    }
                                    return f32481;
                                }
                                c9334.m36224(this.f32501);
                                if (!m36051()) {
                                    c9334.m36186();
                                    if (httpURLConnection != null) {
                                        httpURLConnection.disconnect();
                                    }
                                    return 16386;
                                }
                                C9286.m35978().m36000(str3, "last:" + this.f32505 + " totals:" + this.f32501);
                                StringBuffer stringBuffer9 = this.f32499;
                                stringBuffer9.append("last=");
                                stringBuffer9.append(this.f32505);
                                stringBuffer9.append(" totals=");
                                stringBuffer9.append(this.f32501);
                                stringBuffer9.append("\n");
                                int m36058 = m36058(m36049(httpURLConnection), new C9295(c9334.m36204()), true);
                                if (httpURLConnection != null) {
                                    httpURLConnection.disconnect();
                                }
                                return m36058;
                            }
                            if (responseCode != 307) {
                                if (responseCode == 404) {
                                    if (httpURLConnection != null) {
                                        httpURLConnection.disconnect();
                                    }
                                    return f32480;
                                }
                                if (responseCode != 4016) {
                                    switch (responseCode) {
                                        case 301:
                                        case 302:
                                        case 303:
                                            break;
                                        default:
                                            switch (responseCode) {
                                                case 500:
                                                case 501:
                                                case 502:
                                                case 503:
                                                    c9334.m36186();
                                                    if (httpURLConnection != null) {
                                                        httpURLConnection.disconnect();
                                                    }
                                                    return f32491;
                                                default:
                                                    c9334.m36186();
                                                    if (httpURLConnection != null) {
                                                        httpURLConnection.disconnect();
                                                    }
                                                    return f32473;
                                            }
                                    }
                                } else {
                                    if (c9334.m36204() != null) {
                                        C9286.m35978().m36000(str3, str2);
                                        StringBuffer stringBuffer10 = this.f32499;
                                        stringBuffer10.append(str2);
                                        stringBuffer10.append("\n");
                                        c9334.m36204().delete();
                                        c9334.m36204().createNewFile();
                                    }
                                    str = str2;
                                }
                            }
                            String headerField = httpURLConnection.getHeaderField("Location");
                            if (TextUtils.isEmpty(headerField)) {
                                c9334.m36186();
                                if (httpURLConnection != null) {
                                    httpURLConnection.disconnect();
                                }
                                return f32491;
                            }
                            StringBuffer stringBuffer11 = this.f32499;
                            stringBuffer11.append("original url=");
                            stringBuffer11.append(httpURLConnection.getURL().toString());
                            stringBuffer11.append("  ,redirect url=" + headerField);
                            stringBuffer11.append("\n");
                            try {
                                URL url2 = new URL(url, headerField);
                                c9334.m36202(url2.toString());
                                url = url2;
                                i = i2;
                            } catch (MalformedURLException unused) {
                                c9334.m36186();
                                if (httpURLConnection != null) {
                                    httpURLConnection.disconnect();
                                }
                                return f32491;
                            }
                        }
                        i = i2;
                        str2 = str;
                    } catch (IOException e) {
                        throw e;
                    }
                } else {
                    httpURLConnection = m36064(url);
                    m36048(c9334, httpURLConnection);
                    m36056(c9334, httpURLConnection);
                    try {
                        httpURLConnection.connect();
                        if (!c9334.m36239()) {
                        }
                    } catch (IOException e2) {
                        throw e2;
                    }
                }
            } catch (Throwable th2) {
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
                throw th2;
            }
        }
    }

    private int m36058(InputStream inputStream, RandomAccessFile randomAccessFile, boolean z) throws IOException {
        int i;
        byte[] bArr = new byte[8192];
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 8192);
        C9334 c9334 = this.f32503;
        this.f32496 = 0L;
        try {
            if (z) {
                randomAccessFile.seek(randomAccessFile.length());
            } else {
                randomAccessFile.seek(0L);
                this.f32505 = 0L;
            }
            while (!c9334.m36239() && !c9334.m36238() && !c9334.m36229()) {
                try {
                    int read = bufferedInputStream.read(bArr, 0, 8192);
                    if (read == -1) {
                        break;
                    }
                    randomAccessFile.write(bArr, 0, read);
                    if (SystemClock.elapsedRealtime() - this.f32494 > this.f32500) {
                        this.f32503.m36186();
                        i = f32478;
                        break;
                    }
                } catch (IOException e) {
                    c9334.m36186();
                    throw e;
                }
            }
            if (c9334.m36239()) {
                c9334.m36226();
            } else if (!c9334.m36229()) {
                if (!c9334.m36238()) {
                    if (c9334.m36100()) {
                        this.f32503.m36214(C9286.m35978().m36002(this.f32503.f32631));
                    }
                    if (!TextUtils.isEmpty(c9334.m36094())) {
                        if (TextUtils.isEmpty(c9334.f32534)) {
                            this.f32503.m36214(C9286.m35978().m36002(this.f32503.f32631));
                        }
                        if (!c9334.m36094().equalsIgnoreCase(c9334.mo36106())) {
                            c9334.m36186();
                            i = f32474;
                        }
                    }
                    m36050();
                    c9334.m36197();
                    return 8192;
                }
                i = f32492;
                return i;
            }
            return f32476;
        } finally {
            m36068(randomAccessFile);
            m36068(bufferedInputStream);
            m36068(inputStream);
        }
    }

    private void m36060() {
        C9334 c9334 = this.f32503;
        C9322 c9322 = c9334.f32623;
        if (c9322 != null) {
            c9322.m36165(c9334);
        }
    }

    private String m36061() {
        String mo36110 = C9286.m35978().m35993(this.f32503.f32630).mo36110(C9286.m35978().m36001(this.f32503.m36088()), "-1");
        if (TextUtils.isEmpty(mo36110) || "-1".equals(mo36110)) {
            return null;
        }
        return mo36110;
    }

    private void m36062(int i) {
        if (this.f32498) {
            m36024(Integer.valueOf(i));
        } else {
            mo36023(Integer.valueOf(i));
        }
    }

    private HttpURLConnection m36064(URL url) throws IOException {
        C9334 c9334 = this.f32503;
        HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setConnectTimeout((int) this.f32504);
        httpURLConnection.setInstanceFollowRedirects(false);
        httpURLConnection.setReadTimeout((int) c9334.m36103());
        httpURLConnection.setRequestProperty("Accept", "*/*");
        httpURLConnection.setRequestProperty("Accept-Encoding", "deflate,gzip");
        return httpURLConnection;
    }

    private final void m36065(HttpURLConnection httpURLConnection) throws IOException {
        C9334 c9334 = this.f32503;
        if (TextUtils.isEmpty(c9334.m36101())) {
            c9334.m36199(httpURLConnection.getHeaderField("Content-Disposition"));
            String m35988 = C9286.m35978().m35988(c9334.m36101());
            if (!TextUtils.isEmpty(m35988) && !c9334.m36204().getName().equals(m35988)) {
                File file = new File(c9334.m36204().getParent(), m35988);
                if (file.exists()) {
                    c9334.m36230(file);
                    m36060();
                } else {
                    File m36204 = c9334.m36204();
                    if (c9334.m36204().renameTo(file)) {
                        c9334.m36230(file);
                        m36060();
                        StringBuffer stringBuffer = this.f32499;
                        stringBuffer.append("origin=");
                        stringBuffer.append(m36204.getName());
                        stringBuffer.append(" rename=");
                        stringBuffer.append(file.getName());
                        stringBuffer.append("\n");
                        m36204.delete();
                    }
                }
            }
        }
        if (TextUtils.isEmpty(c9334.m36104())) {
            c9334.m36237(httpURLConnection.getHeaderField(HTTP.CONTENT_TYPE));
        }
        if (TextUtils.isEmpty(c9334.m36096())) {
            String headerField = httpURLConnection.getHeaderField(HTTP.USER_AGENT);
            if (headerField == null) {
                headerField = "";
            }
            c9334.m36246(headerField);
        }
        c9334.m36183(m36046(httpURLConnection, HTTP.CONTENT_LEN));
        m36071();
    }

    private boolean m36066() {
        C9334 c9334 = this.f32503;
        return !c9334.m36089() ? C9286.m35978().m35989(c9334.m36243()) : C9286.m35978().m36008(c9334.m36243());
    }

    private final C9334 m36067() {
        C9334 c9334 = this.f32503;
        c9334.m36234();
        return c9334;
    }

    @Override
    public final C9334 cancel() {
        C9334 c9334 = this.f32503;
        c9334.m36188();
        return c9334;
    }

    public void m36068(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public C9334 mo36069() {
        return this.f32503;
    }

    @Override
    public boolean mo36070(C9334 c9334) {
        return true;
    }

    @Override
    public void mo36023(Integer... numArr) {
        C9334 c9334 = this.f32503;
        C9322 c9322 = c9334.f32623;
        try {
            long elapsedRealtime = SystemClock.elapsedRealtime() - this.f32494;
            this.f32497 = elapsedRealtime;
            if (elapsedRealtime == 0) {
                this.f32506 = 0L;
            } else {
                this.f32506 = (this.f32496 * 1000) / this.f32497;
            }
            if (numArr != null && numArr.length > 0 && numArr[0].intValue() == 1 && c9322 != null) {
                if (this.f32501 > 0) {
                    c9322.m36168((int) (((this.f32505 + this.f32496) / Float.valueOf(this.f32501).floatValue()) * 100.0f));
                } else {
                    c9322.m36170(this.f32505 + this.f32496);
                }
            }
            if (c9334.m36233() != null) {
                c9334.m36194().onProgress(c9334.m36088(), this.f32505 + this.f32496, this.f32501, c9334.m36207());
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public void m36071() throws IOException {
        C9334 c9334 = this.f32503;
        if (c9334 == null || c9334.m36233() == null) {
            return;
        }
        f32484.post(new RunnableC9294(c9334));
    }

    public Integer m36072() {
        String str = "";
        C9334 c9334 = this.f32503;
        boolean m36239 = c9334.m36239();
        Integer valueOf = Integer.valueOf(f32476);
        if (m36239) {
            c9334.m36226();
            return valueOf;
        }
        if (c9334.m36229()) {
            return valueOf;
        }
        if (c9334.m36238()) {
            return Integer.valueOf(f32492);
        }
        this.f32494 = SystemClock.elapsedRealtime();
        if (!m36066()) {
            C9286.m35978().m36014(f32490, " Network error,isForceDownload:" + this.f32503.m36089());
            c9334.m36186();
            return 16384;
        }
        StringBuffer stringBuffer = this.f32499;
        stringBuffer.append("\r\n");
        stringBuffer.append("=============");
        stringBuffer.append("\n");
        StringBuffer stringBuffer2 = this.f32499;
        stringBuffer2.append("Download Message");
        stringBuffer2.append("\n");
        StringBuffer stringBuffer3 = this.f32499;
        stringBuffer3.append("downloadTask id=");
        stringBuffer3.append(c9334.m36203());
        stringBuffer3.append("\n");
        StringBuffer stringBuffer4 = this.f32499;
        stringBuffer4.append("url=");
        stringBuffer4.append(c9334.m36088());
        stringBuffer4.append("\n");
        try {
            StringBuffer stringBuffer5 = this.f32499;
            stringBuffer5.append("file=");
            stringBuffer5.append(c9334.m36204() == null ? "" : c9334.m36204().getCanonicalPath());
            stringBuffer5.append("\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
        String name = Thread.currentThread().getName();
        Thread.currentThread().setName("pool-download-thread-" + C9286.m35978().m36012());
        try {
            c9334.m36225(1002);
            IOException e2 = null;
            int i = 0;
            int i2 = f32481;
            while (i <= c9334.f32536) {
                try {
                    i2 = m36057();
                } catch (IOException e3) {
                    e2 = e3;
                    this.f32493 = e2;
                    if (C9286.m35978().m36017()) {
                        e2.printStackTrace();
                    }
                    i2 = f32481;
                }
                if (e2 == null) {
                    break;
                }
                if (i == c9334.f32536) {
                    c9334.m36186();
                    this.f32503.m36195(e2);
                }
                StringBuffer stringBuffer6 = this.f32499;
                stringBuffer6.append("download error message: ");
                stringBuffer6.append(e2.getMessage());
                stringBuffer6.append("\n");
                i++;
                if (i <= c9334.f32536) {
                    StringBuffer stringBuffer7 = this.f32499;
                    stringBuffer7.append("download error , retry ");
                    stringBuffer7.append(i);
                    stringBuffer7.append("\n");
                }
            }
            try {
                StringBuffer stringBuffer8 = this.f32499;
                stringBuffer8.append("final output file=");
                if (c9334.m36204() != null) {
                    str = c9334.m36204().getCanonicalPath();
                }
                stringBuffer8.append(str);
                stringBuffer8.append("\n");
            } catch (IOException e4) {
                e4.printStackTrace();
            }
            if (c9334.m36098() != null && !c9334.m36098().isEmpty()) {
                StringBuffer stringBuffer9 = this.f32499;
                stringBuffer9.append("custom request headers=");
                stringBuffer9.append(c9334.m36098().toString());
                stringBuffer9.append("\n");
            }
            StringBuffer stringBuffer10 = this.f32499;
            stringBuffer10.append("error=");
            stringBuffer10.append("0x" + Integer.toHexString(i2));
            stringBuffer10.append("\n");
            StringBuffer stringBuffer11 = this.f32499;
            stringBuffer11.append("error table: ERROR_NETWORK_CONNECTION = 0x4000,ERROR_RESPONSE_STATUS = 0x4001,ERROR_STORAGE = 0x4002,ERROR_TIME_OUT = 0x4003,ERROR_USER_PAUSE = 0x4004,ERROR_USER_CANCEL = 0x4006,ERROR_SHUTDOWN = 0x4007,ERROR_TOO_MANY_REDIRECTS = 0x4008,ERROR_LOAD = 0x4009,ERROR_RESOURCE_NOT_FOUND = 0x4010,ERROR_MD5 = 0x4011,ERROR_SERVICE = 0x5003,SUCCESSFUL = 0x2000,HTTP_RANGE_NOT_SATISFIABLE = 4016");
            stringBuffer11.append("\n");
            StringBuffer stringBuffer12 = this.f32499;
            stringBuffer12.append("error message=");
            stringBuffer12.append(f32489.get(i2));
            stringBuffer12.append("\n");
            StringBuffer stringBuffer13 = this.f32499;
            stringBuffer13.append("mLoaded=");
            stringBuffer13.append(this.f32496);
            stringBuffer13.append("\n");
            StringBuffer stringBuffer14 = this.f32499;
            stringBuffer14.append("mLastLoaded=");
            stringBuffer14.append(this.f32505);
            stringBuffer14.append("\n");
            StringBuffer stringBuffer15 = this.f32499;
            stringBuffer15.append("mLoaded+mLastLoaded=");
            stringBuffer15.append(this.f32496 + this.f32505);
            stringBuffer15.append("\n");
            StringBuffer stringBuffer16 = this.f32499;
            stringBuffer16.append("totals=");
            stringBuffer16.append(this.f32501);
            stringBuffer16.append("\n");
            if (c9334.m36235() == 1005 || i2 == 16401) {
                StringBuffer stringBuffer17 = this.f32499;
                stringBuffer17.append("isCalculateMD5=");
                stringBuffer17.append(c9334.m36100());
                stringBuffer17.append("\n");
                if (TextUtils.isEmpty(c9334.f32534)) {
                    StringBuffer stringBuffer18 = this.f32499;
                    stringBuffer18.append("FileMD5=");
                    stringBuffer18.append("''");
                    stringBuffer18.append("\n");
                } else {
                    StringBuffer stringBuffer19 = this.f32499;
                    stringBuffer19.append("FileMD5=");
                    stringBuffer19.append(c9334.f32534);
                    stringBuffer19.append("\n");
                }
            }
            if (!TextUtils.isEmpty(c9334.m36094())) {
                StringBuffer stringBuffer20 = this.f32499;
                stringBuffer20.append("targetCompareMD5=");
                stringBuffer20.append(c9334.m36094());
                stringBuffer20.append("\n");
            }
            StringBuffer stringBuffer21 = this.f32499;
            stringBuffer21.append("current downloadTask status=");
            stringBuffer21.append(c9334.m36235());
            stringBuffer21.append("\n");
            StringBuffer stringBuffer22 = this.f32499;
            stringBuffer22.append("status table: STATUS_NEW = 1000,STATUS_PENDDING = 1001,STATUS_DOWNLOADING = 1002,STATUS_PAUSING = 1003,STATUS_PAUSED = 1004,STATUS_SUCCESSFUL = 1005,STATUS_CANCELED = 1006,STATUS_ERROR = 1007");
            stringBuffer22.append("\n");
            StringBuffer stringBuffer23 = this.f32499;
            stringBuffer23.append("used time=");
            stringBuffer23.append(c9334.m36207());
            stringBuffer23.append("ms");
            stringBuffer23.append("\n");
            this.f32499.append("\r\n");
            C9286.m35978().m36000(f32490, "\r\n" + this.f32499.toString());
            Thread.currentThread().setName(name);
            return Integer.valueOf(i2);
        } catch (Throwable th) {
            Thread.currentThread().setName(name);
            throw th;
        }
    }

    @Override
    public int mo36073() {
        C9334 c9334 = this.f32503;
        if (c9334 == null) {
            return 1000;
        }
        return c9334.m36235();
    }

    @Override
    public C9334 mo36074() {
        return cancel();
    }

    public void m36075(C9334 c9334) {
        Objects.requireNonNull(c9334, "downloadTask can't be null.");
        Objects.requireNonNull(c9334.m36243(), "context can't be null.");
    }

    @Override
    public C9334 mo36076() {
        return m36067();
    }
}