163 lines
5.6 KiB
Java
163 lines
5.6 KiB
Java
package com.liulishuo.filedownloader.services;
|
|
|
|
import com.liulishuo.filedownloader.connection.DefaultConnectionCountAdapter;
|
|
import com.liulishuo.filedownloader.connection.FileDownloadUrlConnection;
|
|
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
|
import com.liulishuo.filedownloader.database.RemitDatabase;
|
|
import com.liulishuo.filedownloader.services.ForegroundServiceConfig;
|
|
import com.liulishuo.filedownloader.stream.FileDownloadRandomAccessFile;
|
|
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
|
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
|
import com.liulishuo.filedownloader.util.FileDownloadProperties;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DownloadMgrInitialParams {
|
|
private final InitCustomMaker a = null;
|
|
|
|
public static class InitCustomMaker {
|
|
FileDownloadHelper.DatabaseCustomMaker a;
|
|
Integer b;
|
|
FileDownloadHelper.OutputStreamCreator c;
|
|
FileDownloadHelper.ConnectionCreator d;
|
|
FileDownloadHelper.ConnectionCountAdapter e;
|
|
FileDownloadHelper.IdGenerator f;
|
|
ForegroundServiceConfig g;
|
|
}
|
|
|
|
private FileDownloadHelper.ConnectionCountAdapter h() {
|
|
return new DefaultConnectionCountAdapter();
|
|
}
|
|
|
|
private FileDownloadHelper.ConnectionCreator i() {
|
|
return new FileDownloadUrlConnection.Creator();
|
|
}
|
|
|
|
private FileDownloadDatabase j() {
|
|
return new RemitDatabase();
|
|
}
|
|
|
|
private ForegroundServiceConfig k() {
|
|
ForegroundServiceConfig.Builder builder = new ForegroundServiceConfig.Builder();
|
|
builder.a(true);
|
|
return builder.a();
|
|
}
|
|
|
|
private FileDownloadHelper.IdGenerator l() {
|
|
return new DefaultIdGenerator();
|
|
}
|
|
|
|
private FileDownloadHelper.OutputStreamCreator m() {
|
|
return new FileDownloadRandomAccessFile.Creator();
|
|
}
|
|
|
|
private int n() {
|
|
return FileDownloadProperties.a().e;
|
|
}
|
|
|
|
public FileDownloadHelper.ConnectionCountAdapter a() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return h();
|
|
}
|
|
FileDownloadHelper.ConnectionCountAdapter connectionCountAdapter = initCustomMaker.e;
|
|
if (connectionCountAdapter == null) {
|
|
return h();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize connection count adapter: %s", connectionCountAdapter);
|
|
}
|
|
return connectionCountAdapter;
|
|
}
|
|
|
|
public FileDownloadHelper.ConnectionCreator b() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return i();
|
|
}
|
|
FileDownloadHelper.ConnectionCreator connectionCreator = initCustomMaker.d;
|
|
if (connectionCreator == null) {
|
|
return i();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize connection creator: %s", connectionCreator);
|
|
}
|
|
return connectionCreator;
|
|
}
|
|
|
|
public FileDownloadDatabase c() {
|
|
FileDownloadHelper.DatabaseCustomMaker databaseCustomMaker;
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null || (databaseCustomMaker = initCustomMaker.a) == null) {
|
|
return j();
|
|
}
|
|
FileDownloadDatabase a = databaseCustomMaker.a();
|
|
if (a == null) {
|
|
return j();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize database: %s", a);
|
|
}
|
|
return a;
|
|
}
|
|
|
|
public ForegroundServiceConfig d() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return k();
|
|
}
|
|
ForegroundServiceConfig foregroundServiceConfig = initCustomMaker.g;
|
|
if (foregroundServiceConfig == null) {
|
|
return k();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize foreground service config: %s", foregroundServiceConfig);
|
|
}
|
|
return foregroundServiceConfig;
|
|
}
|
|
|
|
public FileDownloadHelper.IdGenerator e() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return l();
|
|
}
|
|
FileDownloadHelper.IdGenerator idGenerator = initCustomMaker.f;
|
|
if (idGenerator == null) {
|
|
return l();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize id generator: %s", idGenerator);
|
|
}
|
|
return idGenerator;
|
|
}
|
|
|
|
public FileDownloadHelper.OutputStreamCreator f() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return m();
|
|
}
|
|
FileDownloadHelper.OutputStreamCreator outputStreamCreator = initCustomMaker.c;
|
|
if (outputStreamCreator == null) {
|
|
return m();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize output stream: %s", outputStreamCreator);
|
|
}
|
|
return outputStreamCreator;
|
|
}
|
|
|
|
public int g() {
|
|
InitCustomMaker initCustomMaker = this.a;
|
|
if (initCustomMaker == null) {
|
|
return n();
|
|
}
|
|
Integer num = initCustomMaker.b;
|
|
if (num == null) {
|
|
return n();
|
|
}
|
|
if (FileDownloadLog.a) {
|
|
FileDownloadLog.a(this, "initial FileDownloader manager with the customize maxNetworkThreadCount: %d", num);
|
|
}
|
|
return FileDownloadProperties.a(num.intValue());
|
|
}
|
|
}
|