jimu-decompiled/sources/com/liulishuo/filedownloader/download/FetchDataTask.java
2025-05-13 19:24:51 +02:00

161 lines
5.5 KiB
Java

package com.liulishuo.filedownloader.download;
import android.os.SystemClock;
import com.liulishuo.filedownloader.connection.FileDownloadConnection;
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
import com.liulishuo.filedownloader.stream.FileDownloadOutputStream;
import com.liulishuo.filedownloader.util.FileDownloadLog;
import com.liulishuo.filedownloader.util.FileDownloadUtils;
import java.io.IOException;
/* loaded from: classes.dex */
public class FetchDataTask {
private final ProcessCallback a;
private final int b;
private final int c;
private final DownloadRunnable d;
private final FileDownloadConnection e;
private final boolean f;
private final long g;
private final long h;
private final long i;
private final String j;
long k;
private FileDownloadOutputStream l;
private volatile boolean m;
private final FileDownloadDatabase n;
private volatile long o;
private volatile long p;
public static class Builder {
DownloadRunnable a;
FileDownloadConnection b;
ConnectionProfile c;
ProcessCallback d;
String e;
Boolean f;
Integer g;
Integer h;
public Builder a(FileDownloadConnection fileDownloadConnection) {
this.b = fileDownloadConnection;
return this;
}
public Builder b(int i) {
this.h = Integer.valueOf(i);
return this;
}
public Builder a(ConnectionProfile connectionProfile) {
this.c = connectionProfile;
return this;
}
public Builder a(ProcessCallback processCallback) {
this.d = processCallback;
return this;
}
public Builder a(String str) {
this.e = str;
return this;
}
public Builder a(boolean z) {
this.f = Boolean.valueOf(z);
return this;
}
public Builder a(DownloadRunnable downloadRunnable) {
this.a = downloadRunnable;
return this;
}
public Builder a(int i) {
this.g = Integer.valueOf(i);
return this;
}
public FetchDataTask a() throws IllegalArgumentException {
FileDownloadConnection fileDownloadConnection;
ConnectionProfile connectionProfile;
Integer num;
if (this.f != null && (fileDownloadConnection = this.b) != null && (connectionProfile = this.c) != null && this.d != null && this.e != null && (num = this.h) != null && this.g != null) {
return new FetchDataTask(fileDownloadConnection, connectionProfile, this.a, num.intValue(), this.g.intValue(), this.f.booleanValue(), this.d, this.e);
}
throw new IllegalArgumentException();
}
}
private void c() {
long elapsedRealtime = SystemClock.elapsedRealtime();
if (FileDownloadUtils.a(this.k - this.o, elapsedRealtime - this.p)) {
d();
this.o = this.k;
this.p = elapsedRealtime;
}
}
private void d() {
boolean z;
long uptimeMillis = SystemClock.uptimeMillis();
try {
this.l.a();
z = true;
} catch (IOException e) {
if (FileDownloadLog.a) {
FileDownloadLog.a(this, "Because of the system cannot guarantee that all the buffers have been synchronized with physical media, or write to filefailed, we just not flushAndSync process to database too %s", e);
}
z = false;
}
if (z) {
if (this.c >= 0) {
this.n.a(this.b, this.c, this.k);
} else {
this.a.a();
}
if (FileDownloadLog.a) {
FileDownloadLog.a(this, "require flushAndSync id[%d] index[%d] offset[%d], consume[%d]", Integer.valueOf(this.b), Integer.valueOf(this.c), Long.valueOf(this.k), Long.valueOf(SystemClock.uptimeMillis() - uptimeMillis));
}
}
}
public void a() {
this.m = true;
}
/* JADX WARN: Code restructure failed: missing block: B:83:0x01f9, code lost:
throw new com.liulishuo.filedownloader.exception.FileDownloadNetworkPolicyException();
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void b() throws java.io.IOException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, com.liulishuo.filedownloader.exception.FileDownloadGiveUpRetryException {
/*
Method dump skipped, instructions count: 589
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.FetchDataTask.b():void");
}
private FetchDataTask(FileDownloadConnection fileDownloadConnection, ConnectionProfile connectionProfile, DownloadRunnable downloadRunnable, int i, int i2, boolean z, ProcessCallback processCallback, String str) {
this.o = 0L;
this.p = 0L;
this.a = processCallback;
this.j = str;
this.e = fileDownloadConnection;
this.f = z;
this.d = downloadRunnable;
this.c = i2;
this.b = i;
this.n = CustomComponentHolder.i().a();
this.g = connectionProfile.a;
this.h = connectionProfile.c;
this.k = connectionProfile.b;
this.i = connectionProfile.d;
}
}