package com.letv.component.upgrade.utils;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Environment;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.letv.component.upgrade.core.service.DownLoadFunction;
import com.letv.component.upgrade.core.service.RemoteDownloadTaskService;
import com.letv.component.upgrade.core.upgrade.UpgradeCallBack;
import com.letv.component.upgrade.core.upgrade.UpgradeSilenceCallBack;
import com.letv.component.utils.ApnChecker;
import com.letv.component.utils.DebugLog;
import com.letv.download.manager.StoreManager;
import io.fabric.sdk.android.services.common.CommonUtils;
import io.fabric.sdk.android.services.events.EventsFilesManager;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.Proxy;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Enumeration;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class LetvUtil {
    public static final int NETTYPE_2G = 2;
    public static final int NETTYPE_3G = 3;
    public static final int NETTYPE_NO = 0;
    public static final int NETTYPE_WIFI = 1;
    private static final String TAG = "LetvUtil";
    private static String deviceID;
    private static Executor executor;
    static Context mContext;
    static File mFile;
    String isHd;
    String mmsid;
    String pcode;
    String version;

    public LetvUtil(String mmsid, String isHd, String pcode, String version, Context mContext) {
        this.mmsid = mmsid;
        this.isHd = isHd;
        this.pcode = pcode;
        this.version = version;
        mContext = mContext;
    }

    public LetvUtil(Context mContext) {
        mContext = mContext;
    }

    public static URLConnection initConnection(URL url, Context mContext) throws IOException {
        Proxy mProxy = ApnChecker.getProxy(mContext);
        if (mProxy != null) {
            return (HttpURLConnection) url.openConnec