Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
package com.liulishuo.filedownloader.model;
import android.content.ContentValues;
import com.liulishuo.filedownloader.util.FileDownloadUtils;
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
import java.util.List;
/* loaded from: classes.dex */
public class ConnectionModel {
private int a;
private int b;
private long c;
private long d;
private long e;
public void a(int i) {
this.a = i;
}
public void b(int i) {
this.b = i;
}
public int c() {
return this.a;
}
public int d() {
return this.b;
}
public long e() {
return this.c;
}
public ContentValues f() {
ContentValues contentValues = new ContentValues();
contentValues.put(JockstickDataConverter.ID, Integer.valueOf(this.a));
contentValues.put("connectionIndex", Integer.valueOf(this.b));
contentValues.put("startOffset", Long.valueOf(this.c));
contentValues.put("currentOffset", Long.valueOf(this.d));
contentValues.put("endOffset", Long.valueOf(this.e));
return contentValues;
}
public String toString() {
return FileDownloadUtils.a("id[%d] index[%d] range[%d, %d) current offset(%d)", Integer.valueOf(this.a), Integer.valueOf(this.b), Long.valueOf(this.c), Long.valueOf(this.e), Long.valueOf(this.d));
}
public long a() {
return this.d;
}
public long b() {
return this.e;
}
public void c(long j) {
this.c = j;
}
public void a(long j) {
this.d = j;
}
public void b(long j) {
this.e = j;
}
public static long a(List<ConnectionModel> list) {
long j = 0;
for (ConnectionModel connectionModel : list) {
j += connectionModel.a() - connectionModel.e();
}
return j;
}
}

View File

@@ -0,0 +1,87 @@
package com.liulishuo.filedownloader.model;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/* loaded from: classes.dex */
public class FileDownloadHeader implements Parcelable {
public static final Parcelable.Creator<FileDownloadHeader> CREATOR = new Parcelable.Creator<FileDownloadHeader>() { // from class: com.liulishuo.filedownloader.model.FileDownloadHeader.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadHeader createFromParcel(Parcel parcel) {
return new FileDownloadHeader(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadHeader[] newArray(int i) {
return new FileDownloadHeader[i];
}
};
private HashMap<String, List<String>> mHeaderMap;
public FileDownloadHeader() {
}
public void add(String str, String str2) {
if (str == null) {
throw new NullPointerException("name == null");
}
if (str.isEmpty()) {
throw new IllegalArgumentException("name is empty");
}
if (str2 == null) {
throw new NullPointerException("value == null");
}
if (this.mHeaderMap == null) {
this.mHeaderMap = new HashMap<>();
}
List<String> list = this.mHeaderMap.get(str);
if (list == null) {
list = new ArrayList<>();
this.mHeaderMap.put(str, list);
}
if (list.contains(str2)) {
return;
}
list.add(str2);
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public HashMap<String, List<String>> getHeaders() {
return this.mHeaderMap;
}
public void removeAll(String str) {
HashMap<String, List<String>> hashMap = this.mHeaderMap;
if (hashMap == null) {
return;
}
hashMap.remove(str);
}
public String toString() {
return this.mHeaderMap.toString();
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeMap(this.mHeaderMap);
}
protected FileDownloadHeader(Parcel parcel) {
this.mHeaderMap = parcel.readHashMap(String.class.getClassLoader());
}
public void add(String str) {
String[] split = str.split(":");
add(split[0].trim(), split[1].trim());
}
}

View File

@@ -0,0 +1,252 @@
package com.liulishuo.filedownloader.model;
import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;
import com.liulishuo.filedownloader.util.FileDownloadUtils;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
/* loaded from: classes.dex */
public class FileDownloadModel implements Parcelable {
public static final String CONNECTION_COUNT = "connectionCount";
public static final Parcelable.Creator<FileDownloadModel> CREATOR = new Parcelable.Creator<FileDownloadModel>() { // from class: com.liulishuo.filedownloader.model.FileDownloadModel.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadModel createFromParcel(Parcel parcel) {
return new FileDownloadModel(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadModel[] newArray(int i) {
return new FileDownloadModel[i];
}
};
public static final int DEFAULT_CALLBACK_PROGRESS_TIMES = 100;
public static final String ERR_MSG = "errMsg";
public static final String ETAG = "etag";
public static final String FILENAME = "filename";
public static final String ID = "_id";
public static final String PATH = "path";
public static final String PATH_AS_DIRECTORY = "pathAsDirectory";
public static final String SOFAR = "sofar";
public static final String STATUS = "status";
public static final String TOTAL = "total";
public static final int TOTAL_VALUE_IN_CHUNKED_RESOURCE = -1;
public static final String URL = "url";
private int connectionCount;
private String eTag;
private String errMsg;
private String filename;
private int id;
private boolean isLargeFile;
private String path;
private boolean pathAsDirectory;
private final AtomicLong soFar;
private final AtomicInteger status;
private long total;
private String url;
public FileDownloadModel() {
this.soFar = new AtomicLong();
this.status = new AtomicInteger();
}
public void deleteTargetFile() {
String targetFilePath = getTargetFilePath();
if (targetFilePath != null) {
File file = new File(targetFilePath);
if (file.exists()) {
file.delete();
}
}
}
public void deleteTaskFiles() {
deleteTempFile();
deleteTargetFile();
}
public void deleteTempFile() {
String tempFilePath = getTempFilePath();
if (tempFilePath != null) {
File file = new File(tempFilePath);
if (file.exists()) {
file.delete();
}
}
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public int getConnectionCount() {
return this.connectionCount;
}
public String getETag() {
return this.eTag;
}
public String getErrMsg() {
return this.errMsg;
}
public String getFilename() {
return this.filename;
}
public int getId() {
return this.id;
}
public String getPath() {
return this.path;
}
public long getSoFar() {
return this.soFar.get();
}
public byte getStatus() {
return (byte) this.status.get();
}
public String getTargetFilePath() {
return FileDownloadUtils.a(getPath(), isPathAsDirectory(), getFilename());
}
public String getTempFilePath() {
if (getTargetFilePath() == null) {
return null;
}
return FileDownloadUtils.j(getTargetFilePath());
}
public long getTotal() {
return this.total;
}
public String getUrl() {
return this.url;
}
public void increaseSoFar(long j) {
this.soFar.addAndGet(j);
}
public boolean isChunked() {
return this.total == -1;
}
public boolean isLargeFile() {
return this.isLargeFile;
}
public boolean isPathAsDirectory() {
return this.pathAsDirectory;
}
public void resetConnectionCount() {
this.connectionCount = 1;
}
public void setConnectionCount(int i) {
this.connectionCount = i;
}
public void setETag(String str) {
this.eTag = str;
}
public void setErrMsg(String str) {
this.errMsg = str;
}
public void setFilename(String str) {
this.filename = str;
}
public void setId(int i) {
this.id = i;
}
public void setPath(String str, boolean z) {
this.path = str;
this.pathAsDirectory = z;
}
public void setSoFar(long j) {
this.soFar.set(j);
}
public void setStatus(byte b) {
this.status.set(b);
}
public void setTotal(long j) {
this.isLargeFile = j > 2147483647L;
this.total = j;
}
public void setUrl(String str) {
this.url = str;
}
public ContentValues toContentValues() {
ContentValues contentValues = new ContentValues();
contentValues.put(ID, Integer.valueOf(getId()));
contentValues.put("url", getUrl());
contentValues.put(PATH, getPath());
contentValues.put(STATUS, Byte.valueOf(getStatus()));
contentValues.put(SOFAR, Long.valueOf(getSoFar()));
contentValues.put(TOTAL, Long.valueOf(getTotal()));
contentValues.put(ERR_MSG, getErrMsg());
contentValues.put(ETAG, getETag());
contentValues.put(CONNECTION_COUNT, Integer.valueOf(getConnectionCount()));
contentValues.put(PATH_AS_DIRECTORY, Boolean.valueOf(isPathAsDirectory()));
if (isPathAsDirectory() && getFilename() != null) {
contentValues.put(FILENAME, getFilename());
}
return contentValues;
}
public String toString() {
return FileDownloadUtils.a("id[%d], url[%s], path[%s], status[%d], sofar[%s], total[%d], etag[%s], %s", Integer.valueOf(this.id), this.url, this.path, Integer.valueOf(this.status.get()), this.soFar, Long.valueOf(this.total), this.eTag, super.toString());
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.id);
parcel.writeString(this.url);
parcel.writeString(this.path);
parcel.writeByte(this.pathAsDirectory ? (byte) 1 : (byte) 0);
parcel.writeString(this.filename);
parcel.writeByte((byte) this.status.get());
parcel.writeLong(this.soFar.get());
parcel.writeLong(this.total);
parcel.writeString(this.errMsg);
parcel.writeString(this.eTag);
parcel.writeInt(this.connectionCount);
parcel.writeByte(this.isLargeFile ? (byte) 1 : (byte) 0);
}
protected FileDownloadModel(Parcel parcel) {
this.id = parcel.readInt();
this.url = parcel.readString();
this.path = parcel.readString();
this.pathAsDirectory = parcel.readByte() != 0;
this.filename = parcel.readString();
this.status = new AtomicInteger(parcel.readByte());
this.soFar = new AtomicLong(parcel.readLong());
this.total = parcel.readLong();
this.errMsg = parcel.readString();
this.eTag = parcel.readString();
this.connectionCount = parcel.readInt();
this.isLargeFile = parcel.readByte() != 0;
}
}

View File

@@ -0,0 +1,71 @@
package com.liulishuo.filedownloader.model;
import com.liulishuo.filedownloader.BaseDownloadTask;
/* loaded from: classes.dex */
public class FileDownloadStatus {
public static boolean a(int i) {
return i > 0;
}
public static boolean a(int i, int i2) {
if ((i != 3 && i != 5 && i == i2) || b(i)) {
return false;
}
if (i >= 1 && i <= 6 && i2 >= 10 && i2 <= 11) {
return false;
}
if (i == 1) {
return i2 != 0;
}
if (i == 2) {
return (i2 == 0 || i2 == 1 || i2 == 6) ? false : true;
}
if (i == 3) {
return (i2 == 0 || i2 == 1 || i2 == 2 || i2 == 6) ? false : true;
}
if (i == 5) {
return (i2 == 1 || i2 == 6) ? false : true;
}
if (i != 6) {
return true;
}
return (i2 == 0 || i2 == 1) ? false : true;
}
public static boolean b(int i) {
return i < 0;
}
public static boolean b(int i, int i2) {
if ((i != 3 && i != 5 && i == i2) || b(i)) {
return false;
}
if (i2 == -2 || i2 == -1) {
return true;
}
if (i == 0) {
return i2 == 10;
}
if (i == 1) {
return i2 == 6;
}
if (i == 2 || i == 3) {
return i2 == -3 || i2 == 3 || i2 == 5;
}
if (i == 5 || i == 6) {
return i2 == 2 || i2 == 5;
}
if (i == 10) {
return i2 == 11;
}
if (i != 11) {
return false;
}
return i2 == -4 || i2 == -3 || i2 == 1;
}
public static boolean a(BaseDownloadTask baseDownloadTask) {
return baseDownloadTask.getStatus() == 0 || baseDownloadTask.getStatus() == 3;
}
}

View File

@@ -0,0 +1,84 @@
package com.liulishuo.filedownloader.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.liulishuo.filedownloader.util.FileDownloadUtils;
/* loaded from: classes.dex */
public class FileDownloadTaskAtom implements Parcelable {
public static final Parcelable.Creator<FileDownloadTaskAtom> CREATOR = new Parcelable.Creator<FileDownloadTaskAtom>() { // from class: com.liulishuo.filedownloader.model.FileDownloadTaskAtom.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadTaskAtom createFromParcel(Parcel parcel) {
return new FileDownloadTaskAtom(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public FileDownloadTaskAtom[] newArray(int i) {
return new FileDownloadTaskAtom[i];
}
};
private int id;
private String path;
private long totalBytes;
private String url;
public FileDownloadTaskAtom(String str, String str2, long j) {
setUrl(str);
setPath(str2);
setTotalBytes(j);
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public int getId() {
int i = this.id;
if (i != 0) {
return i;
}
int c = FileDownloadUtils.c(getUrl(), getPath());
this.id = c;
return c;
}
public String getPath() {
return this.path;
}
public long getTotalBytes() {
return this.totalBytes;
}
public String getUrl() {
return this.url;
}
public void setPath(String str) {
this.path = str;
}
public void setTotalBytes(long j) {
this.totalBytes = j;
}
public void setUrl(String str) {
this.url = str;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.url);
parcel.writeString(this.path);
parcel.writeLong(this.totalBytes);
}
protected FileDownloadTaskAtom(Parcel parcel) {
this.url = parcel.readString();
this.path = parcel.readString();
this.totalBytes = parcel.readLong();
}
}