翰林优商.apk(点击下载) / SqlDownloadCacheService.java


package com.ss.android.socialbase.downloader.downloader;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import com.ss.android.socialbase.downloader.impls.d;

public class SqlDownloadCacheService extends Service {
    private static final String a = "SqlDownloadCacheService";

    public static void a(Context context, ServiceConnection serviceConnection) {
        if (context != null) {
            try {
                Intent intent = new Intent(context, SqlDownloadCacheService.class);
                if (serviceConnection != null) {
                    context.bindService(intent, serviceConnection, 1);
                }
                context.startService(intent);
            } catch (Throwable th) {
                Log.w(a, "startServiceAndBind fail", th);
            }
        }
    }

    public void onCreate() {
        super.onCreate();
        c.a(getApplicationContext());
    }

    public IBinder onBind(Intent intent) {
        t tVar;
        j x = c.x();
        if (x instanceof d) {
            tVar = ((d) x).f();
        } else {
            tVar = x instanceof t ? (t) x : null;
        }
        if (tVar instanceof IBinder) {
            return (IBinder) tVar;
        }
        return new Binder();
    }

    public int onStartCommand(Intent intent, int i, int i2) {
        int onStartCommand = super.onStartCommand(intent, i, i2);
        if (c.j()) {
            return 2;
        }
        return onStartCommand;
    }
}