package com.zxhl.cms.common

import android.content.Context
import android.os.Build
import com.ayl.ces.jni.CesCore
import com.zx.ad.AdManager
import com.zx.ad.modulecommon.AdConstant
import com.zxhl.cms.AppContext
import com.zxhl.cms.utils.LogUtils
import com.zxhl.cms.utils.PhoneUtils
import org.jetbrains.anko.doAsync

/**
 * Created by gaoleichao on 2018/7/12.
 */
class Config {

    companion object {
        fun init(context: Context) {
            doAsync {
                CesCore.getInstance().init(AppContext.mAppContext)
                Constant.Param.vendor = Build.MANUFACTURER
                Constant.Param.svn = android.os.Build.VERSION.SDK_INT.toString()
                Constant.Param.model = PhoneUtils.getModel()
                Constant.Param.androidId = PhoneUtils.getAndroidID(context)
                Constant.Param.carrier = PhoneUtils.getOperator(context)
                Constant.Param.w = PhoneUtils.getScreenWidth(context).toString()
                Constant.Param.h = PhoneUtils.getScreenHeight(context).toString()
                Constant.Param.vc = PhoneUtils.getAppVersionCode(context).toString()
                Constant.Param.vn = PhoneUtils.getAppVersionName(context)
                Constant.Param.device = PhoneUtils.getDeviceId(context)
                Constant.Param.imei = PhoneUtils.getImei(context)
//                Constant.Param.ssid = PhoneUtils.getBSSID(context)
//                if (!TextUtils.isEmpty(Constant.Param.ssid)) {
//                    Constant.Param.ssid.replace(":", "")
//                }
                Constant.Param.ua = System.getProperty("http.agent")
                Constant.Param.ntt = PhoneUtils.getNetworkType(context)?.toString()
                Constant.Param.miToken = PhoneUtils.getDeviceToken(context)
//                uiThread {
//                    LocationProvider.getInstance(context).startLocation()
//                }
                Constant.Param.imsi = PhoneUtils.getIMSI(context)
//                Constant.Param.mac = PhoneUtils.getMac(context) ?: ""
//                Constant.Param.env = CesCore.getInstance().Ckwork(Constant.Param.androidId)
                LogUtils.d("Param", "Param.androidId:  " + Constant.Param.androidId)
                LogUtils.d("Param", "Param.carrier:  " + Constant.Param.carrier)
                LogUtils.d("Param", "Param.w:  " + Constant.Param.w)
                LogUtils.d("Param", "Param.h:  " + Constant.Param.h)
                LogUtils.d("Param", "Param.model:  " + Constant.Param.model)
                LogUtils.d("Param", "Param.vc:  " + Constant.Param.vc)
                LogUtils.d("Param", "Param.device:  " + Constant.Param.device)
                LogUtils.d("Param", "Param.imei:  " + Constant.Param.imei)
                LogUtils.d("Param", "Param.mac:  " + Constant.Param.mac)
                LogUtils.d("Param", "Param.ua:  " + Constant.Param.ua)
                LogUtils.d("Param", "Param.ntt:  " + Constant.Param.ntt)
                LogUtils.d("Param", "Param.svn:  " + Constant.Param.svn)
                LogUtils.d("Param", "Param.vendor:  " + Constant.Param.vendor)
                LogUtils.d("Param", "Param.imsi:  " + Constant.Param.imsi)
                LogUtils.d("Param", "Param.miToken:  " + Constant.Param.miToken)
                LogUtils.d("Param", "Param.env:  " + Constant.Param.env)
                AdConstant.param.androidId = Constant.Param.androidId
                AdConstant.param.carrier = Constant.Param.carrier
                AdConstant.param.w = Constant.Param.w
                AdConstant.param.h = Constant.Param.h
                AdConstant.param.model = Constant.Param.model
                AdConstant.param.vc = Constant.Param.vc
                AdConstant.param.device = Constant.Param.device
                AdConstant.param.imei = Constant.Param.imei
                AdConstant.param.mac = Constant.Param.mac
                AdConstant.param.ua = Constant.Param.ua
                AdConstant.param.ntt = Constant.Param.ntt
                AdConstant.param.svn = Constant.Param.svn
                AdConstant.param.imsi = Constant.Param.imsi
                AdConstant.param.env = Constant.Param.env
                AdManager.init(context, Constant.Param.APPLS)
            }
        }
    }
}