Initial commit
This commit is contained in:
169
sources/com/liulishuo/filedownloader/download/ConnectTask.java
Normal file
169
sources/com/liulishuo/filedownloader/download/ConnectTask.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.liulishuo.filedownloader.connection.FileDownloadConnection;
|
||||
import com.liulishuo.filedownloader.connection.RedirectHandler;
|
||||
import com.liulishuo.filedownloader.download.ConnectionProfile;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.io.IOException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectTask {
|
||||
final int a;
|
||||
final String b;
|
||||
final FileDownloadHeader c;
|
||||
private ConnectionProfile d;
|
||||
private String e;
|
||||
private Map<String, List<String>> f;
|
||||
private List<String> g;
|
||||
|
||||
static class Builder {
|
||||
private Integer a;
|
||||
private String b;
|
||||
private String c;
|
||||
private FileDownloadHeader d;
|
||||
private ConnectionProfile e;
|
||||
|
||||
Builder() {
|
||||
}
|
||||
|
||||
public Builder a(int i) {
|
||||
this.a = Integer.valueOf(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b(String str) {
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(String str) {
|
||||
this.c = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(FileDownloadHeader fileDownloadHeader) {
|
||||
this.d = fileDownloadHeader;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(ConnectionProfile connectionProfile) {
|
||||
this.e = connectionProfile;
|
||||
return this;
|
||||
}
|
||||
|
||||
ConnectTask a() {
|
||||
ConnectionProfile connectionProfile;
|
||||
Integer num = this.a;
|
||||
if (num != null && (connectionProfile = this.e) != null && this.b != null) {
|
||||
return new ConnectTask(connectionProfile, num.intValue(), this.b, this.c, this.d);
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void b(FileDownloadConnection fileDownloadConnection) {
|
||||
HashMap<String, List<String>> headers;
|
||||
FileDownloadHeader fileDownloadHeader = this.c;
|
||||
if (fileDownloadHeader == null || (headers = fileDownloadHeader.getHeaders()) == null) {
|
||||
return;
|
||||
}
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.d(this, "%d add outside header: %s", Integer.valueOf(this.a), headers);
|
||||
}
|
||||
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
List<String> value = entry.getValue();
|
||||
if (value != null) {
|
||||
Iterator<String> it = value.iterator();
|
||||
while (it.hasNext()) {
|
||||
fileDownloadConnection.a(key, it.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void c(FileDownloadConnection fileDownloadConnection) {
|
||||
FileDownloadHeader fileDownloadHeader = this.c;
|
||||
if (fileDownloadHeader == null || fileDownloadHeader.getHeaders().get("User-Agent") == null) {
|
||||
fileDownloadConnection.a("User-Agent", FileDownloadUtils.a());
|
||||
}
|
||||
}
|
||||
|
||||
void a(long j) {
|
||||
ConnectionProfile connectionProfile = this.d;
|
||||
long j2 = connectionProfile.b;
|
||||
if (j == j2) {
|
||||
FileDownloadLog.e(this, "no data download, no need to update", new Object[0]);
|
||||
return;
|
||||
}
|
||||
this.d = ConnectionProfile.ConnectionProfileBuild.a(connectionProfile.a, j, connectionProfile.c, connectionProfile.d - (j - j2));
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.c(this, "after update profile:%s", this.d);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, List<String>> d() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
boolean e() {
|
||||
return this.d.b > 0;
|
||||
}
|
||||
|
||||
private ConnectTask(ConnectionProfile connectionProfile, int i, String str, String str2, FileDownloadHeader fileDownloadHeader) {
|
||||
this.a = i;
|
||||
this.b = str;
|
||||
this.e = str2;
|
||||
this.c = fileDownloadHeader;
|
||||
this.d = connectionProfile;
|
||||
}
|
||||
|
||||
public ConnectionProfile c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
FileDownloadConnection a() throws IOException, IllegalAccessException {
|
||||
FileDownloadConnection a = CustomComponentHolder.i().a(this.b);
|
||||
b(a);
|
||||
a(a);
|
||||
c(a);
|
||||
this.f = a.e();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "<---- %s request header %s", Integer.valueOf(this.a), this.f);
|
||||
}
|
||||
a.execute();
|
||||
this.g = new ArrayList();
|
||||
FileDownloadConnection a2 = RedirectHandler.a(this.f, a, this.g);
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "----> %s response header %s", Integer.valueOf(this.a), a2.b());
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
|
||||
String b() {
|
||||
List<String> list = this.g;
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return this.g.get(r0.size() - 1);
|
||||
}
|
||||
|
||||
private void a(FileDownloadConnection fileDownloadConnection) throws ProtocolException {
|
||||
if (fileDownloadConnection.a(this.e, this.d.a)) {
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.e)) {
|
||||
fileDownloadConnection.a("If-Match", this.e);
|
||||
}
|
||||
this.d.a(fileDownloadConnection);
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import com.liulishuo.filedownloader.connection.FileDownloadConnection;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadProperties;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.net.ProtocolException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectionProfile {
|
||||
final long a;
|
||||
final long b;
|
||||
final long c;
|
||||
final long d;
|
||||
private final boolean e;
|
||||
private final boolean f;
|
||||
|
||||
public static class ConnectionProfileBuild {
|
||||
public static ConnectionProfile a() {
|
||||
return new ConnectionProfile();
|
||||
}
|
||||
|
||||
public static ConnectionProfile b() {
|
||||
return new ConnectionProfile(0L, 0L, 0L, 0L, true);
|
||||
}
|
||||
|
||||
public static ConnectionProfile a(long j) {
|
||||
return new ConnectionProfile(0L, 0L, -1L, j);
|
||||
}
|
||||
|
||||
public static ConnectionProfile a(long j, long j2, long j3) {
|
||||
return new ConnectionProfile(j, j2, -1L, j3);
|
||||
}
|
||||
|
||||
public static ConnectionProfile a(long j, long j2, long j3, long j4) {
|
||||
return new ConnectionProfile(j, j2, j3, j4);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(FileDownloadConnection fileDownloadConnection) throws ProtocolException {
|
||||
if (this.e) {
|
||||
return;
|
||||
}
|
||||
if (this.f && FileDownloadProperties.a().h) {
|
||||
fileDownloadConnection.b("HEAD");
|
||||
}
|
||||
fileDownloadConnection.a("Range", this.c == -1 ? FileDownloadUtils.a("bytes=%d-", Long.valueOf(this.b)) : FileDownloadUtils.a("bytes=%d-%d", Long.valueOf(this.b), Long.valueOf(this.c)));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return FileDownloadUtils.a("range[%d, %d) current offset[%d]", Long.valueOf(this.a), Long.valueOf(this.c), Long.valueOf(this.b));
|
||||
}
|
||||
|
||||
private ConnectionProfile() {
|
||||
this.a = 0L;
|
||||
this.b = 0L;
|
||||
this.c = 0L;
|
||||
this.d = 0L;
|
||||
this.e = false;
|
||||
this.f = true;
|
||||
}
|
||||
|
||||
private ConnectionProfile(long j, long j2, long j3, long j4) {
|
||||
this(j, j2, j3, j4, false);
|
||||
}
|
||||
|
||||
private ConnectionProfile(long j, long j2, long j3, long j4, boolean z) {
|
||||
if ((j == 0 && j3 == 0) || !z) {
|
||||
this.a = j;
|
||||
this.b = j2;
|
||||
this.c = j3;
|
||||
this.d = j4;
|
||||
this.e = z;
|
||||
this.f = false;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
@@ -0,0 +1,168 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import com.liulishuo.filedownloader.connection.FileDownloadConnection;
|
||||
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
||||
import com.liulishuo.filedownloader.services.DownloadMgrInitialParams;
|
||||
import com.liulishuo.filedownloader.services.ForegroundServiceConfig;
|
||||
import com.liulishuo.filedownloader.stream.FileDownloadOutputStream;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CustomComponentHolder {
|
||||
private DownloadMgrInitialParams a;
|
||||
private FileDownloadHelper.ConnectionCountAdapter b;
|
||||
private FileDownloadHelper.ConnectionCreator c;
|
||||
private FileDownloadHelper.OutputStreamCreator d;
|
||||
private FileDownloadDatabase e;
|
||||
private FileDownloadHelper.IdGenerator f;
|
||||
private ForegroundServiceConfig g;
|
||||
|
||||
private static final class LazyLoader {
|
||||
private static final CustomComponentHolder a = new CustomComponentHolder();
|
||||
}
|
||||
|
||||
private FileDownloadHelper.ConnectionCountAdapter f() {
|
||||
FileDownloadHelper.ConnectionCountAdapter connectionCountAdapter = this.b;
|
||||
if (connectionCountAdapter != null) {
|
||||
return connectionCountAdapter;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.b == null) {
|
||||
this.b = h().a();
|
||||
}
|
||||
}
|
||||
return this.b;
|
||||
}
|
||||
|
||||
private FileDownloadHelper.ConnectionCreator g() {
|
||||
FileDownloadHelper.ConnectionCreator connectionCreator = this.c;
|
||||
if (connectionCreator != null) {
|
||||
return connectionCreator;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.c == null) {
|
||||
this.c = h().b();
|
||||
}
|
||||
}
|
||||
return this.c;
|
||||
}
|
||||
|
||||
private DownloadMgrInitialParams h() {
|
||||
DownloadMgrInitialParams downloadMgrInitialParams = this.a;
|
||||
if (downloadMgrInitialParams != null) {
|
||||
return downloadMgrInitialParams;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.a == null) {
|
||||
this.a = new DownloadMgrInitialParams();
|
||||
}
|
||||
}
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public static CustomComponentHolder i() {
|
||||
return LazyLoader.a;
|
||||
}
|
||||
|
||||
private FileDownloadHelper.OutputStreamCreator j() {
|
||||
FileDownloadHelper.OutputStreamCreator outputStreamCreator = this.d;
|
||||
if (outputStreamCreator != null) {
|
||||
return outputStreamCreator;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.d == null) {
|
||||
this.d = h().f();
|
||||
}
|
||||
}
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public FileDownloadConnection a(String str) throws IOException {
|
||||
return g().a(str);
|
||||
}
|
||||
|
||||
public ForegroundServiceConfig b() {
|
||||
ForegroundServiceConfig foregroundServiceConfig = this.g;
|
||||
if (foregroundServiceConfig != null) {
|
||||
return foregroundServiceConfig;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.g == null) {
|
||||
this.g = h().d();
|
||||
}
|
||||
}
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public FileDownloadHelper.IdGenerator c() {
|
||||
FileDownloadHelper.IdGenerator idGenerator = this.f;
|
||||
if (idGenerator != null) {
|
||||
return idGenerator;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.f == null) {
|
||||
this.f = h().e();
|
||||
}
|
||||
}
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public int d() {
|
||||
return h().g();
|
||||
}
|
||||
|
||||
public boolean e() {
|
||||
return j().a();
|
||||
}
|
||||
|
||||
public FileDownloadOutputStream a(File file) throws IOException {
|
||||
return j().a(file);
|
||||
}
|
||||
|
||||
public FileDownloadDatabase a() {
|
||||
FileDownloadDatabase fileDownloadDatabase = this.e;
|
||||
if (fileDownloadDatabase != null) {
|
||||
return fileDownloadDatabase;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.e == null) {
|
||||
this.e = h().c();
|
||||
a(this.e.a());
|
||||
}
|
||||
}
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public int a(int i, String str, String str2, long j) {
|
||||
return f().a(i, str, str2, j);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:55:0x00d4, code lost:
|
||||
|
||||
if (r8.getSoFar() > 0) goto L46;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:79:0x0051, code lost:
|
||||
|
||||
if (r8.getSoFar() <= 0) goto L18;
|
||||
*/
|
||||
/* JADX WARN: Removed duplicated region for block: B:12:0x005c */
|
||||
/* JADX WARN: Removed duplicated region for block: B:15:0x00fb A[Catch: all -> 0x013f, TryCatch #3 {all -> 0x013f, blocks: (B:26:0x00f1, B:15:0x00fb, B:17:0x0111, B:19:0x0115, B:20:0x012d, B:21:0x0134, B:51:0x00a3, B:52:0x00c5, B:54:0x00cc, B:57:0x00da, B:60:0x00e5), top: B:25:0x00f1 }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:25:0x00f1 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:33:0x019b */
|
||||
/* JADX WARN: Removed duplicated region for block: B:36:0x0065 A[Catch: all -> 0x0141, TryCatch #0 {all -> 0x0141, blocks: (B:72:0x0034, B:74:0x003b, B:76:0x0042, B:78:0x0049, B:10:0x0056, B:36:0x0065, B:38:0x0070, B:9:0x0053), top: B:71:0x0034 }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:54:0x00cc A[Catch: all -> 0x013f, TryCatch #3 {all -> 0x013f, blocks: (B:26:0x00f1, B:15:0x00fb, B:17:0x0111, B:19:0x0115, B:20:0x012d, B:21:0x0134, B:51:0x00a3, B:52:0x00c5, B:54:0x00cc, B:57:0x00da, B:60:0x00e5), top: B:25:0x00f1 }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:64:0x00d8 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private static void a(com.liulishuo.filedownloader.database.FileDownloadDatabase.Maintainer r26) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 452
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.CustomComponentHolder.a(com.liulishuo.filedownloader.database.FileDownloadDatabase$Maintainer):void");
|
||||
}
|
||||
}
|
@@ -0,0 +1,619 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import com.liulishuo.filedownloader.IThreadPoolMonitor;
|
||||
import com.liulishuo.filedownloader.connection.FileDownloadConnection;
|
||||
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
||||
import com.liulishuo.filedownloader.download.ConnectTask;
|
||||
import com.liulishuo.filedownloader.download.ConnectionProfile;
|
||||
import com.liulishuo.filedownloader.download.DownloadRunnable;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadGiveUpRetryException;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadHttpException;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadNetworkPolicyException;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadOutOfSpaceException;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadSecurityException;
|
||||
import com.liulishuo.filedownloader.model.ConnectionModel;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.liulishuo.filedownloader.stream.FileDownloadOutputStream;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadExecutors;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadProperties;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadLaunchRunnable implements Runnable, ProcessCallback {
|
||||
private static final ThreadPoolExecutor x = FileDownloadExecutors.a("ConnectionBlock");
|
||||
private final DownloadStatusCallback a;
|
||||
private final FileDownloadModel b;
|
||||
private final FileDownloadHeader c;
|
||||
private final boolean d;
|
||||
private final boolean e;
|
||||
private final FileDownloadDatabase f;
|
||||
private final IThreadPoolMonitor g;
|
||||
private boolean h;
|
||||
int i;
|
||||
private boolean j;
|
||||
private final boolean k;
|
||||
private final ArrayList<DownloadRunnable> l;
|
||||
private DownloadRunnable m;
|
||||
private boolean n;
|
||||
private boolean o;
|
||||
private boolean p;
|
||||
private boolean q;
|
||||
private final AtomicBoolean r;
|
||||
private volatile boolean s;
|
||||
private volatile boolean t;
|
||||
private volatile Exception u;
|
||||
private String v;
|
||||
|
||||
public static class Builder {
|
||||
private FileDownloadModel a;
|
||||
private FileDownloadHeader b;
|
||||
private IThreadPoolMonitor c;
|
||||
private Integer d;
|
||||
private Integer e;
|
||||
private Boolean f;
|
||||
private Boolean g;
|
||||
private Integer h;
|
||||
|
||||
public Builder a(FileDownloadModel fileDownloadModel) {
|
||||
this.a = fileDownloadModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b(Boolean bool) {
|
||||
this.g = bool;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder c(Integer num) {
|
||||
this.d = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(FileDownloadHeader fileDownloadHeader) {
|
||||
this.b = fileDownloadHeader;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b(Integer num) {
|
||||
this.h = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(IThreadPoolMonitor iThreadPoolMonitor) {
|
||||
this.c = iThreadPoolMonitor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(Integer num) {
|
||||
this.e = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(Boolean bool) {
|
||||
this.f = bool;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadLaunchRunnable a() {
|
||||
IThreadPoolMonitor iThreadPoolMonitor;
|
||||
Integer num;
|
||||
FileDownloadModel fileDownloadModel = this.a;
|
||||
if (fileDownloadModel != null && (iThreadPoolMonitor = this.c) != null && (num = this.d) != null && this.e != null && this.f != null && this.g != null && this.h != null) {
|
||||
return new DownloadLaunchRunnable(fileDownloadModel, this.b, iThreadPoolMonitor, num.intValue(), this.e.intValue(), this.f.booleanValue(), this.g.booleanValue(), this.h.intValue());
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
class DiscardSafely extends Throwable {
|
||||
DiscardSafely(DownloadLaunchRunnable downloadLaunchRunnable) {
|
||||
}
|
||||
}
|
||||
|
||||
class RetryDirectly extends Throwable {
|
||||
RetryDirectly(DownloadLaunchRunnable downloadLaunchRunnable) {
|
||||
}
|
||||
}
|
||||
|
||||
private int b(long j) {
|
||||
if (k()) {
|
||||
return this.o ? this.b.getConnectionCount() : CustomComponentHolder.i().a(this.b.getId(), this.b.getUrl(), this.b.getPath(), j);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void c(long j) throws IOException, IllegalAccessException {
|
||||
ConnectionProfile a;
|
||||
if (this.p) {
|
||||
a = ConnectionProfile.ConnectionProfileBuild.a(this.b.getSoFar(), this.b.getSoFar(), j - this.b.getSoFar());
|
||||
} else {
|
||||
this.b.setSoFar(0L);
|
||||
a = ConnectionProfile.ConnectionProfileBuild.a(j);
|
||||
}
|
||||
DownloadRunnable.Builder builder = new DownloadRunnable.Builder();
|
||||
builder.a(this.b.getId());
|
||||
builder.a((Integer) (-1));
|
||||
builder.a(this);
|
||||
builder.c(this.b.getUrl());
|
||||
builder.a(this.b.getETag());
|
||||
builder.a(this.c);
|
||||
builder.a(this.e);
|
||||
builder.a(a);
|
||||
builder.b(this.b.getTempFilePath());
|
||||
this.m = builder.a();
|
||||
this.b.setConnectionCount(1);
|
||||
this.f.a(this.b.getId(), 1);
|
||||
if (!this.s) {
|
||||
this.m.run();
|
||||
} else {
|
||||
this.b.setStatus((byte) -2);
|
||||
this.m.pause();
|
||||
}
|
||||
}
|
||||
|
||||
private void f() throws RetryDirectly, DiscardSafely {
|
||||
int id = this.b.getId();
|
||||
if (this.b.isPathAsDirectory()) {
|
||||
String targetFilePath = this.b.getTargetFilePath();
|
||||
int c = FileDownloadUtils.c(this.b.getUrl(), targetFilePath);
|
||||
if (FileDownloadHelper.a(id, targetFilePath, this.d, false)) {
|
||||
this.f.remove(id);
|
||||
this.f.b(id);
|
||||
throw new DiscardSafely(this);
|
||||
}
|
||||
FileDownloadModel e = this.f.e(c);
|
||||
if (e != null) {
|
||||
if (FileDownloadHelper.a(id, e, this.g, false)) {
|
||||
this.f.remove(id);
|
||||
this.f.b(id);
|
||||
throw new DiscardSafely(this);
|
||||
}
|
||||
List<ConnectionModel> d = this.f.d(c);
|
||||
this.f.remove(c);
|
||||
this.f.b(c);
|
||||
FileDownloadUtils.d(this.b.getTargetFilePath());
|
||||
if (FileDownloadUtils.a(c, e)) {
|
||||
this.b.setSoFar(e.getSoFar());
|
||||
this.b.setTotal(e.getTotal());
|
||||
this.b.setETag(e.getETag());
|
||||
this.b.setConnectionCount(e.getConnectionCount());
|
||||
this.f.a(this.b);
|
||||
if (d != null) {
|
||||
for (ConnectionModel connectionModel : d) {
|
||||
connectionModel.a(id);
|
||||
this.f.a(connectionModel);
|
||||
}
|
||||
}
|
||||
throw new RetryDirectly(this);
|
||||
}
|
||||
}
|
||||
if (FileDownloadHelper.a(id, this.b.getSoFar(), this.b.getTempFilePath(), targetFilePath, this.g)) {
|
||||
this.f.remove(id);
|
||||
this.f.b(id);
|
||||
throw new DiscardSafely(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void j() throws FileDownloadGiveUpRetryException {
|
||||
if (this.e && !FileDownloadUtils.a("android.permission.ACCESS_NETWORK_STATE")) {
|
||||
throw new FileDownloadGiveUpRetryException(FileDownloadUtils.a("Task[%d] can't start the download runnable, because this task require wifi, but user application nor current process has %s, so we can't check whether the network type connection.", Integer.valueOf(this.b.getId()), "android.permission.ACCESS_NETWORK_STATE"));
|
||||
}
|
||||
if (this.e && FileDownloadUtils.e()) {
|
||||
throw new FileDownloadNetworkPolicyException();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean k() {
|
||||
return (!this.o || this.b.getConnectionCount() > 1) && this.p && this.k && !this.q;
|
||||
}
|
||||
|
||||
private void l() throws IOException, RetryDirectly, IllegalAccessException, FileDownloadSecurityException {
|
||||
FileDownloadConnection fileDownloadConnection = null;
|
||||
try {
|
||||
ConnectionProfile b = this.j ? ConnectionProfile.ConnectionProfileBuild.b() : ConnectionProfile.ConnectionProfileBuild.a();
|
||||
ConnectTask.Builder builder = new ConnectTask.Builder();
|
||||
builder.a(this.b.getId());
|
||||
builder.b(this.b.getUrl());
|
||||
builder.a(this.b.getETag());
|
||||
builder.a(this.c);
|
||||
builder.a(b);
|
||||
ConnectTask a = builder.a();
|
||||
fileDownloadConnection = a.a();
|
||||
a(a.d(), a, fileDownloadConnection);
|
||||
} finally {
|
||||
if (fileDownloadConnection != null) {
|
||||
fileDownloadConnection.d();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:12:0x0068 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:15:? A[RETURN, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:9:0x0061 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
void a(java.util.List<com.liulishuo.filedownloader.model.ConnectionModel> r11) {
|
||||
/*
|
||||
r10 = this;
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r0 = r10.b
|
||||
int r0 = r0.getConnectionCount()
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r1 = r10.b
|
||||
java.lang.String r1 = r1.getTempFilePath()
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r2 = r10.b
|
||||
java.lang.String r2 = r2.getTargetFilePath()
|
||||
r3 = 0
|
||||
r4 = 1
|
||||
if (r0 <= r4) goto L18
|
||||
r5 = 1
|
||||
goto L19
|
||||
L18:
|
||||
r5 = 0
|
||||
L19:
|
||||
boolean r6 = r10.j
|
||||
r7 = 0
|
||||
if (r6 == 0) goto L21
|
||||
L1f:
|
||||
r5 = r7
|
||||
goto L58
|
||||
L21:
|
||||
if (r5 == 0) goto L28
|
||||
boolean r6 = r10.k
|
||||
if (r6 != 0) goto L28
|
||||
goto L1f
|
||||
L28:
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r6 = r10.b
|
||||
int r6 = r6.getId()
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r9 = r10.b
|
||||
boolean r6 = com.liulishuo.filedownloader.util.FileDownloadUtils.a(r6, r9)
|
||||
if (r6 == 0) goto L1f
|
||||
boolean r6 = r10.k
|
||||
if (r6 != 0) goto L44
|
||||
java.io.File r11 = new java.io.File
|
||||
r11.<init>(r1)
|
||||
long r5 = r11.length()
|
||||
goto L58
|
||||
L44:
|
||||
if (r5 == 0) goto L52
|
||||
int r5 = r11.size()
|
||||
if (r0 == r5) goto L4d
|
||||
goto L1f
|
||||
L4d:
|
||||
long r5 = com.liulishuo.filedownloader.model.ConnectionModel.a(r11)
|
||||
goto L58
|
||||
L52:
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r11 = r10.b
|
||||
long r5 = r11.getSoFar()
|
||||
L58:
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r11 = r10.b
|
||||
r11.setSoFar(r5)
|
||||
int r11 = (r5 > r7 ? 1 : (r5 == r7 ? 0 : -1))
|
||||
if (r11 <= 0) goto L62
|
||||
r3 = 1
|
||||
L62:
|
||||
r10.o = r3
|
||||
boolean r11 = r10.o
|
||||
if (r11 != 0) goto L76
|
||||
com.liulishuo.filedownloader.database.FileDownloadDatabase r11 = r10.f
|
||||
com.liulishuo.filedownloader.model.FileDownloadModel r0 = r10.b
|
||||
int r0 = r0.getId()
|
||||
r11.b(r0)
|
||||
com.liulishuo.filedownloader.util.FileDownloadUtils.a(r2, r1)
|
||||
L76:
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.DownloadLaunchRunnable.a(java.util.List):void");
|
||||
}
|
||||
|
||||
public boolean d() {
|
||||
return this.r.get() || this.a.b();
|
||||
}
|
||||
|
||||
public void e() {
|
||||
a(this.f.d(this.b.getId()));
|
||||
this.a.f();
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
this.s = true;
|
||||
DownloadRunnable downloadRunnable = this.m;
|
||||
if (downloadRunnable != null) {
|
||||
downloadRunnable.pause();
|
||||
}
|
||||
Iterator it = ((ArrayList) this.l.clone()).iterator();
|
||||
while (it.hasNext()) {
|
||||
DownloadRunnable downloadRunnable2 = (DownloadRunnable) it.next();
|
||||
if (downloadRunnable2 != null) {
|
||||
downloadRunnable2.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:106:0x01c3 A[Catch: all -> 0x01f8, TryCatch #13 {all -> 0x01f8, blocks: (B:3:0x0003, B:6:0x0012, B:8:0x001a, B:10:0x001e, B:25:0x0030, B:26:0x008d, B:28:0x0091, B:30:0x0096, B:116:0x009a, B:118:0x009e, B:33:0x00c6, B:35:0x00e2, B:44:0x0100, B:56:0x0136, B:58:0x013a, B:69:0x015f, B:71:0x0165, B:85:0x0169, B:87:0x0172, B:88:0x0176, B:90:0x017a, B:91:0x018d, B:100:0x018e, B:104:0x01bd, B:106:0x01c3, B:109:0x01c8), top: B:2:0x0003, inners: #15, #12, #11 }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:108:0x01c8 A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:74:0x01d4 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:77:0x01da */
|
||||
@Override // java.lang.Runnable
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void run() {
|
||||
/*
|
||||
Method dump skipped, instructions count: 550
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.DownloadLaunchRunnable.run():void");
|
||||
}
|
||||
|
||||
private DownloadLaunchRunnable(FileDownloadModel fileDownloadModel, FileDownloadHeader fileDownloadHeader, IThreadPoolMonitor iThreadPoolMonitor, int i, int i2, boolean z, boolean z2, int i3) {
|
||||
this.j = false;
|
||||
this.l = new ArrayList<>(5);
|
||||
this.r = new AtomicBoolean(true);
|
||||
this.s = false;
|
||||
this.h = false;
|
||||
this.b = fileDownloadModel;
|
||||
this.c = fileDownloadHeader;
|
||||
this.d = z;
|
||||
this.e = z2;
|
||||
this.f = CustomComponentHolder.i().a();
|
||||
this.k = CustomComponentHolder.i().e();
|
||||
this.g = iThreadPoolMonitor;
|
||||
this.i = i3;
|
||||
this.a = new DownloadStatusCallback(fileDownloadModel, i3, i, i2);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public void b(Exception exc) {
|
||||
if (this.s) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "the task[%d] has already been paused, so pass the retry callback", Integer.valueOf(this.b.getId()));
|
||||
}
|
||||
} else {
|
||||
int i = this.i;
|
||||
this.i = i - 1;
|
||||
if (i < 0) {
|
||||
FileDownloadLog.b(this, "valid retry times is less than 0(%d) for download task(%d)", Integer.valueOf(this.i), Integer.valueOf(this.b.getId()));
|
||||
}
|
||||
this.a.a(exc, this.i);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:11:0x008a */
|
||||
/* JADX WARN: Removed duplicated region for block: B:22:0x011b */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void a(java.util.Map<java.lang.String, java.util.List<java.lang.String>> r18, com.liulishuo.filedownloader.download.ConnectTask r19, com.liulishuo.filedownloader.connection.FileDownloadConnection r20) throws java.io.IOException, com.liulishuo.filedownloader.download.DownloadLaunchRunnable.RetryDirectly, java.lang.IllegalArgumentException, com.liulishuo.filedownloader.exception.FileDownloadSecurityException {
|
||||
/*
|
||||
Method dump skipped, instructions count: 357
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.DownloadLaunchRunnable.a(java.util.Map, com.liulishuo.filedownloader.download.ConnectTask, com.liulishuo.filedownloader.connection.FileDownloadConnection):void");
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.b.getId();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public boolean c(Exception exc) {
|
||||
if (exc instanceof FileDownloadHttpException) {
|
||||
int code = ((FileDownloadHttpException) exc).getCode();
|
||||
if (this.n && code == 416 && !this.h) {
|
||||
FileDownloadUtils.a(this.b.getTargetFilePath(), this.b.getTempFilePath());
|
||||
this.h = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.i > 0 && !(exc instanceof FileDownloadGiveUpRetryException);
|
||||
}
|
||||
|
||||
public String c() {
|
||||
return this.b.getTempFilePath();
|
||||
}
|
||||
|
||||
private void a(int i, List<ConnectionModel> list) throws InterruptedException {
|
||||
if (i > 1 && list.size() == i) {
|
||||
a(list, this.b.getTotal());
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
private void a(long j, int i) throws InterruptedException {
|
||||
long j2 = j / i;
|
||||
int id = this.b.getId();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
long j3 = 0;
|
||||
int i2 = 0;
|
||||
while (i2 < i) {
|
||||
long j4 = i2 == i + (-1) ? -1L : (j3 + j2) - 1;
|
||||
ConnectionModel connectionModel = new ConnectionModel();
|
||||
connectionModel.a(id);
|
||||
connectionModel.b(i2);
|
||||
connectionModel.c(j3);
|
||||
connectionModel.a(j3);
|
||||
connectionModel.b(j4);
|
||||
arrayList.add(connectionModel);
|
||||
this.f.a(connectionModel);
|
||||
j3 += j2;
|
||||
i2++;
|
||||
}
|
||||
this.b.setConnectionCount(i);
|
||||
this.f.a(id, i);
|
||||
a(arrayList, j);
|
||||
}
|
||||
|
||||
private void a(List<ConnectionModel> list, long j) throws InterruptedException {
|
||||
long b;
|
||||
int id = this.b.getId();
|
||||
String eTag = this.b.getETag();
|
||||
String str = this.v;
|
||||
if (str == null) {
|
||||
str = this.b.getUrl();
|
||||
}
|
||||
String tempFilePath = this.b.getTempFilePath();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "fetch data with multiple connection(count: [%d]) for task[%d] totalLength[%d]", Integer.valueOf(list.size()), Integer.valueOf(id), Long.valueOf(j));
|
||||
}
|
||||
boolean z = this.o;
|
||||
long j2 = 0;
|
||||
long j3 = 0;
|
||||
for (ConnectionModel connectionModel : list) {
|
||||
if (connectionModel.b() == -1) {
|
||||
b = j - connectionModel.a();
|
||||
} else {
|
||||
b = (connectionModel.b() - connectionModel.a()) + 1;
|
||||
}
|
||||
long j4 = b;
|
||||
j3 += connectionModel.a() - connectionModel.e();
|
||||
if (j4 == j2) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "pass connection[%d-%d], because it has been completed", Integer.valueOf(connectionModel.c()), Integer.valueOf(connectionModel.d()));
|
||||
}
|
||||
} else {
|
||||
DownloadRunnable.Builder builder = new DownloadRunnable.Builder();
|
||||
ConnectionProfile a = ConnectionProfile.ConnectionProfileBuild.a(connectionModel.e(), connectionModel.a(), connectionModel.b(), j4);
|
||||
builder.a(id);
|
||||
builder.a(Integer.valueOf(connectionModel.d()));
|
||||
builder.a(this);
|
||||
builder.c(str);
|
||||
builder.a(z ? eTag : null);
|
||||
builder.a(this.c);
|
||||
builder.a(this.e);
|
||||
builder.a(a);
|
||||
builder.b(tempFilePath);
|
||||
DownloadRunnable a2 = builder.a();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "enable multiple connection: %s", connectionModel);
|
||||
}
|
||||
if (a2 != null) {
|
||||
this.l.add(a2);
|
||||
} else {
|
||||
throw new IllegalArgumentException("the download runnable must not be null!");
|
||||
}
|
||||
}
|
||||
j2 = 0;
|
||||
}
|
||||
if (j3 != this.b.getSoFar()) {
|
||||
FileDownloadLog.e(this, "correct the sofar[%d] from connection table[%d]", Long.valueOf(this.b.getSoFar()), Long.valueOf(j3));
|
||||
this.b.setSoFar(j3);
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(this.l.size());
|
||||
Iterator<DownloadRunnable> it = this.l.iterator();
|
||||
while (it.hasNext()) {
|
||||
DownloadRunnable next = it.next();
|
||||
if (this.s) {
|
||||
next.pause();
|
||||
} else {
|
||||
arrayList.add(Executors.callable(next));
|
||||
}
|
||||
}
|
||||
if (this.s) {
|
||||
this.b.setStatus((byte) -2);
|
||||
return;
|
||||
}
|
||||
List<Future> invokeAll = x.invokeAll(arrayList);
|
||||
if (FileDownloadLog.a) {
|
||||
for (Future future : invokeAll) {
|
||||
FileDownloadLog.a(this, "finish sub-task for [%d] %B %B", Integer.valueOf(id), Boolean.valueOf(future.isDone()), Boolean.valueOf(future.isCancelled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(long j, String str) throws IOException, IllegalAccessException {
|
||||
FileDownloadOutputStream fileDownloadOutputStream = null;
|
||||
if (j != -1) {
|
||||
try {
|
||||
fileDownloadOutputStream = FileDownloadUtils.c(this.b.getTempFilePath());
|
||||
long length = new File(str).length();
|
||||
long j2 = j - length;
|
||||
long h = FileDownloadUtils.h(str);
|
||||
if (h >= j2) {
|
||||
if (!FileDownloadProperties.a().f) {
|
||||
fileDownloadOutputStream.a(j);
|
||||
}
|
||||
} else {
|
||||
throw new FileDownloadOutOfSpaceException(h, j2, length);
|
||||
}
|
||||
} finally {
|
||||
if (0 != 0) {
|
||||
fileDownloadOutputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public void a(long j) {
|
||||
if (this.s) {
|
||||
return;
|
||||
}
|
||||
this.a.a(j);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public void a(DownloadRunnable downloadRunnable, long j, long j2) {
|
||||
if (this.s) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "the task[%d] has already been paused, so pass the completed callback", Integer.valueOf(this.b.getId()));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int i = downloadRunnable.h;
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "the connection has been completed(%d): [%d, %d) %d", Integer.valueOf(i), Long.valueOf(j), Long.valueOf(j2), Long.valueOf(this.b.getTotal()));
|
||||
}
|
||||
if (!this.n) {
|
||||
synchronized (this.l) {
|
||||
this.l.remove(downloadRunnable);
|
||||
}
|
||||
} else {
|
||||
if (j == 0 || j2 == this.b.getTotal()) {
|
||||
return;
|
||||
}
|
||||
FileDownloadLog.b(this, "the single task not completed corrected(%d, %d != %d) for task(%d)", Long.valueOf(j), Long.valueOf(j2), Long.valueOf(this.b.getTotal()), Integer.valueOf(this.b.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public void a(Exception exc) {
|
||||
this.t = true;
|
||||
this.u = exc;
|
||||
if (this.s) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "the task[%d] has already been paused, so pass the error callback", Integer.valueOf(this.b.getId()));
|
||||
}
|
||||
} else {
|
||||
Iterator it = ((ArrayList) this.l.clone()).iterator();
|
||||
while (it.hasNext()) {
|
||||
DownloadRunnable downloadRunnable = (DownloadRunnable) it.next();
|
||||
if (downloadRunnable != null) {
|
||||
downloadRunnable.a();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.download.ProcessCallback
|
||||
public void a() {
|
||||
this.f.b(this.b.getId(), this.b.getSoFar());
|
||||
}
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
||||
import com.liulishuo.filedownloader.download.ConnectTask;
|
||||
import com.liulishuo.filedownloader.model.ConnectionModel;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadRunnable implements Runnable {
|
||||
private final ConnectTask a;
|
||||
private final ProcessCallback b;
|
||||
private final String c;
|
||||
private final boolean d;
|
||||
private FetchDataTask e;
|
||||
private volatile boolean f;
|
||||
private final int g;
|
||||
final int h;
|
||||
|
||||
public static class Builder {
|
||||
private final ConnectTask.Builder a = new ConnectTask.Builder();
|
||||
private ProcessCallback b;
|
||||
private String c;
|
||||
private Boolean d;
|
||||
private Integer e;
|
||||
|
||||
public Builder a(ProcessCallback processCallback) {
|
||||
this.b = processCallback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b(String str) {
|
||||
this.c = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder c(String str) {
|
||||
this.a.b(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(int i) {
|
||||
this.a.a(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(String str) {
|
||||
this.a.a(str);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(FileDownloadHeader fileDownloadHeader) {
|
||||
this.a.a(fileDownloadHeader);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(ConnectionProfile connectionProfile) {
|
||||
this.a.a(connectionProfile);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(boolean z) {
|
||||
this.d = Boolean.valueOf(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(Integer num) {
|
||||
this.e = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DownloadRunnable a() {
|
||||
if (this.b != null && this.c != null && this.d != null && this.e != null) {
|
||||
ConnectTask a = this.a.a();
|
||||
return new DownloadRunnable(a.a, this.e.intValue(), a, this.b, this.d.booleanValue(), this.c);
|
||||
}
|
||||
throw new IllegalArgumentException(FileDownloadUtils.a("%s %s %B", this.b, this.c, this.d));
|
||||
}
|
||||
}
|
||||
|
||||
private long b() {
|
||||
FileDownloadDatabase a = CustomComponentHolder.i().a();
|
||||
if (this.h < 0) {
|
||||
return a.e(this.g).getSoFar();
|
||||
}
|
||||
for (ConnectionModel connectionModel : a.d(this.g)) {
|
||||
if (connectionModel.d() == this.h) {
|
||||
return connectionModel.a();
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
pause();
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
this.f = true;
|
||||
FetchDataTask fetchDataTask = this.e;
|
||||
if (fetchDataTask != null) {
|
||||
fetchDataTask.a();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:71:0x014f */
|
||||
@Override // java.lang.Runnable
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void run() {
|
||||
/*
|
||||
Method dump skipped, instructions count: 339
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.DownloadRunnable.run():void");
|
||||
}
|
||||
|
||||
private DownloadRunnable(int i, int i2, ConnectTask connectTask, ProcessCallback processCallback, boolean z, String str) {
|
||||
this.g = i;
|
||||
this.h = i2;
|
||||
this.f = false;
|
||||
this.b = processCallback;
|
||||
this.c = str;
|
||||
this.a = connectTask;
|
||||
this.d = z;
|
||||
}
|
||||
}
|
@@ -0,0 +1,430 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
import android.database.sqlite.SQLiteFullException;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadGiveUpRetryException;
|
||||
import com.liulishuo.filedownloader.exception.FileDownloadOutOfSpaceException;
|
||||
import com.liulishuo.filedownloader.message.MessageSnapshotFlow;
|
||||
import com.liulishuo.filedownloader.message.MessageSnapshotTaker;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.liulishuo.filedownloader.services.FileDownloadBroadcastHandler;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadProperties;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DownloadStatusCallback implements Handler.Callback {
|
||||
private final FileDownloadModel a;
|
||||
private final ProcessParams c;
|
||||
private final int d;
|
||||
private final int e;
|
||||
private final int f;
|
||||
private long g;
|
||||
private Handler h;
|
||||
private HandlerThread i;
|
||||
private volatile Thread k;
|
||||
private volatile boolean j = false;
|
||||
private volatile long l = 0;
|
||||
private final AtomicLong m = new AtomicLong();
|
||||
private final AtomicBoolean n = new AtomicBoolean(false);
|
||||
private final AtomicBoolean o = new AtomicBoolean(false);
|
||||
private final AtomicBoolean p = new AtomicBoolean(true);
|
||||
private final FileDownloadDatabase b = CustomComponentHolder.i().a();
|
||||
|
||||
public static class ProcessParams {
|
||||
private boolean a;
|
||||
private Exception b;
|
||||
private int c;
|
||||
|
||||
void a(boolean z) {
|
||||
this.a = z;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public boolean c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
void a(Exception exc) {
|
||||
this.b = exc;
|
||||
}
|
||||
|
||||
void a(int i) {
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public Exception a() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
|
||||
DownloadStatusCallback(FileDownloadModel fileDownloadModel, int i, int i2, int i3) {
|
||||
this.a = fileDownloadModel;
|
||||
this.e = i2 >= 5 ? i2 : 5;
|
||||
this.f = i3;
|
||||
this.c = new ProcessParams();
|
||||
this.d = i;
|
||||
}
|
||||
|
||||
private void h() throws IOException {
|
||||
l();
|
||||
this.a.setStatus((byte) -3);
|
||||
this.b.a(this.a.getId(), this.a.getTotal());
|
||||
this.b.b(this.a.getId());
|
||||
a((byte) -3);
|
||||
if (FileDownloadProperties.a().g) {
|
||||
FileDownloadBroadcastHandler.a(this.a);
|
||||
}
|
||||
}
|
||||
|
||||
private void i() {
|
||||
this.a.setStatus((byte) -2);
|
||||
this.b.c(this.a.getId(), this.a.getSoFar());
|
||||
a((byte) -2);
|
||||
}
|
||||
|
||||
private void j() {
|
||||
if (this.a.getSoFar() == this.a.getTotal()) {
|
||||
this.b.b(this.a.getId(), this.a.getSoFar());
|
||||
return;
|
||||
}
|
||||
if (this.o.compareAndSet(true, false)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.c(this, "handleProgress update model's status with progress", new Object[0]);
|
||||
}
|
||||
this.a.setStatus((byte) 3);
|
||||
}
|
||||
if (this.n.compareAndSet(true, false)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.c(this, "handleProgress notify user progress status", new Object[0]);
|
||||
}
|
||||
a((byte) 3);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean k() {
|
||||
if (this.a.isChunked()) {
|
||||
FileDownloadModel fileDownloadModel = this.a;
|
||||
fileDownloadModel.setTotal(fileDownloadModel.getSoFar());
|
||||
} else if (this.a.getSoFar() != this.a.getTotal()) {
|
||||
a(new FileDownloadGiveUpRetryException(FileDownloadUtils.a("sofar[%d] not equal total[%d]", Long.valueOf(this.a.getSoFar()), Long.valueOf(this.a.getTotal()))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void l() throws IOException {
|
||||
boolean z;
|
||||
String tempFilePath = this.a.getTempFilePath();
|
||||
String targetFilePath = this.a.getTargetFilePath();
|
||||
File file = new File(tempFilePath);
|
||||
try {
|
||||
File file2 = new File(targetFilePath);
|
||||
if (file2.exists()) {
|
||||
long length = file2.length();
|
||||
if (!file2.delete()) {
|
||||
throw new IOException(FileDownloadUtils.a("Can't delete the old file([%s], [%d]), so can't replace it with the new downloaded one.", targetFilePath, Long.valueOf(length)));
|
||||
}
|
||||
FileDownloadLog.e(this, "The target file([%s], [%d]) will be replaced with the new downloaded file[%d]", targetFilePath, Long.valueOf(length), Long.valueOf(file.length()));
|
||||
}
|
||||
z = !file.renameTo(file2);
|
||||
if (!z) {
|
||||
if (z && file.exists() && !file.delete()) {
|
||||
FileDownloadLog.e(this, "delete the temp file(%s) failed, on completed downloading.", tempFilePath);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
throw new IOException(FileDownloadUtils.a("Can't rename the temp downloaded file(%s) to the target file(%s)", tempFilePath, targetFilePath));
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (z && file.exists() && !file.delete()) {
|
||||
FileDownloadLog.e(this, "delete the temp file(%s) failed, on completed downloading.", tempFilePath);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
|
||||
void a() {
|
||||
Handler handler = this.h;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
this.i.quit();
|
||||
this.k = Thread.currentThread();
|
||||
while (this.j) {
|
||||
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(100L));
|
||||
}
|
||||
this.k = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
HandlerThread handlerThread = this.i;
|
||||
return handlerThread != null && handlerThread.isAlive();
|
||||
}
|
||||
|
||||
void c() throws IOException {
|
||||
if (k()) {
|
||||
return;
|
||||
}
|
||||
h();
|
||||
}
|
||||
|
||||
void d() {
|
||||
this.i = new HandlerThread("source-status-callback");
|
||||
this.i.start();
|
||||
this.h = new Handler(this.i.getLooper(), this);
|
||||
}
|
||||
|
||||
void e() {
|
||||
i();
|
||||
}
|
||||
|
||||
public void f() {
|
||||
this.a.setStatus((byte) 1);
|
||||
this.b.a(this.a.getId());
|
||||
a((byte) 1);
|
||||
}
|
||||
|
||||
void g() {
|
||||
this.a.setStatus((byte) 6);
|
||||
a((byte) 6);
|
||||
this.b.c(this.a.getId());
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:11:0x0020 A[DONT_GENERATE] */
|
||||
@Override // android.os.Handler.Callback
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public boolean handleMessage(android.os.Message r5) {
|
||||
/*
|
||||
r4 = this;
|
||||
r0 = 1
|
||||
r4.j = r0
|
||||
int r1 = r5.what
|
||||
r2 = 3
|
||||
r3 = 0
|
||||
if (r1 == r2) goto L17
|
||||
r2 = 5
|
||||
if (r1 == r2) goto Ld
|
||||
goto L1a
|
||||
Ld:
|
||||
java.lang.Object r1 = r5.obj // Catch: java.lang.Throwable -> L26
|
||||
java.lang.Exception r1 = (java.lang.Exception) r1 // Catch: java.lang.Throwable -> L26
|
||||
int r5 = r5.arg1 // Catch: java.lang.Throwable -> L26
|
||||
r4.b(r1, r5) // Catch: java.lang.Throwable -> L26
|
||||
goto L1a
|
||||
L17:
|
||||
r4.j() // Catch: java.lang.Throwable -> L26
|
||||
L1a:
|
||||
r4.j = r3
|
||||
java.lang.Thread r5 = r4.k
|
||||
if (r5 == 0) goto L25
|
||||
java.lang.Thread r5 = r4.k
|
||||
java.util.concurrent.locks.LockSupport.unpark(r5)
|
||||
L25:
|
||||
return r0
|
||||
L26:
|
||||
r5 = move-exception
|
||||
r4.j = r3
|
||||
java.lang.Thread r0 = r4.k
|
||||
if (r0 == 0) goto L32
|
||||
java.lang.Thread r0 = r4.k
|
||||
java.util.concurrent.locks.LockSupport.unpark(r0)
|
||||
L32:
|
||||
throw r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.liulishuo.filedownloader.download.DownloadStatusCallback.handleMessage(android.os.Message):boolean");
|
||||
}
|
||||
|
||||
private Exception b(Exception exc) {
|
||||
long length;
|
||||
String tempFilePath = this.a.getTempFilePath();
|
||||
if ((!this.a.isChunked() && !FileDownloadProperties.a().f) || !(exc instanceof IOException) || !new File(tempFilePath).exists()) {
|
||||
return exc;
|
||||
}
|
||||
long h = FileDownloadUtils.h(tempFilePath);
|
||||
if (h > 4096) {
|
||||
return exc;
|
||||
}
|
||||
File file = new File(tempFilePath);
|
||||
if (file.exists()) {
|
||||
length = file.length();
|
||||
} else {
|
||||
FileDownloadLog.a(this, exc, "Exception with: free space isn't enough, and the target file not exist.", new Object[0]);
|
||||
length = 0;
|
||||
}
|
||||
return Build.VERSION.SDK_INT >= 9 ? new FileDownloadOutOfSpaceException(h, 4096L, length, exc) : new FileDownloadOutOfSpaceException(h, 4096L, length);
|
||||
}
|
||||
|
||||
private void c(Exception exc) {
|
||||
Exception exc2;
|
||||
Exception b = b(exc);
|
||||
if (b instanceof SQLiteFullException) {
|
||||
a((SQLiteFullException) b);
|
||||
exc2 = b;
|
||||
} else {
|
||||
try {
|
||||
this.a.setStatus((byte) -1);
|
||||
this.a.setErrMsg(exc.toString());
|
||||
this.b.a(this.a.getId(), b, this.a.getSoFar());
|
||||
exc2 = b;
|
||||
} catch (SQLiteFullException e) {
|
||||
SQLiteFullException sQLiteFullException = e;
|
||||
a(sQLiteFullException);
|
||||
exc2 = sQLiteFullException;
|
||||
}
|
||||
}
|
||||
this.c.a(exc2);
|
||||
a((byte) -1);
|
||||
}
|
||||
|
||||
void a(boolean z, long j, String str, String str2) throws IllegalArgumentException {
|
||||
String eTag = this.a.getETag();
|
||||
if (eTag != null && !eTag.equals(str)) {
|
||||
throw new IllegalArgumentException(FileDownloadUtils.a("callback onConnected must with precondition succeed, but the etag is changes(%s != %s)", str, eTag));
|
||||
}
|
||||
this.c.a(z);
|
||||
this.a.setStatus((byte) 2);
|
||||
this.a.setTotal(j);
|
||||
this.a.setETag(str);
|
||||
this.a.setFilename(str2);
|
||||
this.b.a(this.a.getId(), j, str, str2);
|
||||
a((byte) 2);
|
||||
this.g = a(j, this.f);
|
||||
this.o.compareAndSet(false, true);
|
||||
}
|
||||
|
||||
private void b(Exception exc, int i) {
|
||||
Exception b = b(exc);
|
||||
this.c.a(b);
|
||||
this.c.a(this.d - i);
|
||||
this.a.setStatus((byte) 5);
|
||||
this.a.setErrMsg(b.toString());
|
||||
this.b.a(this.a.getId(), b);
|
||||
a((byte) 5);
|
||||
}
|
||||
|
||||
private void b(long j) {
|
||||
boolean z;
|
||||
if (!this.p.compareAndSet(true, false)) {
|
||||
long j2 = j - this.l;
|
||||
if (this.g == -1 || this.m.get() < this.g || j2 < this.e) {
|
||||
z = false;
|
||||
if (z || !this.n.compareAndSet(false, true)) {
|
||||
}
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.c(this, "inspectNeedCallbackToUser need callback to user", new Object[0]);
|
||||
}
|
||||
this.l = j;
|
||||
this.m.set(0L);
|
||||
return;
|
||||
}
|
||||
}
|
||||
z = true;
|
||||
if (z) {
|
||||
}
|
||||
}
|
||||
|
||||
void a(long j) {
|
||||
this.m.addAndGet(j);
|
||||
this.a.increaseSoFar(j);
|
||||
b(SystemClock.elapsedRealtime());
|
||||
if (this.h == null) {
|
||||
j();
|
||||
} else if (this.n.get()) {
|
||||
a(this.h.obtainMessage(3));
|
||||
}
|
||||
}
|
||||
|
||||
void a(Exception exc, int i) {
|
||||
this.m.set(0L);
|
||||
Handler handler = this.h;
|
||||
if (handler == null) {
|
||||
b(exc, i);
|
||||
} else {
|
||||
a(handler.obtainMessage(5, i, 0, exc));
|
||||
}
|
||||
}
|
||||
|
||||
void a(Exception exc) {
|
||||
c(exc);
|
||||
}
|
||||
|
||||
private synchronized void a(Message message) {
|
||||
if (!this.i.isAlive()) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "require callback %d but the host thread of the flow has already dead, what is occurred because of there are several reason can final this flow on different thread.", Integer.valueOf(message.what));
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.h.sendMessage(message);
|
||||
} catch (IllegalStateException e) {
|
||||
if (!this.i.isAlive()) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "require callback %d but the host thread of the flow has already dead, what is occurred because of there are several reason can final this flow on different thread.", Integer.valueOf(message.what));
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static long a(long j, long j2) {
|
||||
if (j2 <= 0) {
|
||||
return -1L;
|
||||
}
|
||||
if (j == -1) {
|
||||
return 1L;
|
||||
}
|
||||
long j3 = j / j2;
|
||||
if (j3 <= 0) {
|
||||
return 1L;
|
||||
}
|
||||
return j3;
|
||||
}
|
||||
|
||||
private void a(SQLiteFullException sQLiteFullException) {
|
||||
int id = this.a.getId();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "the data of the task[%d] is dirty, because the SQLite full exception[%s], so remove it from the database directly.", Integer.valueOf(id), sQLiteFullException.toString());
|
||||
}
|
||||
this.a.setErrMsg(sQLiteFullException.toString());
|
||||
this.a.setStatus((byte) -1);
|
||||
this.b.remove(id);
|
||||
this.b.b(id);
|
||||
}
|
||||
|
||||
private void a(byte b) {
|
||||
if (b == -2) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "High concurrent cause, Already paused and we don't need to call-back to Task in here, %d", Integer.valueOf(this.a.getId()));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
MessageSnapshotFlow.a().a(MessageSnapshotTaker.a(b, this.a, this.c));
|
||||
}
|
||||
}
|
160
sources/com/liulishuo/filedownloader/download/FetchDataTask.java
Normal file
160
sources/com/liulishuo/filedownloader/download/FetchDataTask.java
Normal file
@@ -0,0 +1,160 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.liulishuo.filedownloader.download;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ProcessCallback {
|
||||
void a();
|
||||
|
||||
void a(long j);
|
||||
|
||||
void a(DownloadRunnable downloadRunnable, long j, long j2);
|
||||
|
||||
void a(Exception exc);
|
||||
|
||||
void b(Exception exc);
|
||||
|
||||
boolean c(Exception exc);
|
||||
}
|
Reference in New Issue
Block a user