package com.ym.modulecommon;

import android.content.Context
import android.text.TextUtils
import com.ym.modulecommon.utils.PhoneUtils
import com.ym.modulecommon.utils.AdPreference
import com.ym.modulecommon.utils.Utils
import org.jetbrains.anko.doAsync
import java.lang.Exception

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

    companion object {
        fun init(context: Context) {
            doAsync {
                try {
                    if (TextUtils.isEmpty(AdPreference.getUid())) {
                        AdPreference.setUid(AdPreference.getUid())
                    }
                    AdPreference.setModel(PhoneUtils.getModel())
                    AdPreference.setAndroidId(PhoneUtils.getAndroidID(context))
                    AdPreference.setCarrier(PhoneUtils.getOperator(context))
                    AdPreference.setW(PhoneUtils.getScreenWidth(context).toString())
                    AdPreference.setH(PhoneUtils.getScreenHeight(context).toString())

                    AdPreference.setDevice(PhoneUtils.getDeviceId(context))
                    AdPreference.setImei(PhoneUtils.getImei(context))
                    AdPreference.setSsid(PhoneUtils.getBSSID(context))
                    AdPreference.setImsi(PhoneUtils.getIMSI(context))
                    AdPreference.setMac(PhoneUtils.getMac(context))
                    AdPreference.setVC(PhoneUtils.getAppVersionCode(context).toString())
                    AdPreference.setVN(PhoneUtils.getAppVersionName(context))
                    AdPreference.setNTT(PhoneUtils.getNetworkType(context).toString())

                    AdPreference.setMac(PhoneUtils.getMac(context))
                    AdPreference.setIp(PhoneUtils.getIPAddress(false))
                    AdPreference.setSource(Utils.getChannel(context))
                    AdPreference.setSVN(""+android.os.Build.VERSION.SDK_INT)
                } catch (e:Exception){}
            }
        }
    }
}