電視直播.apk(点击下载) / 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.f.d;
import com.kwad.framework.filedownloader.f.f;
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 final ArrayList<Runnable> afd = new ArrayList<>();
    private final CALLBACK ahV;
    private volatile INTERFACE ahW;
    private final HashMap<String, Object> ahX = new HashMap<>();
    private final List<Context> ahY = new ArrayList();
    private final Class<?> ahq;

    protected a(Class<?> cls) {
        this.ahq = cls;
        this.ahV = uW();
    }

    private void a(Context context, Runnable runnable) {
        if (!f.an(context)) {
            if (d.aiv) {
                d.c(this, "bindStartByContext %s", context.getClass().getSimpleName());
            }
            Intent intent = new Intent(context, this.ahq);
            if (!this.ahY.contains(context)) {
                this.ahY.add(context);
            }
            context.bindService(intent, this, 1);
            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");
    }

    private void bg(boolean z) {
        if (d.aiv) {
            d.c(this, "release connect resources %s", this.ahW);
        }
        this.ahW = null;
        com.kwad.framework.filedownloader.f.uE().c(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.lost, this.ahq));
    }

    /* access modifiers changed from: protected */
    public abstract void a(INTERFACE v, CALLBACK callback);

    @Override // com.kwad.framework.filedownloader.u
    public final void ak(Context context) {
        a(context, (Runnable) null);
    }

    /* access modifiers changed from: protected */
    public abstract INTERFACE b(IBinder iBinder);

    @Override // com.kwad.framework.filedownloader.u
    public final boolean isConnected() {
        return wv() != null;
    }

    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        this.ahW = b(iBinder);
        if (d.aiv) {
            d.c(this, "onServiceConnected %s %s", componentName, this.ahW);
        }
        try {
            a(this.ahW, this.ahV);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
        this.afd.clear();
        for (Runnable runnable : (List) this.afd.clone()) {
            runnable.run();
        }
        com.kwad.framework.filedownloader.f.uE().c(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.connected, this.ahq));
    }

    public void onServiceDisconnected(ComponentName componentName) {
        if (d.aiv) {
            d.c(this, "onServiceDisconnected %s %s", componentName, this.ahW);
        }
        bg(true);
    }

    /* access modifiers changed from: protected */
    public abstract CALLBACK uW();

    /* access modifiers changed from: protected */
    public final INTERFACE wv() {
        return this.ahW;
    }
}