正在查看: moonshot.企业版 v5.53.33 应用的 C6808.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: moonshot.企业版 v5.53.33 应用的 C6808.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package jnksI9k6J1HFuFo5YzBf.n66Vr4ULakY6CzHspLC4.UBVL9U3WwxbAPwDW6rA5;
import MeHcvHJFg1sI1SlloYsz.UBVL9U3WwxbAPwDW6rA5.UBVL9U3WwxbAPwDW6rA5.C0033;
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 jnksI9k6J1HFuFo5YzBf.P1qFuCkms7jkO5aFlyzU.UBVL9U3WwxbAPwDW6rA5.UBVL9U3WwxbAPwDW6rA5.C6258;
import org.apache.http.protocol.HTTP;
public class C6808 extends C6798 implements InterfaceC6772<C6777>, InterfaceC6766 {
private static final int f25917 = 307;
public static final int f25918 = 16401;
public static final int f25919 = 16384;
public static final SparseArray<String> f25920;
public static final int f25921 = 16392;
public static final int f25922 = 16388;
public static final int f25923 = 16385;
public static final int f25924 = 16386;
private static final int f25925 = 7;
private static final String f25926 = C6782.f25851 + C6808.class.getSimpleName();
public static final int f25927 = 16391;
public static final int f25928 = 16393;
public static final int f25929 = 4016;
private static final int f25930 = 8192;
public static final int f25931 = 16400;
public static final int f25932 = 16390;
private static final Handler f25933;
public static final int f25934 = 20483;
public static final int f25935 = 8192;
public static final int f25936 = 16387;
public volatile C6777 f25938;
public volatile Throwable f25940;
private volatile long f25947 = 0;
public volatile long f25942 = -1;
private long f25951 = 0;
private long f25939 = 0;
private long f25941 = 0;
private volatile long f25944 = 0;
private volatile long f25950 = 0;
public long f25945 = Long.MAX_VALUE;
public long f25946 = C6258.f24110;
public volatile boolean f25943 = false;
public boolean f25949 = false;
public boolean f25948 = false;
private StringBuffer f25937 = new StringBuffer();
public final class C6809 extends RandomAccessFile {
public C6809(File file) throws FileNotFoundException {
super(file, "rw");
}
@Override
public void write(byte[] bArr, int i, int i2) throws IOException {
super.write(bArr, i, i2);
C6808.this.f25947 += i2;
C6777 c6777 = C6808.this.f25938;
if (c6777 != null) {
c6777.m31294(C6808.this.f25951 + C6808.this.f25947);
}
C6808.this.m31480();
}
}
public class RunnableC6810 implements Runnable {
public final C6777 f25953;
public RunnableC6810(C6777 c6777) {
this.f25953 = c6777;
}
@Override
public void run() {
InterfaceC6774 m31252 = this.f25953.m31252();
C6777 c6777 = this.f25953;
m31252.onStart(c6777.f25886, c6777.f25895, c6777.f25901, c6777.f25891, c6777.f25825, c6777);
}
}
static {
SparseArray<String> sparseArray = new SparseArray<>(13);
f25920 = sparseArray;
f25933 = new Handler(Looper.getMainLooper());
sparseArray.append(16384, "Network connection error . ");
sparseArray.append(f25923, "Response code non-200 or non-206 . ");
sparseArray.append(16386, "Insufficient memory space . ");
sparseArray.append(f25927, "Shutdown . ");
sparseArray.append(f25936, "Download time is overtime . ");
sparseArray.append(f25932, "The user canceled the download . ");
sparseArray.append(f25931, "Resource not found . ");
sparseArray.append(f25922, "paused . ");
sparseArray.append(f25928, "IO Error . ");
sparseArray.append(f25934, "Service Unavailable . ");
sparseArray.append(f25921, "Too many redirects . ");
sparseArray.append(f25918, "Md5 check fails . ");
sparseArray.append(8192, "Download successful . ");
}
public static InterfaceC6766 m31458(C6777 c6777) {
C6808 c6808 = new C6808();
c6808.f25938 = c6777;
c6808.f25942 = c6777.m31310();
c6808.f25945 = c6777.m31427();
c6808.f25946 = c6777.m31432();
c6808.f25948 = c6777.m31423();
c6808.f25943 = c6777.m31422() || c6777.m31275() != null;
return c6808;
}
private String m31460() {
String mo31243 = C6782.m31360().m31388(this.f25938.f25823).mo31243(C6782.m31360().m31375(this.f25938.m31436()), "-1");
if (TextUtils.isEmpty(mo31243) || "-1".equals(mo31243)) {
return null;
}
return mo31243;
}
private void m31461(C6777 c6777, HttpURLConnection httpURLConnection) {
Map<String, String> m31428 = c6777.m31428();
if (m31428 != null && !m31428.isEmpty()) {
for (Map.Entry<String, String> entry : m31428.entrySet()) {
if (!TextUtils.isEmpty(entry.getKey()) && !TextUtils.isEmpty(entry.getValue())) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
}
String m31460 = m31460();
if (TextUtils.isEmpty(m31460)) {
return;
}
C6782.m31360().m31400(f25926, "Etag:" + m31460);
httpURLConnection.setRequestProperty("If-Match", m31460());
}
public static long m31462(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;
}
}
private void m31463(int i) {
if (this.f25949) {
m31450(Integer.valueOf(i));
} else {
mo31449(Integer.valueOf(i));
}
}
private boolean m31464() {
C6777 c6777 = this.f25938;
return !c6777.m31429() ? C6782.m31360().m31384(c6777.m31257()) : C6782.m31360().m31365(c6777.m31257());
}
private long m31467(HttpURLConnection httpURLConnection, String str) {
String headerField = httpURLConnection.getHeaderField(str);
if (headerField == null) {
return -1L;
}
try {
return Long.parseLong(headerField);
} catch (NumberFormatException e) {
if (C6782.m31360().m31398()) {
e.printStackTrace();
}
return -1L;
}
}
private InputStream m31468(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 HttpURLConnection m31469(URL url) throws IOException {
C6777 c6777 = this.f25938;
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout((int) this.f25946);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setReadTimeout((int) c6777.m31420());
httpURLConnection.setRequestProperty("Accept", "*/*");
httpURLConnection.setRequestProperty("Accept-Encoding", "deflate,gzip");
return httpURLConnection;
}
private void m31470() {
this.f25941 = SystemClock.elapsedRealtime();
m31463(1);
}
private void m31471(C6777 c6777, HttpURLConnection httpURLConnection) {
if (c6777.m31253() != null && c6777.m31253().length() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("bytes=");
long length = c6777.m31253().length();
this.f25951 = length;
sb.append(length);
sb.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
httpURLConnection.setRequestProperty("Range", sb.toString());
}
StringBuffer stringBuffer = this.f25937;
stringBuffer.append("range=");
stringBuffer.append(this.f25951);
stringBuffer.append("\n");
httpURLConnection.setRequestProperty(HTTP.CONN_DIRECTIVE, "close");
}
private void m31472() {
C6777 c6777 = this.f25938;
C6811 c6811 = c6777.f25822;
if (c6811 != null) {
c6811.m31522(c6777);
}
}
private int m31473() throws IOException {
boolean z;
String str;
String str2 = "range not satisfiable .";
C6777 c6777 = this.f25938;
c6777.m31295(this.f25944);
c6777.m31317();
HttpURLConnection httpURLConnection = null;
URL url = TextUtils.isEmpty(c6777.f25834) ? new URL(c6777.m31436()) : new URL(c6777.m31266());
int i = 0;
while (true) {
int i2 = i + 1;
if (i > 7) {
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25921;
}
try {
StringBuffer stringBuffer = this.f25937;
stringBuffer.append("redirectionCount=");
stringBuffer.append(i2);
stringBuffer.append("\n");
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
if (c6777.f25833 <= 0) {
httpURLConnection = m31469(url);
m31461(c6777, httpURLConnection);
try {
httpURLConnection.connect();
if (!c6777.m31254()) {
c6777.m31319();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25922;
}
if (c6777.m31264()) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25922;
}
if (c6777.m31320()) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25932;
}
try {
z = HTTP.CHUNK_CODING.equalsIgnoreCase(httpURLConnection.getHeaderField(HTTP.TRANSFER_ENCODING));
} catch (Throwable th) {
th.printStackTrace();
z = false;
}
long m31467 = m31467(httpURLConnection, HTTP.CONTENT_LEN);
boolean z2 = m31467 > 0;
boolean z3 = (z && z2) || !(z || z2);
int responseCode = httpURLConnection.getResponseCode();
C6782 m31360 = C6782.m31360();
String str3 = f25926;
m31360.m31400(str3, "responseCode:" + responseCode);
StringBuffer stringBuffer2 = this.f25937;
stringBuffer2.append("responseCode=");
stringBuffer2.append(responseCode);
stringBuffer2.append("\n");
if (responseCode == 206 && !z2) {
c6777.m31249();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 8192;
}
if (responseCode == 200) {
str = str2;
if (z3) {
C6782.m31360().m31373(str3, " error , giving up , EncodingChunked:" + z + " hasLength:" + z2 + " response length:" + m31467 + " responseCode:" + responseCode);
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25928;
}
this.f25942 = m31467;
if (c6777.f25833 <= 0) {
m31478(httpURLConnection);
c6777.f25833++;
if (c6777.m31253().length() > 0 && !z) {
if (c6777.m31253().length() == m31467) {
StringBuffer stringBuffer3 = this.f25937;
stringBuffer3.append("file already exist, file name=");
stringBuffer3.append(c6777.m31253().getName());
stringBuffer3.append(", file length==contentLength");
stringBuffer3.append(",contentLength=");
stringBuffer3.append(m31467);
stringBuffer3.append("\n");
String m31396 = C6782.m31360().m31396(c6777.m31253());
int mo31239 = C6782.m31360().m31371().mo31239(c6777.m31436(), c6777.m31253(), c6777.m31437(), m31396);
StringBuffer stringBuffer4 = this.f25937;
stringBuffer4.append("compareResult=");
stringBuffer4.append(mo31239);
stringBuffer4.append("\n");
StringBuffer stringBuffer5 = this.f25937;
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 (mo31239 == 1) {
c6777.m31287(m31396);
this.f25951 = m31467;
m31463(1);
c6777.m31249();
if (httpURLConnection == null) {
return 8192;
}
httpURLConnection.disconnect();
return 8192;
}
if (mo31239 == 2) {
c6777.m31253().delete();
c6777.m31253().createNewFile();
} else {
int i3 = 1;
while (true) {
if (i3 < Integer.MAX_VALUE) {
File file = new File(c6777.m31253().getParent(), C0033.C0034.f90 + i3 + C0033.C0034.f92 + c6777.m31253().getName());
if (!file.exists()) {
StringBuffer stringBuffer6 = this.f25937;
stringBuffer6.append("target file is not exist, create new target file ,file name=");
stringBuffer6.append(file.getName());
stringBuffer6.append("\n");
file.createNewFile();
c6777.m31278(file);
} else if (file.length() >= m31467) {
C6782.m31360().m31400(f25926, "rename download , targetFile exists:" + file.getName());
i3++;
} else {
StringBuffer stringBuffer7 = this.f25937;
stringBuffer7.append("origin file name=");
stringBuffer7.append(c6777.m31253().getName());
stringBuffer7.append(" target file name=");
stringBuffer7.append(file.getName());
stringBuffer7.append(",current target file length=");
stringBuffer7.append(file.length());
stringBuffer7.append("\n");
c6777.m31278(file);
}
}
}
}
} else if (c6777.m31253().length() >= m31467) {
StringBuffer stringBuffer8 = this.f25937;
stringBuffer8.append("file length error .");
stringBuffer8.append("\n");
c6777.m31253().delete();
c6777.m31253().createNewFile();
}
}
}
} else {
if (responseCode == 206) {
if (z3) {
C6782.m31360().m31373(str3, " error , giving up , EncodingChunked:" + z + " hasLength:" + z2 + " response length:" + m31467 + " responseCode:" + responseCode);
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25928;
}
if (this.f25942 <= 0) {
this.f25942 = c6777.m31253().length() + m31467;
}
if (this.f25942 > 0 && c6777.m31253().length() + m31467 != this.f25942) {
c6777.m31285();
C6782.m31360().m31373(str3, "length error, this.mTotals:" + this.f25942 + " contentLength:" + m31467 + " file length:" + c6777.m31253().length());
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25928;
}
c6777.m31288(this.f25942);
if (!m31476()) {
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 16386;
}
C6782.m31360().m31400(str3, "last:" + this.f25951 + " totals:" + this.f25942);
StringBuffer stringBuffer9 = this.f25937;
stringBuffer9.append("last=");
stringBuffer9.append(this.f25951);
stringBuffer9.append(" totals=");
stringBuffer9.append(this.f25942);
stringBuffer9.append("\n");
int m31479 = m31479(m31468(httpURLConnection), new C6809(c6777.m31253()), true);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return m31479;
}
if (responseCode != 307) {
if (responseCode == 404) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25931;
}
if (responseCode != 4016) {
switch (responseCode) {
case 301:
case 302:
case 303:
break;
default:
switch (responseCode) {
case 500:
case 501:
case 502:
case 503:
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25934;
default:
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25923;
}
}
} else {
if (c6777.m31253() != null) {
C6782.m31360().m31400(str3, str2);
StringBuffer stringBuffer10 = this.f25937;
stringBuffer10.append(str2);
stringBuffer10.append("\n");
c6777.m31253().delete();
c6777.m31253().createNewFile();
}
str = str2;
}
}
String headerField = httpURLConnection.getHeaderField("Location");
if (TextUtils.isEmpty(headerField)) {
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25934;
}
StringBuffer stringBuffer11 = this.f25937;
stringBuffer11.append("original url=");
stringBuffer11.append(httpURLConnection.getURL().toString());
stringBuffer11.append(" ,redirect url=" + headerField);
stringBuffer11.append("\n");
try {
URL url2 = new URL(url, headerField);
c6777.m31297(url2.toString());
url = url2;
i = i2;
} catch (MalformedURLException unused) {
c6777.m31285();
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return f25934;
}
}
i = i2;
str2 = str;
} catch (IOException e) {
throw e;
}
} else {
httpURLConnection = m31469(url);
m31461(c6777, httpURLConnection);
m31471(c6777, httpURLConnection);
try {
httpURLConnection.connect();
if (!c6777.m31254()) {
}
} catch (IOException e2) {
throw e2;
}
}
} catch (Throwable th2) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th2;
}
}
}
private void m31474(HttpURLConnection httpURLConnection) {
String headerField = httpURLConnection.getHeaderField(HttpHeaders.ETAG);
if (TextUtils.isEmpty(headerField)) {
return;
}
String m31375 = C6782.m31360().m31375(this.f25938.m31436());
C6782.m31360().m31400(f25926, "save etag:" + headerField);
C6782.m31360().m31388(this.f25938.f25823).mo31244(m31375, headerField);
}
private final C6777 m31475() {
C6777 c6777 = this.f25938;
c6777.m31296();
return c6777;
}
private boolean m31476() {
C6777 c6777 = this.f25938;
if (c6777.m31310() - c6777.m31253().length() <= m31462(c6777.m31253().getParent()) - 104857600) {
return true;
}
C6782.m31360().m31373(f25926, " 空间不足");
return false;
}
private final void m31478(HttpURLConnection httpURLConnection) throws IOException {
C6777 c6777 = this.f25938;
if (TextUtils.isEmpty(c6777.m31425())) {
c6777.m31308(httpURLConnection.getHeaderField("Content-Disposition"));
String m31381 = C6782.m31360().m31381(c6777.m31425());
if (!TextUtils.isEmpty(m31381) && !c6777.m31253().getName().equals(m31381)) {
File file = new File(c6777.m31253().getParent(), m31381);
if (file.exists()) {
c6777.m31278(file);
m31472();
} else {
File m31253 = c6777.m31253();
if (c6777.m31253().renameTo(file)) {
c6777.m31278(file);
m31472();
StringBuffer stringBuffer = this.f25937;
stringBuffer.append("origin=");
stringBuffer.append(m31253.getName());
stringBuffer.append(" rename=");
stringBuffer.append(file.getName());
stringBuffer.append("\n");
m31253.delete();
}
}
}
}
if (TextUtils.isEmpty(c6777.m31430())) {
c6777.m31282(httpURLConnection.getHeaderField(HTTP.CONTENT_TYPE));
}
if (TextUtils.isEmpty(c6777.m31419())) {
String headerField = httpURLConnection.getHeaderField(HTTP.USER_AGENT);
if (headerField == null) {
headerField = "";
}
c6777.m31313(headerField);
}
c6777.m31298(m31467(httpURLConnection, HTTP.CONTENT_LEN));
m31481();
}
private int m31479(InputStream inputStream, RandomAccessFile randomAccessFile, boolean z) throws IOException {
int i;
byte[] bArr = new byte[8192];
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 8192);
C6777 c6777 = this.f25938;
this.f25947 = 0L;
try {
if (z) {
randomAccessFile.seek(randomAccessFile.length());
} else {
randomAccessFile.seek(0L);
this.f25951 = 0L;
}
while (!c6777.m31254() && !c6777.m31320() && !c6777.m31264()) {
try {
int read = bufferedInputStream.read(bArr, 0, 8192);
if (read == -1) {
break;
}
randomAccessFile.write(bArr, 0, read);
if (SystemClock.elapsedRealtime() - this.f25944 > this.f25945) {
this.f25938.m31285();
i = f25936;
break;
}
} catch (IOException e) {
c6777.m31285();
throw e;
}
}
if (c6777.m31254()) {
c6777.m31319();
} else if (!c6777.m31264()) {
if (!c6777.m31320()) {
if (c6777.m31431()) {
this.f25938.m31287(C6782.m31360().m31396(this.f25938.f25840));
}
if (!TextUtils.isEmpty(c6777.m31437())) {
if (TextUtils.isEmpty(c6777.f25897)) {
this.f25938.m31287(C6782.m31360().m31396(this.f25938.f25840));
}
if (!c6777.m31437().equalsIgnoreCase(c6777.mo31312())) {
c6777.m31285();
i = f25918;
}
}
m31470();
c6777.m31249();
return 8192;
}
i = f25932;
return i;
}
return f25922;
} finally {
m31484(randomAccessFile);
m31484(bufferedInputStream);
m31484(inputStream);
}
}
public void m31480() {
if (this.f25943) {
if (!this.f25948) {
long elapsedRealtime = SystemClock.elapsedRealtime();
if (elapsedRealtime - this.f25941 < 1200) {
return;
}
this.f25941 = elapsedRealtime;
m31463(1);
return;
}
long elapsedRealtime2 = SystemClock.elapsedRealtime();
if (elapsedRealtime2 - this.f25941 < 1200) {
m31463(0);
} else {
this.f25941 = elapsedRealtime2;
m31463(1);
}
}
}
@Override
public final C6777 cancel() {
C6777 c6777 = this.f25938;
c6777.m31255();
return c6777;
}
@Override
public C6777 mo31216() {
return cancel();
}
@Override
public void mo31449(Integer... numArr) {
C6777 c6777 = this.f25938;
C6811 c6811 = c6777.f25822;
try {
long elapsedRealtime = SystemClock.elapsedRealtime() - this.f25944;
this.f25939 = elapsedRealtime;
if (elapsedRealtime == 0) {
this.f25950 = 0L;
} else {
this.f25950 = (this.f25947 * 1000) / this.f25939;
}
if (numArr != null && numArr.length > 0 && numArr[0].intValue() == 1 && c6811 != null) {
if (this.f25942 > 0) {
c6811.m31523((int) (((this.f25951 + this.f25947) / Float.valueOf(this.f25942).floatValue()) * 100.0f));
} else {
c6811.m31521(this.f25951 + this.f25947);
}
}
if (c6777.m31252() != null) {
c6777.m31275().onProgress(c6777.m31436(), this.f25951 + this.f25947, this.f25942, c6777.m31258());
}
} catch (Throwable th) {
th.printStackTrace();
}
}
public void m31481() throws IOException {
C6777 c6777 = this.f25938;
if (c6777 == null || c6777.m31252() == null) {
return;
}
f25933.post(new RunnableC6810(c6777));
}
@Override
public int mo31241() {
C6777 c6777 = this.f25938;
if (c6777 == null) {
return 1000;
}
return c6777.m31276();
}
public void m31482(C6777 c6777) {
Objects.requireNonNull(c6777, "downloadTask can't be null.");
Objects.requireNonNull(c6777.m31257(), "context can't be null.");
}
public Integer m31483() {
String str = "";
C6777 c6777 = this.f25938;
boolean m31254 = c6777.m31254();
Integer valueOf = Integer.valueOf(f25922);
if (m31254) {
c6777.m31319();
return valueOf;
}
if (c6777.m31264()) {
return valueOf;
}
if (c6777.m31320()) {
return Integer.valueOf(f25932);
}
this.f25944 = SystemClock.elapsedRealtime();
if (!m31464()) {
C6782.m31360().m31373(f25926, " Network error,isForceDownload:" + this.f25938.m31429());
c6777.m31285();
return 16384;
}
StringBuffer stringBuffer = this.f25937;
stringBuffer.append("\r\n");
stringBuffer.append("=============");
stringBuffer.append("\n");
StringBuffer stringBuffer2 = this.f25937;
stringBuffer2.append("Download Message");
stringBuffer2.append("\n");
StringBuffer stringBuffer3 = this.f25937;
stringBuffer3.append("downloadTask id=");
stringBuffer3.append(c6777.m31248());
stringBuffer3.append("\n");
StringBuffer stringBuffer4 = this.f25937;
stringBuffer4.append("url=");
stringBuffer4.append(c6777.m31436());
stringBuffer4.append("\n");
try {
StringBuffer stringBuffer5 = this.f25937;
stringBuffer5.append("file=");
stringBuffer5.append(c6777.m31253() == null ? "" : c6777.m31253().getCanonicalPath());
stringBuffer5.append("\n");
} catch (IOException e) {
e.printStackTrace();
}
String name = Thread.currentThread().getName();
Thread.currentThread().setName("pool-download-thread-" + C6782.m31360().m31397());
try {
c6777.m31274(1002);
IOException e2 = null;
int i = 0;
int i2 = f25928;
while (i <= c6777.f25892) {
try {
i2 = m31473();
} catch (IOException e3) {
e2 = e3;
this.f25940 = e2;
if (C6782.m31360().m31398()) {
e2.printStackTrace();
}
i2 = f25928;
}
if (e2 == null) {
break;
}
if (i == c6777.f25892) {
c6777.m31285();
this.f25938.m31251(e2);
}
StringBuffer stringBuffer6 = this.f25937;
stringBuffer6.append("download error message: ");
stringBuffer6.append(e2.getMessage());
stringBuffer6.append("\n");
i++;
if (i <= c6777.f25892) {
StringBuffer stringBuffer7 = this.f25937;
stringBuffer7.append("download error , retry ");
stringBuffer7.append(i);
stringBuffer7.append("\n");
}
}
try {
StringBuffer stringBuffer8 = this.f25937;
stringBuffer8.append("final output file=");
if (c6777.m31253() != null) {
str = c6777.m31253().getCanonicalPath();
}
stringBuffer8.append(str);
stringBuffer8.append("\n");
} catch (IOException e4) {
e4.printStackTrace();
}
if (c6777.m31428() != null && !c6777.m31428().isEmpty()) {
StringBuffer stringBuffer9 = this.f25937;
stringBuffer9.append("custom request headers=");
stringBuffer9.append(c6777.m31428().toString());
stringBuffer9.append("\n");
}
StringBuffer stringBuffer10 = this.f25937;
stringBuffer10.append("error=");
stringBuffer10.append("0x" + Integer.toHexString(i2));
stringBuffer10.append("\n");
StringBuffer stringBuffer11 = this.f25937;
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.f25937;
stringBuffer12.append("error message=");
stringBuffer12.append(f25920.get(i2));
stringBuffer12.append("\n");
StringBuffer stringBuffer13 = this.f25937;
stringBuffer13.append("mLoaded=");
stringBuffer13.append(this.f25947);
stringBuffer13.append("\n");
StringBuffer stringBuffer14 = this.f25937;
stringBuffer14.append("mLastLoaded=");
stringBuffer14.append(this.f25951);
stringBuffer14.append("\n");
StringBuffer stringBuffer15 = this.f25937;
stringBuffer15.append("mLoaded+mLastLoaded=");
stringBuffer15.append(this.f25947 + this.f25951);
stringBuffer15.append("\n");
StringBuffer stringBuffer16 = this.f25937;
stringBuffer16.append("totals=");
stringBuffer16.append(this.f25942);
stringBuffer16.append("\n");
if (c6777.m31276() == 1005 || i2 == 16401) {
StringBuffer stringBuffer17 = this.f25937;
stringBuffer17.append("isCalculateMD5=");
stringBuffer17.append(c6777.m31431());
stringBuffer17.append("\n");
if (TextUtils.isEmpty(c6777.f25897)) {
StringBuffer stringBuffer18 = this.f25937;
stringBuffer18.append("FileMD5=");
stringBuffer18.append("''");
stringBuffer18.append("\n");
} else {
StringBuffer stringBuffer19 = this.f25937;
stringBuffer19.append("FileMD5=");
stringBuffer19.append(c6777.f25897);
stringBuffer19.append("\n");
}
}
if (!TextUtils.isEmpty(c6777.m31437())) {
StringBuffer stringBuffer20 = this.f25937;
stringBuffer20.append("targetCompareMD5=");
stringBuffer20.append(c6777.m31437());
stringBuffer20.append("\n");
}
StringBuffer stringBuffer21 = this.f25937;
stringBuffer21.append("current downloadTask status=");
stringBuffer21.append(c6777.m31276());
stringBuffer21.append("\n");
StringBuffer stringBuffer22 = this.f25937;
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.f25937;
stringBuffer23.append("used time=");
stringBuffer23.append(c6777.m31258());
stringBuffer23.append("ms");
stringBuffer23.append("\n");
this.f25937.append("\r\n");
C6782.m31360().m31400(f25926, "\r\n" + this.f25937.toString());
Thread.currentThread().setName(name);
return Integer.valueOf(i2);
} catch (Throwable th) {
Thread.currentThread().setName(name);
throw th;
}
}
@Override
public C6777 mo31217() {
return this.f25938;
}
@Override
public boolean mo31242(C6777 c6777) {
return true;
}
public void m31484(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public C6777 mo31218() {
return m31475();
}
}