Initial commit
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.RemoteException;
|
||||
import com.liulishuo.filedownloader.FileDownloadEventPool;
|
||||
import com.liulishuo.filedownloader.IFileDownloadServiceProxy;
|
||||
import com.liulishuo.filedownloader.event.DownloadServiceConnectChangedEvent;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BaseFileServiceUIGuard<CALLBACK extends Binder, INTERFACE extends IInterface> implements IFileDownloadServiceProxy, ServiceConnection {
|
||||
private final CALLBACK a;
|
||||
private volatile INTERFACE b;
|
||||
private final Class<?> c;
|
||||
private final List<Context> d;
|
||||
private final ArrayList<Runnable> e;
|
||||
|
||||
protected BaseFileServiceUIGuard(Class<?> cls) {
|
||||
new HashMap();
|
||||
this.d = new ArrayList();
|
||||
this.e = new ArrayList<>();
|
||||
this.c = cls;
|
||||
this.a = a();
|
||||
}
|
||||
|
||||
private void a(boolean z) {
|
||||
if (!z && this.b != null) {
|
||||
try {
|
||||
b(this.b, this.a);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "release connect resources %s", this.b);
|
||||
}
|
||||
this.b = null;
|
||||
FileDownloadEventPool.a().a(new DownloadServiceConnectChangedEvent(z ? DownloadServiceConnectChangedEvent.ConnectStatus.lost : DownloadServiceConnectChangedEvent.ConnectStatus.disconnected, this.c));
|
||||
}
|
||||
|
||||
protected abstract CALLBACK a();
|
||||
|
||||
protected abstract INTERFACE a(IBinder iBinder);
|
||||
|
||||
protected abstract void a(INTERFACE r1, CALLBACK callback) throws RemoteException;
|
||||
|
||||
protected abstract void b(INTERFACE r1, CALLBACK callback) throws RemoteException;
|
||||
|
||||
@Override // com.liulishuo.filedownloader.IFileDownloadServiceProxy
|
||||
public boolean b() {
|
||||
return c() != null;
|
||||
}
|
||||
|
||||
protected INTERFACE c() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
this.b = a(iBinder);
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "onServiceConnected %s %s", componentName, this.b);
|
||||
}
|
||||
try {
|
||||
a((BaseFileServiceUIGuard<CALLBACK, INTERFACE>) this.b, (INTERFACE) this.a);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List list = (List) this.e.clone();
|
||||
this.e.clear();
|
||||
Iterator it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
((Runnable) it.next()).run();
|
||||
}
|
||||
FileDownloadEventPool.a().a(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.connected, this.c));
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "onServiceDisconnected %s %s", componentName, this.b);
|
||||
}
|
||||
a(true);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.IFileDownloadServiceProxy
|
||||
public void a(Context context) {
|
||||
a(context, (Runnable) null);
|
||||
}
|
||||
|
||||
public void a(Context context, Runnable runnable) {
|
||||
if (!FileDownloadUtils.c(context)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "bindStartByContext %s", context.getClass().getSimpleName());
|
||||
}
|
||||
Intent intent = new Intent(context, this.c);
|
||||
if (runnable != null && !this.e.contains(runnable)) {
|
||||
this.e.add(runnable);
|
||||
}
|
||||
if (!this.d.contains(context)) {
|
||||
this.d.add(context);
|
||||
}
|
||||
context.bindService(intent, this, 1);
|
||||
if (FileDownloadUtils.e(context)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "start foreground service", new Object[0]);
|
||||
}
|
||||
context.startForegroundService(intent);
|
||||
return;
|
||||
}
|
||||
context.startService(intent);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Fatal-Exception: You can't bind the FileDownloadService in :filedownloader process.\n It's the invalid operation and is likely to cause unexpected problems.\n Maybe you want to use non-separate process mode for FileDownloader, More detail about non-separate mode, please move to wiki manually: https://github.com/lingochamp/FileDownloader/wiki/filedownloader.properties");
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DefaultIdGenerator implements FileDownloadHelper.IdGenerator {
|
||||
@Override // com.liulishuo.filedownloader.util.FileDownloadHelper.IdGenerator
|
||||
public int a(int i, String str, String str2, boolean z) {
|
||||
return a(str, str2, z);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.util.FileDownloadHelper.IdGenerator
|
||||
public int a(String str, String str2, boolean z) {
|
||||
return z ? FileDownloadUtils.m(FileDownloadUtils.a("%sp%s@dir", str, str2)).hashCode() : FileDownloadUtils.m(FileDownloadUtils.a("%sp%s", str, str2)).hashCode();
|
||||
}
|
||||
}
|
@@ -0,0 +1,162 @@
|
||||
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());
|
||||
}
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteCallbackList;
|
||||
import android.os.RemoteException;
|
||||
import com.liulishuo.filedownloader.i.IFileDownloadIPCCallback;
|
||||
import com.liulishuo.filedownloader.i.IFileDownloadIPCService;
|
||||
import com.liulishuo.filedownloader.message.MessageSnapshot;
|
||||
import com.liulishuo.filedownloader.message.MessageSnapshotFlow;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FDServiceSeparateHandler extends IFileDownloadIPCService.Stub implements MessageSnapshotFlow.MessageReceiver, IFileDownloadServiceHandler {
|
||||
private final RemoteCallbackList<IFileDownloadIPCCallback> a = new RemoteCallbackList<>();
|
||||
private final FileDownloadManager b;
|
||||
private final WeakReference<FileDownloadService> c;
|
||||
|
||||
FDServiceSeparateHandler(WeakReference<FileDownloadService> weakReference, FileDownloadManager fileDownloadManager) {
|
||||
this.c = weakReference;
|
||||
this.b = fileDownloadManager;
|
||||
MessageSnapshotFlow.a().a(this);
|
||||
}
|
||||
|
||||
private synchronized int b(MessageSnapshot messageSnapshot) {
|
||||
int beginBroadcast;
|
||||
RemoteCallbackList<IFileDownloadIPCCallback> remoteCallbackList;
|
||||
beginBroadcast = this.a.beginBroadcast();
|
||||
for (int i = 0; i < beginBroadcast; i++) {
|
||||
try {
|
||||
try {
|
||||
this.a.getBroadcastItem(i).a(messageSnapshot);
|
||||
} catch (RemoteException e) {
|
||||
FileDownloadLog.a(this, e, "callback error", new Object[0]);
|
||||
remoteCallbackList = this.a;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
this.a.finishBroadcast();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
remoteCallbackList = this.a;
|
||||
remoteCallbackList.finishBroadcast();
|
||||
return beginBroadcast;
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public IBinder a(Intent intent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public void a(Intent intent, int i, int i2) {
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(IFileDownloadIPCCallback iFileDownloadIPCCallback) throws RemoteException {
|
||||
this.a.register(iFileDownloadIPCCallback);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean c(int i) throws RemoteException {
|
||||
return this.b.g(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean d() throws RemoteException {
|
||||
return this.b.b();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void e() throws RemoteException {
|
||||
this.b.c();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public long f(int i) throws RemoteException {
|
||||
return this.b.b(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean a(String str, String str2) throws RemoteException {
|
||||
return this.b.a(str, str2);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void c() throws RemoteException {
|
||||
this.b.a();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean d(int i) throws RemoteException {
|
||||
return this.b.a(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public long e(int i) throws RemoteException {
|
||||
return this.b.d(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(String str, String str2, boolean z, int i, int i2, int i3, boolean z2, FileDownloadHeader fileDownloadHeader, boolean z3) throws RemoteException {
|
||||
this.b.a(str, str2, z, i, i2, i3, z2, fileDownloadHeader, z3);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public byte a(int i) throws RemoteException {
|
||||
return this.b.c(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(int i, Notification notification) throws RemoteException {
|
||||
WeakReference<FileDownloadService> weakReference = this.c;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
this.c.get().startForeground(i, notification);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void b(IFileDownloadIPCCallback iFileDownloadIPCCallback) throws RemoteException {
|
||||
this.a.unregister(iFileDownloadIPCCallback);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(boolean z) throws RemoteException {
|
||||
WeakReference<FileDownloadService> weakReference = this.c;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
this.c.get().stopForeground(z);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean b(int i) throws RemoteException {
|
||||
return this.b.f(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public void a() {
|
||||
MessageSnapshotFlow.a().a((MessageSnapshotFlow.MessageReceiver) null);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.message.MessageSnapshotFlow.MessageReceiver
|
||||
public void a(MessageSnapshot messageSnapshot) {
|
||||
b(messageSnapshot);
|
||||
}
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import com.liulishuo.filedownloader.FileDownloadServiceProxy;
|
||||
import com.liulishuo.filedownloader.i.IFileDownloadIPCCallback;
|
||||
import com.liulishuo.filedownloader.i.IFileDownloadIPCService;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FDServiceSharedHandler extends IFileDownloadIPCService.Stub implements IFileDownloadServiceHandler {
|
||||
private final FileDownloadManager a;
|
||||
private final WeakReference<FileDownloadService> b;
|
||||
|
||||
public interface FileDownloadServiceSharedConnection {
|
||||
void a(FDServiceSharedHandler fDServiceSharedHandler);
|
||||
|
||||
void onDisconnected();
|
||||
}
|
||||
|
||||
FDServiceSharedHandler(WeakReference<FileDownloadService> weakReference, FileDownloadManager fileDownloadManager) {
|
||||
this.b = weakReference;
|
||||
this.a = fileDownloadManager;
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public IBinder a(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(IFileDownloadIPCCallback iFileDownloadIPCCallback) {
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean a(String str, String str2) {
|
||||
return this.a.a(str, str2);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void b(IFileDownloadIPCCallback iFileDownloadIPCCallback) {
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean b(int i) {
|
||||
return this.a.f(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean c(int i) {
|
||||
return this.a.g(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean d() {
|
||||
return this.a.b();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void e() {
|
||||
this.a.c();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public long f(int i) {
|
||||
return this.a.b(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(String str, String str2, boolean z, int i, int i2, int i3, boolean z2, FileDownloadHeader fileDownloadHeader, boolean z3) {
|
||||
this.a.a(str, str2, z, i, i2, i3, z2, fileDownloadHeader, z3);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void c() {
|
||||
this.a.a();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public boolean d(int i) {
|
||||
return this.a.a(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public long e(int i) {
|
||||
return this.a.d(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public byte a(int i) {
|
||||
return this.a.c(i);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(int i, Notification notification) {
|
||||
WeakReference<FileDownloadService> weakReference = this.b;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
this.b.get().startForeground(i, notification);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.i.IFileDownloadIPCService
|
||||
public void a(boolean z) {
|
||||
WeakReference<FileDownloadService> weakReference = this.b;
|
||||
if (weakReference == null || weakReference.get() == null) {
|
||||
return;
|
||||
}
|
||||
this.b.get().stopForeground(z);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public void a(Intent intent, int i, int i2) {
|
||||
FileDownloadServiceProxy.a().a(this);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.services.IFileDownloadServiceHandler
|
||||
public void a() {
|
||||
FileDownloadServiceProxy.a().onDisconnected();
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.content.Intent;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FileDownloadBroadcastHandler {
|
||||
public static void a(FileDownloadModel fileDownloadModel) {
|
||||
if (fileDownloadModel == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (fileDownloadModel.getStatus() != -3) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
Intent intent = new Intent("filedownloader.intent.action.completed");
|
||||
intent.putExtra("model", fileDownloadModel);
|
||||
FileDownloadHelper.a().sendBroadcast(intent);
|
||||
}
|
||||
}
|
@@ -0,0 +1,230 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.liulishuo.filedownloader.IThreadPoolMonitor;
|
||||
import com.liulishuo.filedownloader.database.FileDownloadDatabase;
|
||||
import com.liulishuo.filedownloader.download.CustomComponentHolder;
|
||||
import com.liulishuo.filedownloader.download.DownloadLaunchRunnable;
|
||||
import com.liulishuo.filedownloader.model.ConnectionModel;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadHeader;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadStatus;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FileDownloadManager implements IThreadPoolMonitor {
|
||||
private final FileDownloadDatabase a;
|
||||
private final FileDownloadThreadPool b;
|
||||
|
||||
FileDownloadManager() {
|
||||
CustomComponentHolder i = CustomComponentHolder.i();
|
||||
this.a = i.a();
|
||||
this.b = new FileDownloadThreadPool(i.d());
|
||||
}
|
||||
|
||||
public synchronized void a(String str, String str2, boolean z, int i, int i2, int i3, boolean z2, FileDownloadHeader fileDownloadHeader, boolean z3) {
|
||||
FileDownloadModel fileDownloadModel;
|
||||
List<ConnectionModel> list;
|
||||
boolean z4 = true;
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "request start the task with url(%s) path(%s) isDirectory(%B)", str, str2, Boolean.valueOf(z));
|
||||
}
|
||||
int a = FileDownloadUtils.a(str, str2, z);
|
||||
FileDownloadModel e = this.a.e(a);
|
||||
if (z || e != null) {
|
||||
fileDownloadModel = e;
|
||||
list = null;
|
||||
} else {
|
||||
int a2 = FileDownloadUtils.a(str, FileDownloadUtils.i(str2), true);
|
||||
FileDownloadModel e2 = this.a.e(a2);
|
||||
if (e2 == null || !str2.equals(e2.getTargetFilePath())) {
|
||||
list = null;
|
||||
} else {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "task[%d] find model by dirCaseId[%d]", Integer.valueOf(a), Integer.valueOf(a2));
|
||||
}
|
||||
list = this.a.d(a2);
|
||||
}
|
||||
fileDownloadModel = e2;
|
||||
}
|
||||
if (FileDownloadHelper.a(a, fileDownloadModel, (IThreadPoolMonitor) this, true)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "has already started download %d", Integer.valueOf(a));
|
||||
}
|
||||
return;
|
||||
}
|
||||
String targetFilePath = fileDownloadModel != null ? fileDownloadModel.getTargetFilePath() : FileDownloadUtils.a(str2, z, (String) null);
|
||||
if (FileDownloadHelper.a(a, targetFilePath, z2, true)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "has already completed downloading %d", Integer.valueOf(a));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (FileDownloadHelper.a(a, fileDownloadModel != null ? fileDownloadModel.getSoFar() : 0L, fileDownloadModel != null ? fileDownloadModel.getTempFilePath() : FileDownloadUtils.j(targetFilePath), targetFilePath, this)) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "there is an another task with the same target-file-path %d %s", Integer.valueOf(a), targetFilePath);
|
||||
}
|
||||
if (fileDownloadModel != null) {
|
||||
this.a.remove(a);
|
||||
this.a.b(a);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (fileDownloadModel == null || !(fileDownloadModel.getStatus() == -2 || fileDownloadModel.getStatus() == -1 || fileDownloadModel.getStatus() == 1 || fileDownloadModel.getStatus() == 6 || fileDownloadModel.getStatus() == 2)) {
|
||||
if (fileDownloadModel == null) {
|
||||
fileDownloadModel = new FileDownloadModel();
|
||||
}
|
||||
fileDownloadModel.setUrl(str);
|
||||
fileDownloadModel.setPath(str2, z);
|
||||
fileDownloadModel.setId(a);
|
||||
fileDownloadModel.setSoFar(0L);
|
||||
fileDownloadModel.setTotal(0L);
|
||||
fileDownloadModel.setStatus((byte) 1);
|
||||
fileDownloadModel.setConnectionCount(1);
|
||||
} else if (fileDownloadModel.getId() != a) {
|
||||
this.a.remove(fileDownloadModel.getId());
|
||||
this.a.b(fileDownloadModel.getId());
|
||||
fileDownloadModel.setId(a);
|
||||
fileDownloadModel.setPath(str2, z);
|
||||
if (list != null) {
|
||||
for (ConnectionModel connectionModel : list) {
|
||||
connectionModel.a(a);
|
||||
this.a.a(connectionModel);
|
||||
}
|
||||
}
|
||||
} else if (TextUtils.equals(str, fileDownloadModel.getUrl())) {
|
||||
z4 = false;
|
||||
} else {
|
||||
fileDownloadModel.setUrl(str);
|
||||
}
|
||||
if (z4) {
|
||||
this.a.a(fileDownloadModel);
|
||||
}
|
||||
DownloadLaunchRunnable.Builder builder = new DownloadLaunchRunnable.Builder();
|
||||
builder.a(fileDownloadModel);
|
||||
builder.a(fileDownloadHeader);
|
||||
builder.a(this);
|
||||
builder.c(Integer.valueOf(i2));
|
||||
builder.a(Integer.valueOf(i));
|
||||
builder.a(Boolean.valueOf(z2));
|
||||
builder.b(Boolean.valueOf(z3));
|
||||
builder.b(Integer.valueOf(i3));
|
||||
this.b.a(builder.a());
|
||||
}
|
||||
|
||||
public long b(int i) {
|
||||
FileDownloadModel e = this.a.e(i);
|
||||
if (e == null) {
|
||||
return 0L;
|
||||
}
|
||||
int connectionCount = e.getConnectionCount();
|
||||
if (connectionCount <= 1) {
|
||||
return e.getSoFar();
|
||||
}
|
||||
List<ConnectionModel> d = this.a.d(i);
|
||||
if (d == null || d.size() != connectionCount) {
|
||||
return 0L;
|
||||
}
|
||||
return ConnectionModel.a(d);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
List<Integer> b = this.b.b();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "pause all tasks %d", Integer.valueOf(b.size()));
|
||||
}
|
||||
Iterator<Integer> it = b.iterator();
|
||||
while (it.hasNext()) {
|
||||
f(it.next().intValue());
|
||||
}
|
||||
}
|
||||
|
||||
public long d(int i) {
|
||||
FileDownloadModel e = this.a.e(i);
|
||||
if (e == null) {
|
||||
return 0L;
|
||||
}
|
||||
return e.getTotal();
|
||||
}
|
||||
|
||||
public boolean e(int i) {
|
||||
return a(this.a.e(i));
|
||||
}
|
||||
|
||||
public boolean f(int i) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "request pause the task %d", Integer.valueOf(i));
|
||||
}
|
||||
FileDownloadModel e = this.a.e(i);
|
||||
if (e == null) {
|
||||
return false;
|
||||
}
|
||||
e.setStatus((byte) -2);
|
||||
this.b.a(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean g(int i) {
|
||||
return this.b.c(i);
|
||||
}
|
||||
|
||||
public byte c(int i) {
|
||||
FileDownloadModel e = this.a.e(i);
|
||||
if (e == null) {
|
||||
return (byte) 0;
|
||||
}
|
||||
return e.getStatus();
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return this.b.a() <= 0;
|
||||
}
|
||||
|
||||
public boolean a(String str, String str2) {
|
||||
return e(FileDownloadUtils.c(str, str2));
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.IThreadPoolMonitor
|
||||
public boolean a(FileDownloadModel fileDownloadModel) {
|
||||
if (fileDownloadModel == null) {
|
||||
return false;
|
||||
}
|
||||
boolean b = this.b.b(fileDownloadModel.getId());
|
||||
if (FileDownloadStatus.b(fileDownloadModel.getStatus())) {
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
} else if (!b) {
|
||||
FileDownloadLog.b(this, "%d status is[%s](not finish) & but not in the pool", Integer.valueOf(fileDownloadModel.getId()), Byte.valueOf(fileDownloadModel.getStatus()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.IThreadPoolMonitor
|
||||
public int a(String str, int i) {
|
||||
return this.b.a(str, i);
|
||||
}
|
||||
|
||||
public boolean a(int i) {
|
||||
if (i == 0) {
|
||||
FileDownloadLog.e(this, "The task[%d] id is invalid, can't clear it.", Integer.valueOf(i));
|
||||
return false;
|
||||
}
|
||||
if (e(i)) {
|
||||
FileDownloadLog.e(this, "The task[%d] is downloading, can't clear it.", Integer.valueOf(i));
|
||||
return false;
|
||||
}
|
||||
this.a.remove(i);
|
||||
this.a.b(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.a.clear();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import com.liulishuo.filedownloader.download.CustomComponentHolder;
|
||||
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.lang.ref.WeakReference;
|
||||
|
||||
@SuppressLint({"Registered"})
|
||||
/* loaded from: classes.dex */
|
||||
public class FileDownloadService extends Service {
|
||||
private IFileDownloadServiceHandler a;
|
||||
|
||||
public static class SeparateProcessService extends FileDownloadService {
|
||||
}
|
||||
|
||||
public static class SharedMainProcessService extends FileDownloadService {
|
||||
}
|
||||
|
||||
@TargetApi(26)
|
||||
private void a() {
|
||||
ForegroundServiceConfig b = CustomComponentHolder.i().b();
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "make service foreground: %s", b);
|
||||
}
|
||||
if (b.d()) {
|
||||
NotificationChannel notificationChannel = new NotificationChannel(b.a(), b.b(), 2);
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
|
||||
if (notificationManager == null) {
|
||||
return;
|
||||
} else {
|
||||
notificationManager.createNotificationChannel(notificationChannel);
|
||||
}
|
||||
}
|
||||
startForeground(b.c(), b.a(this));
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public IBinder onBind(Intent intent) {
|
||||
return this.a.a(intent);
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
FileDownloadHelper.a(this);
|
||||
try {
|
||||
FileDownloadUtils.a(FileDownloadProperties.a().a);
|
||||
FileDownloadUtils.a(FileDownloadProperties.a().b);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
FileDownloadManager fileDownloadManager = new FileDownloadManager();
|
||||
if (FileDownloadProperties.a().d) {
|
||||
this.a = new FDServiceSharedHandler(new WeakReference(this), fileDownloadManager);
|
||||
} else {
|
||||
this.a = new FDServiceSeparateHandler(new WeakReference(this), fileDownloadManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public void onDestroy() {
|
||||
this.a.a();
|
||||
stopForeground(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.app.Service
|
||||
public int onStartCommand(Intent intent, int i, int i2) {
|
||||
this.a.a(intent, i, i2);
|
||||
if (!FileDownloadUtils.e(this)) {
|
||||
return 1;
|
||||
}
|
||||
a();
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import com.liulishuo.filedownloader.download.DownloadLaunchRunnable;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadExecutors;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FileDownloadThreadPool {
|
||||
private ThreadPoolExecutor b;
|
||||
private int c;
|
||||
private SparseArray<DownloadLaunchRunnable> a = new SparseArray<>();
|
||||
private int d = 0;
|
||||
|
||||
FileDownloadThreadPool(int i) {
|
||||
this.b = FileDownloadExecutors.a(i, "Network");
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public void a(DownloadLaunchRunnable downloadLaunchRunnable) {
|
||||
downloadLaunchRunnable.e();
|
||||
synchronized (this) {
|
||||
this.a.put(downloadLaunchRunnable.b(), downloadLaunchRunnable);
|
||||
}
|
||||
this.b.execute(downloadLaunchRunnable);
|
||||
int i = this.d;
|
||||
if (i < 600) {
|
||||
this.d = i + 1;
|
||||
} else {
|
||||
c();
|
||||
this.d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b(int i) {
|
||||
DownloadLaunchRunnable downloadLaunchRunnable = this.a.get(i);
|
||||
return downloadLaunchRunnable != null && downloadLaunchRunnable.d();
|
||||
}
|
||||
|
||||
public synchronized boolean c(int i) {
|
||||
if (a() > 0) {
|
||||
FileDownloadLog.e(this, "Can't change the max network thread count, because the network thread pool isn't in IDLE, please try again after all running tasks are completed or invoking FileDownloader#pauseAll directly.", new Object[0]);
|
||||
return false;
|
||||
}
|
||||
int a = FileDownloadProperties.a(i);
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "change the max network thread count, from %d to %d", Integer.valueOf(this.c), Integer.valueOf(a));
|
||||
}
|
||||
List<Runnable> shutdownNow = this.b.shutdownNow();
|
||||
this.b = FileDownloadExecutors.a(a, "Network");
|
||||
if (shutdownNow.size() > 0) {
|
||||
FileDownloadLog.e(this, "recreate the network thread pool and discard %d tasks", Integer.valueOf(shutdownNow.size()));
|
||||
}
|
||||
this.c = a;
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized List<Integer> b() {
|
||||
ArrayList arrayList;
|
||||
c();
|
||||
arrayList = new ArrayList();
|
||||
for (int i = 0; i < this.a.size(); i++) {
|
||||
arrayList.add(Integer.valueOf(this.a.get(this.a.keyAt(i)).b()));
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
c();
|
||||
synchronized (this) {
|
||||
DownloadLaunchRunnable downloadLaunchRunnable = this.a.get(i);
|
||||
if (downloadLaunchRunnable != null) {
|
||||
downloadLaunchRunnable.pause();
|
||||
boolean remove = this.b.remove(downloadLaunchRunnable);
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "successful cancel %d %B", Integer.valueOf(i), Boolean.valueOf(remove));
|
||||
}
|
||||
}
|
||||
this.a.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void c() {
|
||||
SparseArray<DownloadLaunchRunnable> sparseArray = new SparseArray<>();
|
||||
int size = this.a.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int keyAt = this.a.keyAt(i);
|
||||
DownloadLaunchRunnable downloadLaunchRunnable = this.a.get(keyAt);
|
||||
if (downloadLaunchRunnable.d()) {
|
||||
sparseArray.put(keyAt, downloadLaunchRunnable);
|
||||
}
|
||||
}
|
||||
this.a = sparseArray;
|
||||
}
|
||||
|
||||
public int a(String str, int i) {
|
||||
if (str == null) {
|
||||
return 0;
|
||||
}
|
||||
int size = this.a.size();
|
||||
for (int i2 = 0; i2 < size; i2++) {
|
||||
DownloadLaunchRunnable valueAt = this.a.valueAt(i2);
|
||||
if (valueAt != null && valueAt.d() && valueAt.b() != i && str.equals(valueAt.c())) {
|
||||
return valueAt.b();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public synchronized int a() {
|
||||
c();
|
||||
return this.a.size();
|
||||
}
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.R;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import com.liulishuo.filedownloader.R$string;
|
||||
import com.liulishuo.filedownloader.util.FileDownloadLog;
|
||||
|
||||
@TargetApi(26)
|
||||
/* loaded from: classes.dex */
|
||||
public class ForegroundServiceConfig {
|
||||
private int a;
|
||||
private String b;
|
||||
private String c;
|
||||
private Notification d;
|
||||
private boolean e;
|
||||
|
||||
public static class Builder {
|
||||
private int a;
|
||||
private String b;
|
||||
private String c;
|
||||
private Notification d;
|
||||
private boolean e;
|
||||
|
||||
public Builder a(boolean z) {
|
||||
this.e = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ForegroundServiceConfig a() {
|
||||
ForegroundServiceConfig foregroundServiceConfig = new ForegroundServiceConfig();
|
||||
String str = this.b;
|
||||
if (str == null) {
|
||||
str = "filedownloader_channel";
|
||||
}
|
||||
foregroundServiceConfig.a(str);
|
||||
String str2 = this.c;
|
||||
if (str2 == null) {
|
||||
str2 = "Filedownloader";
|
||||
}
|
||||
foregroundServiceConfig.b(str2);
|
||||
int i = this.a;
|
||||
if (i == 0) {
|
||||
i = R.drawable.arrow_down_float;
|
||||
}
|
||||
foregroundServiceConfig.a(i);
|
||||
foregroundServiceConfig.a(this.e);
|
||||
foregroundServiceConfig.a(this.d);
|
||||
return foregroundServiceConfig;
|
||||
}
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public boolean d() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ForegroundServiceConfig{notificationId=" + this.a + ", notificationChannelId='" + this.b + "', notificationChannelName='" + this.c + "', notification=" + this.d + ", needRecreateChannelId=" + this.e + '}';
|
||||
}
|
||||
|
||||
private ForegroundServiceConfig() {
|
||||
}
|
||||
|
||||
public Notification a(Context context) {
|
||||
if (this.d == null) {
|
||||
if (FileDownloadLog.a) {
|
||||
FileDownloadLog.a(this, "build default notification", new Object[0]);
|
||||
}
|
||||
this.d = b(context);
|
||||
}
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
this.c = str;
|
||||
}
|
||||
|
||||
private Notification b(Context context) {
|
||||
String string = context.getString(R$string.default_filedownloader_notification_title);
|
||||
String string2 = context.getString(R$string.default_filedownloader_notification_content);
|
||||
Notification.Builder builder = new Notification.Builder(context, this.b);
|
||||
builder.setContentTitle(string).setContentText(string2).setSmallIcon(R.drawable.arrow_down_float);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
this.b = str;
|
||||
}
|
||||
|
||||
public void a(Notification notification) {
|
||||
this.d = notification;
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.e = z;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.liulishuo.filedownloader.services;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface IFileDownloadServiceHandler {
|
||||
IBinder a(Intent intent);
|
||||
|
||||
void a();
|
||||
|
||||
void a(Intent intent, int i, int i2);
|
||||
}
|
Reference in New Issue
Block a user