Initial commit
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user