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


package com.qq.e.comm;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.IBinder;
import android.text.TextUtils;
import com.qq.e.comm.managers.GDTADManager;
import com.qq.e.comm.pi.SVSD;
import com.qq.e.comm.util.GDTLogger;

public class DownloadService extends Service {
    private SVSD a;

    private boolean a() {
        if (this.a == null) {
            try {
                if (GDTADManager.getInstance().isInitialized()) {
                    SVSD aPKDownloadServiceDelegate = GDTADManager.getInstance().getPM().getPOFactory().getAPKDownloadServiceDelegate(this);
                    this.a = aPKDownloadServiceDelegate;
                    aPKDownloadServiceDelegate.onCreate();
                }
            } catch (Throwable th) {
                GDTLogger.e("初始化Service发生异常", th);
            }
        }
        return this.a != null;
    }

    public static void enterAPPDownloadListPage(Context context) {
        if (context == null) {
            GDTLogger.e("enterAPPDownloadListPage 调用异常,context为空");
            return;
        }
        Intent intent = new Intent(context, DownloadService.class);
        intent.putExtra("GDT_APPID", GDTADManager.getInstance().getAppStatus().getAPPID());
        intent.setAction("com.qq.e.comm.ACTION_DOWNLOAD_LIST");
        context.startService(intent);
    }

    public IBinder onBind(Intent intent) {
        GDTLogger.d("DownloadService.onBind");
        SVSD svsd = this.a;
        if (svsd != null) {
            return svsd.onBind(intent);
        }
        String stringExtra = intent.getStringExtra("GDT_APPID");
        GDTLogger.d("DownloadService.onBind,appID=" + stringExtra);
        if (TextUtils.isEmpty(stringExtra) || !a()) {
            return null;
        }
        return this.a.onBind(intent);
    }

    public void onConfigurationChanged(Configuration configuration) {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onConfigurationChanged(configuration);
        }
    }

    public void onCreate() {
        super.onCreate();
    }

    public void onDestroy() {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onDestroy();
        }
    }

    public void onLowMemory() {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onLowMemory();
        }
    }

    public void onRebind(Intent intent) {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onRebind(intent);
        }
    }

    public int onStartCommand(Intent intent, int i, int i2) {
        if (intent == null) {
            stopSelf(i2);
            return 2;
        } else if (!TextUtils.isEmpty(intent.getStringExtra("GDT_APPID")) && a()) {
            return this.a.onStartCommand(intent, i, i2);
        } else {
            GDTLogger.w("Service onStartCommand 出现异常");
            return 2;
        }
    }

    public void onTaskRemoved(Intent intent) {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onTaskRemoved(intent);
        }
    }

    public void onTrimMemory(int i) {
        SVSD svsd = this.a;
        if (svsd != null) {
            svsd.onTrimMemory(i);
        }
    }

    public boolean onUnbind(Intent intent) {
        SVSD svsd = this.a;
        return svsd != null ? svsd.onUnbind(intent) : super.onUnbind(intent);
    }
}