jimu-decompiled/sources/com/liulishuo/filedownloader/services/FDServiceSeparateHandler.java
2025-05-13 19:24:51 +02:00

152 lines
5.6 KiB
Java

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);
}
}