package com.mints.goodmoney.manager

import android.content.Context
import com.bun.miitmdid.core.MdidSdkHelper
import com.bun.supplier.IIdentifierListener
import com.bun.supplier.IdSupplier

/**
 * 移动安全联盟 oaid
 */
class OaidManager(val _listener: AppIdsUpdater?) : IIdentifierListener {
    fun InitSdk(cxt: Context) {
        CallFromReflect(cxt)
    }

    /*
     * 通过反射调用，解决android 9以后的类加载升级，导至找不到so中的方法
     *
     * */
    private fun CallFromReflect(cxt: Context): Int {
        return MdidSdkHelper.InitSdk(cxt, true, this)
    }

    override fun OnSupport(isSupport: Boolean, _supplier: IdSupplier) {
        if (_supplier == null) {
            return
        }
        /* String oaid=_supplier.getOaid();
        String vaid=_supplier.getVAID();
        String aaid=_supplier.getAAID();
        String udid=_supplier.getUDID();
        StringBuilder builder=new StringBuilder();
        builder.append("support: ").append(isSupport?"true":"false").append("\n");
        builder.append("UDID: ").append(udid).append("\n");
        builder.append("OAID: ").append(oaid).append("\n");
        builder.append("VAID: ").append(vaid).append("\n");
        builder.append("AAID: ").append(aaid).append("\n");
        String idstext=builder.toString();*/

        val oaid = _supplier.oaid
        _listener?.OnIdsAvalid(oaid)
    }

    interface AppIdsUpdater {
        fun OnIdsAvalid(ids: String)
    }
}