package com.kwai.filedownloader.services; import android.app.Notification; import android.os.IBinder; import android.os.RemoteCallbackList; import android.os.RemoteException; import com.kwai.filedownloader.b.a; import com.kwai.filedownloader.b.b; import com.kwai.filedownloader.message.MessageSnapshot; import com.kwai.filedownloader.message.e; import java.lang.ref.WeakReference; public final class d extends b.a implements e.b, i { private final RemoteCallbackList<a> bKe = new RemoteCallbackList<>(); private final g bKf; private final WeakReference<FileDownloadServiceProxy> bKg; d(WeakReference<FileDownloadServiceProxy> weakReference, g gVar) { this.bKg = weakReference; this.bKf = gVar; e.ade().a(this); } private synchronized int v(MessageSnapshot messageSnapshot) { int beginBroadcast; RemoteCallbackList<a> remoteCallbackList; beginBroadcast = this.bKe.beginBroadcast(); for (int i = 0; i < beginBroadcast; i++) { try { this.bKe.getBroadcastItem(i).q(messageSnapshot); } catch (RemoteException e) { com.kwai.filedownloader.e.d.a(this, e, "callback error", new Object[0]); remoteCallbackList = this.bKe; } catch (Throwable th) { this.bKe.finishBroadcast(); throw th; } } remoteCallbackList = this.bKe; remoteCallbackList.finishBroadcast(); return beginBroadcast; } @Override // com.kwai.filedownloader.b.b public final void a(a aVar) { this.bKe.register(aVar); } @Override // com.kwai.filedownloader.b.b public final void acU() { this.bKf.acU(); } @Override // com.kwai.filedownloader.services.i public final void adA() { } @Override // com.kwai.filedownloader.services.i public final IBinder adB() { return this; } @Override // com.kwai.filedownloader.b.b public final boolean an(String str, String str2) { return this.bKf.ap(str, str2); } @Override // com.kwai.filedownloader.b.b public final void b(a aVar) { this.bKe.unregister(aVar); } @Override // com.kwai.filedownloader.b.b public final void b(String str, String str2, boolean z, int i, int i2, int i3, boolean z2, com.kwai.filedownloader.c.b bVar, boolean z3) { this.bKf.b(str, str2, z, i, i2, i3, z2, bVar, z3); } @Override // com.kwai.filedownloader.b.b public final byte eA(int i) { return this.bKf.eA(i); } @Override // com.kwai.filedownloader.b.b public final boolean eB(int i) { return this.bKf.eB(i); } @Override // com.kwai.filedownloader.b.b public final boolean eT(int i) { return this.bKf.eT(i); } @Override // com.kwai.filedownloader.b.b public final long eU(int i) { return this.bKf.ff(i); } @Override // com.kwai.filedownloader.b.b public final long eV(int i) { return this.bKf.eV(i); } @Override // com.kwai.filedownloader.b.b public final boolean ez(int i) { return this.bKf.ez(i); } @Override // com.kwai.filedownloader.b.b public final boolean isIdle() { return this.bKf.isIdle(); } @Override // com.kwai.filedownloader.services.i public final void onDestroy() { e.ade().a(null); } @Override // com.kwai.filedownloader.b.b public final void pauseAllTasks() { this.bKf.adC(); } @Override // com.kwai.filedownloader.message.e.b public final void r(MessageSnapshot messageSnapshot) { v(messageSnapshot); } @Override // com.kwai.filedownloader.b.b public final void startForeground(int i, Notification notification) { WeakReference<FileDownloadServiceProxy> weakReference = this.bKg; if (weakReference != null && weakReference.get() != null) { this.bKg.get().context.startForeground(i, notification); } } @Override // com.kwai.filedownloader.b.b public final void stopForeground(boolean z) { WeakReference<FileDownloadServiceProxy> weakReference = this.bKg; if (weakReference != null && weakReference.get() != null) { this.bKg.get().context.stopForeground(z); } } }