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

import X.C3561QXu;
import X.QY1;
import X.QYN;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import com.bytedance.covode.number.Covode;
import com.bytedance.helios.sdk.utils.ServiceLifecycle;
import java.lang.ref.WeakReference;
import java.util.concurrent.ExecutorService;

public class DownloadService extends Service {
    public static final String LIZIZ = DownloadService.class.getSimpleName();
    public QYN LIZ;

    static {
        Covode.recordClassIndex(49003);
    }

    public void onCreate() {
        super.onCreate();
        QY1.LIZ((Context) this);
        QYN LJIIZILJ = QY1.LJIIZILJ();
        this.LIZ = LJIIZILJ;
        LJIIZILJ.LIZ(new WeakReference(this));
    }

    public void onDestroy() {
        if (C3561QXu.LIZ()) {
            C3561QXu.LIZIZ(LIZIZ, "Service onDestroy");
        }
        QYN qyn = this.LIZ;
        if (qyn != null) {
            qyn.LJ();
            this.LIZ = null;
        }
        super.onDestroy();
    }

    public IBinder onBind(Intent intent) {
        boolean z;
        String str = LIZIZ;
        StringBuilder sb = new StringBuilder("onBind downloadServiceHandler != null:");
        if (this.LIZ != null) {
            z = true;
        } else {
            z = false;
        }
        sb.append(z);
        C3561QXu.LIZIZ(str, sb.toString());
        QYN qyn = this.LIZ;
        if (qyn != null) {
            return qyn.LIZ(intent);
        }
        return null;
    }

    public int onStartCommand(final Intent intent, final int i, final int i2) {
        ServiceLifecycle.onStartCommand(this, intent, i, i2);
        if (C3561QXu.LIZ()) {
            C3561QXu.LIZIZ(LIZIZ, "DownloadService onStartCommand");
        }
        this.LIZ.LIZJ();
        ExecutorService LJI = QY1.LJI();
        if (LJI != null) {
            LJI.execute(new Runnable() {
                static {
                    Covode.recordClassIndex(49004);
                }

                public final void run() {
                    if (DownloadService.this.LIZ != null) {
                        DownloadService.this.LIZ.LIZLLL();
                    }
                }
            });
        }
        if (QY1.LJ()) {
            return 2;
        }
        return 3;
    }
}
