万能钥匙.apk(点击下载) / a.java


package com.liulishuo.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.Build;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import com.liulishuo.filedownloader.event.DownloadServiceConnectChangedEvent;
import com.liulishuo.filedownloader.f;
import com.liulishuo.filedownloader.g.d;
import com.liulishuo.filedownloader.u;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/* compiled from: BaseFileServiceUIGuard */
public abstract class a<CALLBACK extends Binder, INTERFACE extends IInterface> implements ServiceConnection, u {

    /* renamed from: a  reason: collision with root package name */
    protected volatile INTERFACE f7715a;

    /* renamed from: b  reason: collision with root package name */
    protected boolean f7716b = false;
    private final CALLBACK c;
    private final Class<?> d;
    private final HashMap<String, Object> e = new HashMap<>();
    private final List<Context> f = new ArrayList();
    private final ArrayList<Runnable> g = new ArrayList<>();

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

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

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

    protected a(Class<?> cls) {
        this.d = cls;
        this.c = d();
    }

    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        this.f7715a = a(iBinder);
        if (d.f7665a) {
            d.c(this, "onServiceConnected %s %s", componentName, this.f7715a);
        }
        try {
            a(this.f7715a, this.c);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
        this.g.clear();
        for (Runnable runnable : (List) this.g.clone()) {
            runnable.run();
        }
        f.a.f7659a.b(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.connected, this.d));
    }

    public void onServiceDisconnected(ComponentName componentName) {
        if (d.f7665a) {
            d.c(this, "onServiceDisconnected %s %s", componentName, this.f7715a);
        }
        if (d.f7665a) {
            d.c(this, "release connect resources %s", this.f7715a);
        }
        this.f7715a = null;
        f.a.f7659a.b(new DownloadServiceConnectChangedEvent(DownloadServiceConnectChangedEvent.ConnectStatus.lost, this.d));
    }

    @Override // com.liulishuo.filedownloader.u
    public final boolean c() {
        return this.f7716b;
    }

    @Override // com.liulishuo.filedownloader.u
    public final void a(Context context) {
        if (!com.liulishuo.filedownloader.g.f.a(context)) {
            if (d.f7665a) {
                d.c(this, "bindStartByContext %s", context.getClass().getSimpleName());
            }
            Intent intent = new Intent(context, this.d);
            if (!this.f.contains(context)) {
                this.f.add(context);
            }
            this.f7716b = com.liulishuo.filedownloader.g.f.e(context);
            intent.putExtra("is_foreground", this.f7716b);
            context.bindService(intent, this, 1);
            if (this.f7716b) {
                if (d.f7665a) {
                    d.c(this, "start foreground service", new Object[0]);
                }
                if (Build.VERSION.SDK_INT >= 26) {
                    context.startForegroundService(intent);
                    return;
                }
                return;
            }
            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");
    }

    @Override // com.liulishuo.filedownloader.u
    public final boolean b() {
        return this.f7715a != null;
    }
}