我要上王者 v1.1版本的 MD5 值为:b7d3566522def961cabeb92cb17f5db9

以下内容为反编译后的 a.java 源代码,内容仅作参考


package com.kwad.framework.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.kwad.framework.filedownloader.event.DownloadServiceConnectChangedEvent;
import com.kwad.framework.filedownloader.u;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public abstract class a<CALLBACK extends Binder, INTERFACE extends IInterface> implements ServiceConnection, u {
    private volatile INTERFACE agS;
    private final Class<?> agm;
    private final HashMap<String, Object> agT = new HashMap<>();
    private final List<Context> agU = new ArrayList();
    private final ArrayList<Runnable> adZ = new ArrayList<>();
    private final CALLBACK agR = us();

    protected abstract void a(INTERFACE r1, CALLBACK callback);

    protected abstract INTERFACE b(IBinder iBinder);

    protected abstract CALLBACK us();

    public final INTERFACE vR() {
        return this.agS;
    }

    public a(Class<?> cls) {
        this.agm = cls;
    }

    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        this.agS = b(iBinder);
        if (com.kwad.framework.filedownloader.f.d.ahr) {
            com.kwad.framework.filedownloader.f.d.c(this, "onServiceConnected %s %s", componentName, this.agS);
        }
        try {
            a((a<CALLBACK, INTERFACE>) this.agS, (INTERFACE) this.agR);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        this.adZ.clear();
        for (Runnable runnable : (List) this.adZ.clone()) {
            runnable.run();
        }
        com.kwad.framework.filedownloader.f.ua().c(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.connected, this.agm));
    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        if (com.kwad.framework.filedownloader.f.d.ahr) {
            com.kwad.framework.filedownloader.f.d.c(this, "onServiceDisconnected %s %s", componentName, this.agS);
        }
        bb(true);
    }

    private void bb(boolean z) {
        if (com.kwad.framework.filedownloader.f.d.ahr) {
            com.kwad.framework.filedownloader.f.d.c(this, "release connect resources %s", this.agS);
        }
        this.agS = null;
        com.kwad.framework.filedownloader.f.ua().c(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.lost, this.agm));
    }

    @Override
    public final void ao(Context context) {
        a(context, (Runnable) null);
    }

    private void a(Context context, Runnable runnable) {
        if (com.kwad.framework.filedownloader.f.f.ar(context)) {
            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");
        }
        if (com.kwad.framework.filedownloader.f.d.ahr) {
            com.kwad.framework.filedownloader.f.d.c(this, "bindStartByContext %s", context.getClass().getSimpleName());
        }
        Intent intent = new Intent(context, this.agm);
        if (!this.agU.contains(context)) {
            this.agU.add(context);
        }
        context.bindService(intent, this, 1);
        context.startService(intent);
    }

    @Override
    public final boolean isConnected() {
        return vR() != null;
    }
}