|
@@ -5,6 +5,7 @@ import android.app.Application
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.text.TextUtils
|
|
|
+import cn.yyxx.eyuancomm.comm.EYuanCommInstaller
|
|
|
import cn.yyxx.eyuancomm.comm.entity.*
|
|
|
import cn.yyxx.eyuancomm.comm.entity.Function
|
|
|
import cn.yyxx.eyuancomm.comm.internal.ICallback
|
|
@@ -14,9 +15,6 @@ import cn.yyxx.eyuancomm.comm.utils.Logger
|
|
|
import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
|
|
|
import cn.yyxx.eyuancomm.comm.widget.ScaleLoadingDialog
|
|
|
import cn.yyxx.support.JsonUtils
|
|
|
-import cn.yyxx.support.device.DeviceInfoUtils
|
|
|
-import cn.yyxx.support.gaid.GAIDUtils
|
|
|
-import cn.yyxx.support.msa.MsaDeviceIdsHandler
|
|
|
import org.json.JSONObject
|
|
|
import java.util.concurrent.atomic.AtomicInteger
|
|
|
|
|
@@ -28,7 +26,8 @@ class CommSdkImpl(context: Context) {
|
|
|
|
|
|
private var mSdkProxy: Any? = null
|
|
|
private var hasSdkInit = false
|
|
|
- private var hasReadDeviceId = false
|
|
|
+
|
|
|
+ // private var hasReadDeviceId = false
|
|
|
private var channelId: String = ""
|
|
|
|
|
|
private var initLoadingDialog: ScaleLoadingDialog? = null
|
|
@@ -57,11 +56,9 @@ class CommSdkImpl(context: Context) {
|
|
|
* 同步Application中的attachBaseContext
|
|
|
*/
|
|
|
fun attachBaseContext(application: Application, context: Context) {
|
|
|
- Logger.initZap(application)
|
|
|
- Logger.i("EYuanCommSdk attachBaseContext ...")
|
|
|
- CommSdkDrive.instance.initSdkDrive(application)
|
|
|
- initGaid(application)
|
|
|
-
|
|
|
+// Logger.i("EYuanCommSdk attachBaseContext ...")
|
|
|
+// CommSdkDrive.instance.initSdkDrive(application)
|
|
|
+// initGaid(application)
|
|
|
if (mSdkProxy == null) {
|
|
|
mSdkProxy = getSdkProxyManager(application)
|
|
|
}
|
|
@@ -69,42 +66,42 @@ class CommSdkImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private fun initGaid(application: Application) {
|
|
|
- GAIDUtils.initGoogleAdid(application) { code, _ ->
|
|
|
- if (code == 0) {
|
|
|
- if (GAIDUtils.getGoogleAdid() == "00000000-0000-0000-0000-000000000000") {
|
|
|
- Logger.i("谷歌框架可以访问,gaid被限制跟踪,尝试使用oaid")
|
|
|
- initOaid(application)
|
|
|
- } else {
|
|
|
- Logger.i("谷歌框架可以访问,请求gaid")
|
|
|
- CommSdkDrive.instance.setCommParam("device_id", GAIDUtils.getGoogleAdid())
|
|
|
- hasReadDeviceId = true
|
|
|
- }
|
|
|
- } else {
|
|
|
- Logger.e("谷歌框架不可访问,尝试使用oaid")
|
|
|
- initOaid(application)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun initOaid(application: Application) {
|
|
|
- MsaDeviceIdsHandler.initMsaDeviceIds(application) { code, msg, _ ->
|
|
|
- if (code == 0) {
|
|
|
- Logger.e("获取oaid成功,使用oaid替代")
|
|
|
- CommSdkDrive.instance.setCommParam("device_id", MsaDeviceIdsHandler.oaid)
|
|
|
- } else {
|
|
|
- Logger.d("获取oaid失败,msg: $msg,使用android id替代")
|
|
|
- CommSdkDrive.instance.setCommParam("device_id", DeviceInfoUtils.getAndroidDeviceId(application))
|
|
|
- }
|
|
|
- hasReadDeviceId = true
|
|
|
- }
|
|
|
- }
|
|
|
+// private fun initGaid(application: Application) {
|
|
|
+// GAIDUtils.initGoogleAdid(application) { code, _ ->
|
|
|
+// if (code == 0) {
|
|
|
+// if (GAIDUtils.getGoogleAdid() == "00000000-0000-0000-0000-000000000000") {
|
|
|
+// Logger.i("谷歌框架可以访问,gaid被限制跟踪,尝试使用oaid")
|
|
|
+// initOaid(application)
|
|
|
+// } else {
|
|
|
+// Logger.i("谷歌框架可以访问,请求gaid")
|
|
|
+// CommSdkDrive.instance.setCommParam("device_id", GAIDUtils.getGoogleAdid())
|
|
|
+// hasReadDeviceId = true
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// Logger.e("谷歌框架不可访问,尝试使用oaid")
|
|
|
+// initOaid(application)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// private fun initOaid(application: Application) {
|
|
|
+// MsaDeviceIdsHandler.initMsaDeviceIds(application) { code, msg, _ ->
|
|
|
+// if (code == 0) {
|
|
|
+// Logger.e("获取oaid成功,使用oaid替代")
|
|
|
+// CommSdkDrive.instance.setCommParam("device_id", MsaDeviceIdsHandler.oaid)
|
|
|
+// } else {
|
|
|
+// Logger.d("获取oaid失败,msg: $msg,使用android id替代")
|
|
|
+// CommSdkDrive.instance.setCommParam("device_id", DeviceInfoUtils.getAndroidDeviceId(application))
|
|
|
+// }
|
|
|
+// hasReadDeviceId = true
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 同步Application中的onCreate
|
|
|
*/
|
|
|
fun initApplication(application: Application) {
|
|
|
- Host.initHostModel(application)
|
|
|
+// Host.initHostModel(application)
|
|
|
if (mSdkProxy == null) {
|
|
|
mSdkProxy = getSdkProxyManager(application)
|
|
|
}
|
|
@@ -132,13 +129,13 @@ class CommSdkImpl(context: Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (!hasReadDeviceId) {
|
|
|
+ if (!EYuanCommInstaller.hasReadDeviceId) {
|
|
|
Logger.e("还未完成deviceId加载,将延迟初始化")
|
|
|
showInitLoadingDialog(activity)
|
|
|
Thread {
|
|
|
- while (!hasReadDeviceId) {
|
|
|
+ while (!EYuanCommInstaller.hasReadDeviceId) {
|
|
|
try {
|
|
|
- Logger.e("还未完成deviceId加载,延迟1s初始化,$hasReadDeviceId")
|
|
|
+ Logger.e("还未完成deviceId加载,延迟1s初始化,$EYuanCommInstaller.hasReadDeviceId")
|
|
|
Thread.sleep(1000)
|
|
|
timeCount.getAndIncrement()
|
|
|
} catch (e: InterruptedException) {
|
|
@@ -146,7 +143,7 @@ class CommSdkImpl(context: Context) {
|
|
|
}
|
|
|
}
|
|
|
activity.runOnUiThread {
|
|
|
- if (hasReadDeviceId) {
|
|
|
+ if (EYuanCommInstaller.hasReadDeviceId) {
|
|
|
Logger.i("加载deviceI完成,共延迟${timeCount}s初始化,将进行初始化操作...")
|
|
|
startSdkInit(activity, isLandscape, callback)
|
|
|
}
|
|
@@ -177,7 +174,6 @@ class CommSdkImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
private fun startInitCommSdk(activity: Activity, callback: ICallback) {
|
|
|
- Logger.d("融合Sdk初始化...")
|
|
|
SdkRequest.instance.initSdk(activity, "") { resultInfo ->
|
|
|
hasSdkInit = resultInfo.code == 1
|
|
|
initLoadingDialog?.apply {
|
|
@@ -503,7 +499,7 @@ class CommSdkImpl(context: Context) {
|
|
|
// return
|
|
|
// }
|
|
|
//
|
|
|
-// SdkProxyManager.call(Function.LINKING_EVENT, arrayOf(Context::class.java, SdkEvent::class.java), arrayOf(context, sdkEvent))
|
|
|
+// SdkProxyManager.call(Function.LINKING_EVENT, arrayOf(Context::class.kotlin, SdkEvent::class.kotlin), arrayOf(context, sdkEvent))
|
|
|
// }
|
|
|
//
|
|
|
// fun share(activity: Activity, line: String, tag: String, quote: String, callback: ICallback) {
|
|
@@ -515,7 +511,7 @@ class CommSdkImpl(context: Context) {
|
|
|
// }
|
|
|
//
|
|
|
// SdkProxyManager.call(
|
|
|
-// Function.SHARE, arrayOf(Activity::class.java, String::class.java, String::class.java, String::class.java, ICallback::class.java),
|
|
|
+// Function.SHARE, arrayOf(Activity::class.kotlin, String::class.kotlin, String::class.kotlin, String::class.kotlin, ICallback::class.kotlin),
|
|
|
// arrayOf(activity, line, tag, quote, callback)
|
|
|
// )
|
|
|
// }
|