Pārlūkot izejas kodu

v1.0.0开发:角色信息上报开发

#Suyghur 2 gadi atpakaļ
vecāks
revīzija
db0d259db3
22 mainītis faili ar 707 papildinājumiem un 161 dzēšanām
  1. 1 1
      demo/src/main/AndroidManifest.xml
  2. 4 1
      demo/src/main/assets/yyxx_game/yyxx_comm.properties
  3. 22 12
      demo/src/main/kotlin/com/eyuancomm/demo/CacheRoleInfo.kt
  4. 5 2
      demo/src/main/kotlin/com/eyuancomm/demo/DemoActivity.kt
  5. 5 5
      library_comm/build.gradle
  6. 0 5
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/EYuanCommInstaller.kt
  7. 8 2
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/entity/SdkEvent.kt
  8. 6 3
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/entity/SdkRoleInfo.kt
  9. 17 2
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/impl/CommSdkImpl.kt
  10. 1 1
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/Host.kt
  11. 87 14
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/SdkRequest.kt
  12. 98 34
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/VolleyRequest.kt
  13. 15 7
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/TraceEventManager.kt
  14. 1 1
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/AdjustEventImpl.kt
  15. 151 0
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/FacebookEventImpl.kt
  16. 123 0
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/FirebaseEventImpl.kt
  17. 41 1
      library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/utils/ParamsUtils.kt
  18. 9 9
      library_impl/src/main/java/cn/yyxx/eyuancomm/impl/ImplSdkProxy.kt
  19. BIN
      libs/apklink.jar
  20. BIN
      libs/eyuancommsdk-comm-1.0.0.jar
  21. 112 61
      module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/network/SdkRequest.kt
  22. 1 0
      settings.gradle

+ 1 - 1
demo/src/main/AndroidManifest.xml

@@ -8,7 +8,7 @@
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:requestLegacyExternalStorage="false"
-        android:resizeableActivity="false"
+        android:resizeableActivity="true"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
 

+ 4 - 1
demo/src/main/assets/yyxx_game/yyxx_comm.properties

@@ -1,9 +1,12 @@
 # 融合应用编号
-YYXX_GCP_CODE=Y010402
+YYXX_GCP_CODE=Y010401
 YYXX_GAME_CODE=100001
 # 渠道Id
 YYXX_CHANNEL_ID=4
 # 事件打点应用ID
+YYXX_ADJUST_TRACE=true
 YYXX_ADJUST_APP_ID=ymyq28xetdkw
+YYXX_FACEBOOK_TRACE=true
+YYXX_FIREBASE_TRACE=true
 # debug模式(cp出正式包请关闭)
 YYXX_OWN_DEBUG=true

+ 22 - 12
demo/src/main/kotlin/com/eyuancomm/demo/CacheRoleInfo.kt

@@ -13,23 +13,27 @@ class CacheRoleInfo {
 
     data class RoleInfo(
         var roleId: String = "", var roleName: String = "", var roleLevel: String = "",
+        var rolePower: Int = 0, var roleGold: Int = 0, var roleChange: Int = 0,
         var serverCode: String = "", var serverName: String = "", var vipLevel: String = "",
-        var balance: String = "", var totalPurchase: Int = 0, var roleCTime: Long = 0
+        var partyId: String = "", var partyName: String = "", var roleCTime: Long = 0
     ) {
         fun toJsonString(): String {
+            val jsonObject = JSONObject()
             try {
-                val jsonObject = JSONObject()
                 jsonObject.put("role_id", roleId)
                 jsonObject.put("role_name", roleName)
                 jsonObject.put("role_level", roleLevel)
+                jsonObject.put("role_power", rolePower)
+                jsonObject.put("role_gold", roleGold)
+                jsonObject.put("role_change", roleChange)
+                jsonObject.put("role_ctime", roleCTime)
+                jsonObject.put("party_id", partyId)
+                jsonObject.put("party_name", partyName)
                 jsonObject.put("server_code", serverCode)
                 jsonObject.put("server_name", serverName)
                 jsonObject.put("vip_level", vipLevel)
-                jsonObject.put("balance", balance)
-                jsonObject.put("total_purchase", totalPurchase)
-                jsonObject.put("role_ctime", roleCTime)
                 return jsonObject.toString()
-            } catch (e: JSONException) {
+            } catch (e: Exception) {
                 e.printStackTrace()
             }
             return ""
@@ -44,12 +48,15 @@ class CacheRoleInfo {
                 roleId = "aaa$ts",
                 roleName = "角色名123",
                 roleLevel = "110",
+                rolePower = 100,
+                roleGold = 100,
+                roleChange = 100,
                 serverCode = "333",
                 serverName = "服务器名333",
                 vipLevel = "1",
-                balance = "600",
-                totalPurchase = 0,
-                roleCTime = ts
+                roleCTime = ts,
+                partyId = "party_101",
+                partyName = "帮派名"
             )
             val info = roleInfo.toJsonString()
             val sp = context.getSharedPreferences("app_role_info", Context.MODE_PRIVATE)
@@ -75,9 +82,12 @@ class CacheRoleInfo {
                         serverCode = jsonObject.getString("server_code"),
                         serverName = jsonObject.getString("server_name"),
                         vipLevel = jsonObject.getString("vip_level"),
-                        balance = jsonObject.getString("balance"),
-                        totalPurchase = jsonObject.getInt("total_purchase"),
-                        roleCTime = jsonObject.getLong("role_ctime")
+                        partyId = jsonObject.getString("party_id"),
+                        partyName = jsonObject.getString("party_name"),
+                        roleCTime = jsonObject.getLong("role_ctime"),
+                        rolePower = jsonObject.getInt("role_power"),
+                        roleGold = jsonObject.getInt("role_gold"),
+                        roleChange = jsonObject.getInt("role_change")
                     )
                 }
 

+ 5 - 2
demo/src/main/kotlin/com/eyuancomm/demo/DemoActivity.kt

@@ -195,8 +195,11 @@ class DemoActivity : Activity(), View.OnClickListener {
             //用户VIP等级,无该字段则传空串""
             gameRoleInfo.vipLevel = vipLevel
             //当前角色游戏币余额
-            gameRoleInfo.balance = balance
-            gameRoleInfo.totalPurchase = totalPurchase
+            gameRoleInfo.rolePower = rolePower
+            gameRoleInfo.roleGold = roleGold
+            gameRoleInfo.roleChange = roleChange
+            gameRoleInfo.partyId = partyId
+            gameRoleInfo.partyName = partyName
         }
         return gameRoleInfo
     }

+ 5 - 5
library_comm/build.gradle

@@ -35,29 +35,27 @@ android {
     buildFeatures {
         buildConfig false
     }
-
     lintOptions {
         abortOnError false
     }
-
     compileOptions {
         kotlinOptions.freeCompilerArgs += ['-module-name', "cn.yyxx.eyuancomm.comm"]
     }
-
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
-
     kotlinOptions {
         jvmTarget = "1.8"
     }
-
     externalNativeBuild {
         cmake {
             path "CMakeLists.txt"
         }
     }
+    packagingOptions {
+        resources.excludes += "DebugProbesKt.bin"
+    }
 }
 
 dependencies {
@@ -70,6 +68,8 @@ dependencies {
     api 'com.tencent:mmkv-static:1.2.10'
 
     implementation 'com.adjust.sdk:adjust-android:4.28.2'
+    implementation 'com.google.firebase:firebase-analytics-ktx:20.1.1'
+    implementation 'com.facebook.android:facebook-core:13.1.0'
 
     api files("../libs/yyxx_support_1.0.2.jar")
     api files("../libs/oaid_sdk_1.0.25.jar")

+ 0 - 5
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/EYuanCommInstaller.kt

@@ -31,11 +31,6 @@ internal class EYuanCommInstaller : ContentProvider() {
         initGaid(application)
         MMKVManager.instance.init(application)
         Host.initHostModel(application)
-        TraceEventManager.instance.initialize(application) { id ->
-            Logger.d("onTraceIdRead: $id")
-            CommSdkDrive.instance.setCommParam("aid", id)
-            MMKVManager.instance.eventKV.encode("adjust_id", id)
-        }
         return true
     }
 

+ 8 - 2
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/entity/SdkEvent.kt

@@ -5,6 +5,12 @@ package cn.yyxx.eyuancomm.comm.entity
  * Created on 2021/07/08
  */
 class SdkEvent {
-    var eventName: String = ""
-    var eventParams: String = ""
+    var eventName = ""
+    var eventParams = ""
+    var standard = false
+    var fbAliasName = ""
+
+    override fun toString(): String {
+        return "SdkEvent(eventName='$eventName', eventParams='$eventParams', standard=$standard, fbAliasName='$fbAliasName')"
+    }
 }

+ 6 - 3
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/entity/SdkRoleInfo.kt

@@ -11,13 +11,16 @@ class SdkRoleInfo {
     var roleName: String = ""
     var roleLevel: String = ""
     var roleCTime: Long = 0
+    var rolePower: Int = 0
+    var roleGold: Int = 0
+    var roleChange: Int = 0
+    var partyId: String = ""
+    var partyName: String = ""
     var serverId: String = ""
     var serverName: String = ""
     var vipLevel: String = ""
-    var balance: String = ""
-    var totalPurchase: Int = 0
 
     override fun toString(): String {
-        return "SdkRoleInfo(userId='$userId', roleId='$roleId', roleName='$roleName', roleLevel='$roleLevel', roleCTime=$roleCTime, serverId='$serverId', serverName='$serverName', vipLevel='$vipLevel', balance='$balance', totalPurchase=$totalPurchase)"
+        return "SdkRoleInfo(userId='$userId', roleId='$roleId', roleName='$roleName', roleLevel='$roleLevel', roleCTime=$roleCTime, rolePower=$rolePower, roleGold=$roleGold, roleChange=$roleChange, partyId='$partyId', partyName='$partyName', serverId='$serverId', serverName='$serverName', vipLevel='$vipLevel')"
     }
 }

+ 17 - 2
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/impl/CommSdkImpl.kt

@@ -18,6 +18,9 @@ import cn.yyxx.eyuancomm.comm.widget.ScaleLoadingDialog
 import cn.yyxx.support.BeanUtils
 import cn.yyxx.support.DensityUtils
 import cn.yyxx.support.JsonUtils
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
 import org.json.JSONObject
 import java.util.concurrent.atomic.AtomicInteger
 import kotlin.Boolean
@@ -73,6 +76,11 @@ internal class CommSdkImpl(context: Context) {
         if (mSdkProxy == null) {
             mSdkProxy = getSdkProxyManager()
         }
+        TraceEventManager.instance.initialize(application) { id ->
+            Logger.d("onTraceIdRead: $id")
+            CommSdkDrive.instance.setCommParam("aid", id)
+            MMKVManager.instance.eventKV.encode("adjust_id", id)
+        }
         SdkProxyManager.call(Function.INIT_APPLICATION, arrayOf(Application::class.java), arrayOf(application))
     }
 
@@ -119,9 +127,9 @@ internal class CommSdkImpl(context: Context) {
             return
         }
 
+        showInitLoadingDialog(activity)
         if (!EYuanCommInstaller.hasReadDeviceId) {
             Logger.e("还未完成deviceId加载,将延迟初始化")
-            showInitLoadingDialog(activity)
             Thread {
                 while (!EYuanCommInstaller.hasReadDeviceId) {
                     try {
@@ -165,7 +173,6 @@ internal class CommSdkImpl(context: Context) {
 
     private fun startInitCommSdk(activity: Activity, callback: ICallback) {
         SdkRequest.instance.initSdk(activity, "") { resultInfo ->
-
             initLoadingDialog?.apply {
                 dismiss()
                 initLoadingDialog = null
@@ -343,6 +350,10 @@ internal class CommSdkImpl(context: Context) {
             return
         }
 
+        SdkRequest.instance.submitRoleData(activity, roleInfo, "createRole") { resultInfo ->
+            Logger.d(resultInfo.toString())
+        }
+
         SdkProxyManager.call(Function.ROLE_CREATE, arrayOf(Activity::class.java, SdkRoleInfo::class.java), arrayOf(activity, roleInfo))
     }
 
@@ -360,6 +371,10 @@ internal class CommSdkImpl(context: Context) {
             return
         }
 
+        SdkRequest.instance.submitRoleData(activity, roleInfo, "enterGame") { resultInfo ->
+            Logger.d(resultInfo.toString())
+        }
+
         SdkProxyManager.call(Function.ROLE_LAUNCHER, arrayOf(Activity::class.java, SdkRoleInfo::class.java), arrayOf(activity, roleInfo))
     }
 

+ 1 - 1
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/Host.kt

@@ -36,7 +36,7 @@ object Host {
     const val BASIC_ROUTE_FORGET_PWD_BY_PHONE = "forgot_pwd_auto"
     const val BASIC_ROUTE_FORGET_PWD_BY_EMAIL = "forgot_pwd_email_auto"
     const val BASIC_ROUTE_MODIFY_PWD = "modify_pwd"
-    const val BASIC_ROUTE_SUBMIT_ROLE_INFO = "game_role_report"
+    const val BASIC_ROUTE_SUBMIT_ROLE_INFO = "report_role_info"
     const val BASIC_ROUTE_UPLOAD_SDK_LOG = "upload_log"
 
     fun originHost(url: String): Boolean {

+ 87 - 14
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/SdkRequest.kt

@@ -1,9 +1,15 @@
 package cn.yyxx.eyuancomm.comm.network
 
 import android.content.Context
+import android.text.TextUtils
 import cn.yyxx.eyuancomm.comm.entity.ResultInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
+import cn.yyxx.eyuancomm.comm.entity.SdkRoleInfo
 import cn.yyxx.eyuancomm.comm.utils.Logger
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
 import org.json.JSONException
 import org.json.JSONObject
 
@@ -21,21 +27,43 @@ class SdkRequest {
 
     fun initSdk(context: Context, extObject: String, callback: (ResultInfo) -> Unit) {
         val jsonObject = JSONObject()
-        jsonObject.put("route_path", Host.BASIC_ROUTE_INIT_SDK)
-        jsonObject.put("channel_init_ext", extObject)
-        VolleyRequest.post(context, jsonObject, callback)
+        kotlin.runCatching {
+            jsonObject.put("route_path", Host.BASIC_ROUTE_INIT_SDK)
+            jsonObject.put("channel_init_ext", extObject)
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "initialize sdk has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
+        }
     }
 
     fun userVerify(context: Context, extObject: String, callback: (ResultInfo) -> Unit) {
         val jsonObject = JSONObject()
-        jsonObject.put("route_path", Host.BASIC_ROUTE_USER_VERIFY)
-        jsonObject.put("channel_ext", extObject)
-        VolleyRequest.post(context, jsonObject, callback)
+        kotlin.runCatching {
+            jsonObject.put("route_path", Host.BASIC_ROUTE_USER_VERIFY)
+            jsonObject.put("channel_ext", extObject)
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "verify user login has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
+        }
     }
 
     fun createOrder(context: Context, extObject: String, chargeInfo: SdkChargeInfo, callback: (ResultInfo) -> Unit) {
         val jsonObject = JSONObject()
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_CREATE_ORDER)
             jsonObject.put("uid", chargeInfo.userId)
             jsonObject.put("role_id", chargeInfo.roleId)
@@ -51,18 +79,63 @@ class SdkRequest {
             jsonObject.put("cp_order_id", chargeInfo.cpOrderId)
             jsonObject.put("cp_ext", chargeInfo.cpExt)
             jsonObject.put("channel_ext", extObject)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "create order has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun notifyOrder(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_NOTIFY_ORDER)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "notify order has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
+        }
+    }
+
+    fun submitRoleData(context: Context, roleInfo: SdkRoleInfo, timing: String, callback: (ResultInfo) -> Unit) {
+        val jsonObject = JSONObject()
+        kotlin.runCatching {
+            jsonObject.put("route_path", Host.BASIC_ROUTE_SUBMIT_ROLE_INFO)
+            jsonObject.put("report_role_type", timing)
+            jsonObject.put("uid", roleInfo.userId)
+            jsonObject.put("role_id", roleInfo.roleId)
+            jsonObject.put("role_name", roleInfo.roleName)
+            jsonObject.put("role_level", roleInfo.roleLevel)
+            jsonObject.put("role_power", roleInfo.rolePower)
+            jsonObject.put("role_gold", roleInfo.roleGold)
+            jsonObject.put("role_change", roleInfo.roleChange)
+            jsonObject.put("role_ctime", roleInfo.roleCTime)
+            jsonObject.put("party_id", roleInfo.partyId)
+            jsonObject.put("party_name", roleInfo.partyName)
+            jsonObject.put("server_id", roleInfo.serverId)
+            jsonObject.put("server_name", roleInfo.serverName)
+            jsonObject.put("vip_level", roleInfo.vipLevel)
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "submit role data has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 }

+ 98 - 34
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/network/VolleyRequest.kt

@@ -17,6 +17,12 @@ import cn.yyxx.support.volley.entity.FileEntity
 import cn.yyxx.support.volley.source.*
 import cn.yyxx.support.volley.source.toolbox.HttpHeaderParser
 import cn.yyxx.support.volley.source.toolbox.JsonObjectRequest
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.launch
 import kotlinx.coroutines.runBlocking
 import org.json.JSONException
 import org.json.JSONObject
@@ -31,52 +37,50 @@ object VolleyRequest {
 
     private const val MAX_TIMEOUT = 10 * 1000
 
-    fun post(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
-            val time = System.currentTimeMillis().toString()
-            val randomKey = time + StrUtils.getRandomString(16)
-            val rawKey = Md5Utils.encodeByMD5(randomKey)
-            val aesKey = Md5Utils.encodeByMD5(rawKey + StrUtils.reverseString(rawKey))
-            val hexP = CommSdkDrive.instance.invokeJob(aesKey.substring(8, 24), jsonObject.toString())
-
-            val tmp = HexUtils.hexString2Bytes(hexP)
-            val p = Base64Utils.encode(tmp)
-
-            Logger.d("请求路由 : ${jsonObject["route_path"]}")
-            Logger.d("请求参数 : $jsonObject")
-            Logger.logHandler("请求路由 : ${jsonObject["route_path"]}\n")
-            Logger.logHandler("请求参数 : $jsonObject\n")
-            val obj = JSONObject()
-            obj.put("p", p)
-            obj.put("ts", rawKey)
-            Logger.d("$obj")
-            Logger.d("host: ${Host.HOST}")
+    fun post2(context: Context, jsonObject: JSONObject): Flow<ResultInfo> {
+        val time = System.currentTimeMillis().toString()
+        val randomKey = time + StrUtils.getRandomString(16)
+        val rawKey = Md5Utils.encodeByMD5(randomKey)
+        val aesKey = Md5Utils.encodeByMD5(rawKey + StrUtils.reverseString(rawKey))
+        val hexP = CommSdkDrive.instance.invokeJob(aesKey.substring(8, 24), jsonObject.toString())
+
+        val tmp = HexUtils.hexString2Bytes(hexP)
+        val p = Base64Utils.encode(tmp)
+
+        Logger.d("请求路由 : ${jsonObject["route_path"]}")
+        Logger.d("请求参数 : $jsonObject")
+        Logger.logHandler("请求路由 : ${jsonObject["route_path"]}\n")
+        Logger.logHandler("请求参数 : $jsonObject\n")
+        val obj = JSONObject()
+        obj.put("p", p)
+        obj.put("ts", rawKey)
+        Logger.d("$obj")
+        Logger.d("host: ${Host.HOST}")
 
+        return callbackFlow {
             val request = object : JsonObjectRequest(Method.POST, Host.HOST, obj, Response.Listener {
                 val resultInfo = ResultInfo()
                 resultInfo.code = -1
                 resultInfo.msg = "接口请求异常"
                 it?.apply {
-                    try {
-                        resultInfo.code = it.getInt("code")
-                        resultInfo.msg = it.getString("msg")
-                        resultInfo.data = if (JsonUtils.hasJsonKey(it, "data")) {
-                            it.getJSONObject("data").parseResponse()
-                        } else {
-                            "{}"
-                        }
-                    } catch (e: JSONException) {
-                        e.printStackTrace()
+                    resultInfo.code = it.getInt("code")
+                    resultInfo.msg = it.getString("msg")
+                    resultInfo.data = if (JsonUtils.hasJsonKey(it, "data")) {
+                        it.getJSONObject("data").parseResponse()
+                    } else {
+                        "{}"
                     }
                 }
                 it.put("data", JSONObject(resultInfo.data))
                 Logger.d("返回信息 : $it")
                 Logger.logHandler("返回信息 : $it\n")
-                callback(resultInfo)
+//                callback(resultInfo)
+                trySend(resultInfo)
             }, Response.ErrorListener {
                 it?.apply {
                     Logger.e("postByVolley onErrorResponse : $it")
-                    callback(getErrorResultInfo(context))
+                    trySend(getErrorResultInfo(context))
+//                    callback(getErrorResultInfo(context))
                 }
             }) {
                 override fun getHeaders(): MutableMap<String, String> {
@@ -89,9 +93,69 @@ object VolleyRequest {
             //设置超时时间
             request.retryPolicy = DefaultRetryPolicy(MAX_TIMEOUT, 1, 1.0f)
             VolleySingleton.getInstance(context.applicationContext).addToRequestQueue(context.applicationContext, request)
-        } catch (e: Exception) {
-            e.printStackTrace()
+            awaitClose()
+        }
+
+    }
+
+    @Throws
+    fun post(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
+        val time = System.currentTimeMillis().toString()
+        val randomKey = time + StrUtils.getRandomString(16)
+        val rawKey = Md5Utils.encodeByMD5(randomKey)
+        val aesKey = Md5Utils.encodeByMD5(rawKey + StrUtils.reverseString(rawKey))
+        val hexP = CommSdkDrive.instance.invokeJob(aesKey.substring(8, 24), jsonObject.toString())
+
+        val tmp = HexUtils.hexString2Bytes(hexP)
+        val p = Base64Utils.encode(tmp)
+
+        Logger.d("请求路由 : ${jsonObject["route_path"]}")
+        Logger.d("请求参数 : $jsonObject")
+        Logger.logHandler("请求路由 : ${jsonObject["route_path"]}\n")
+        Logger.logHandler("请求参数 : $jsonObject\n")
+        val obj = JSONObject()
+        obj.put("p", p)
+        obj.put("ts", rawKey)
+        Logger.d("$obj")
+        Logger.d("host: ${Host.HOST}")
+
+        val request = object : JsonObjectRequest(Method.POST, Host.HOST, obj, Response.Listener {
+            val resultInfo = ResultInfo()
+            resultInfo.code = -1
+            resultInfo.msg = "接口请求异常"
+            it?.apply {
+                try {
+                    resultInfo.code = it.getInt("code")
+                    resultInfo.msg = it.getString("msg")
+                    resultInfo.data = if (JsonUtils.hasJsonKey(it, "data")) {
+                        it.getJSONObject("data").parseResponse()
+                    } else {
+                        "{}"
+                    }
+                } catch (e: JSONException) {
+                    e.printStackTrace()
+                }
+            }
+            it.put("data", JSONObject(resultInfo.data))
+            Logger.d("返回信息 : $it")
+            Logger.logHandler("返回信息 : $it\n")
+            callback(resultInfo)
+        }, Response.ErrorListener {
+            it?.apply {
+                Logger.e("postByVolley onErrorResponse : $it")
+                callback(getErrorResultInfo(context))
+            }
+        }) {
+            override fun getHeaders(): MutableMap<String, String> {
+                val headers = HashMap<String, String>()
+                headers["Accept"] = "application/json"
+                headers["Content-Type"] = "application/json;charset=UTF-8"
+                return headers
+            }
         }
+        //设置超时时间
+        request.retryPolicy = DefaultRetryPolicy(MAX_TIMEOUT, 1, 1.0f)
+        VolleySingleton.getInstance(context.applicationContext).addToRequestQueue(context.applicationContext, request)
     }
 
     fun downloadImageFile(context: Context, url: String, callback: (Int, String) -> Unit) {

+ 15 - 7
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/TraceEventManager.kt

@@ -6,7 +6,10 @@ import android.content.Context
 import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
 import cn.yyxx.eyuancomm.comm.entity.SdkEvent
 import cn.yyxx.eyuancomm.comm.internal.ITrace
-import cn.yyxx.eyuancomm.comm.trace.channel.AdjustEventTrace
+import cn.yyxx.eyuancomm.comm.trace.channel.AdjustEventImpl
+import cn.yyxx.eyuancomm.comm.trace.channel.FacebookEventImpl
+import cn.yyxx.eyuancomm.comm.trace.channel.FirebaseEventImpl
+import cn.yyxx.eyuancomm.comm.utils.ParamsUtils
 
 /**
  * @author #Suyghur.
@@ -23,12 +26,17 @@ class TraceEventManager private constructor() {
     private val observers: MutableList<ITrace> = mutableListOf()
 
     fun initialize(application: Application, callback: (String) -> Unit) {
-        observers.add(AdjustEventTrace { id ->
-            callback(id)
-        })
-//        observers.add(TraceFirebaseImpl())
-//        observers.add(TraceFacebookImpl())
-
+        if (ParamsUtils.getAdjustTrace(application)) {
+            observers.add(AdjustEventImpl { id ->
+                callback(id)
+            })
+        }
+        if (ParamsUtils.getFirebaseTrace(application)) {
+            observers.add(FirebaseEventImpl())
+        }
+        if (ParamsUtils.getFacebookTrace(application)) {
+            observers.add(FacebookEventImpl())
+        }
         for (ob in observers) {
             ob.onInitialize(application)
         }

+ 1 - 1
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/AdjustEventTrace.kt → library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/AdjustEventImpl.kt

@@ -25,7 +25,7 @@ import java.io.InputStreamReader
  * @author #Suyghur.
  * Created on 2022/03/08
  */
-class AdjustEventTrace(private val onIdRead: (String) -> Unit) : ITrace {
+class AdjustEventImpl(private val onIdRead: (String) -> Unit) : ITrace {
 
     private var isInitSuccess = false
     private var sdkConfig: JSONObject? = null

+ 151 - 0
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/FacebookEventImpl.kt

@@ -0,0 +1,151 @@
+package cn.yyxx.eyuancomm.comm.trace.channel
+
+import android.app.Activity
+import android.app.Application
+import android.content.Context
+import android.os.Bundle
+import android.text.TextUtils
+import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
+import cn.yyxx.eyuancomm.comm.entity.SdkEvent
+import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
+import cn.yyxx.eyuancomm.comm.internal.ITrace
+import cn.yyxx.eyuancomm.comm.utils.Logger
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
+import com.facebook.FacebookSdk
+import com.facebook.LoggingBehavior
+import com.facebook.appevents.AppEventsConstants
+import com.facebook.appevents.AppEventsLogger
+import java.math.BigDecimal
+import java.util.*
+
+/**
+ * @author #Suyghur.
+ * Created on 2021/07/06
+ */
+class FacebookEventImpl : ITrace {
+
+    private lateinit var fbLogger: AppEventsLogger
+    private var isInitSuccess = false
+
+    override fun onInitialize(application: Application) {
+
+        FacebookSdk.setIsDebugEnabled(true)
+        FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS)
+
+        fbLogger = AppEventsLogger.newLogger(application)
+
+        if (MMKVManager.instance.eventKV.decodeBool("facebook_activities")) {
+            isInitSuccess = true
+            return
+        }
+        //open_app
+        Logger.d("facebook log open app success")
+        fbLogger.logEvent("open_app")
+        MMKVManager.instance.eventKV.encode("facebook_activities", true)
+        isInitSuccess = true
+    }
+
+    override fun onLogin(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("facebook log failed , user is null")
+            return
+        }
+
+        fbLogger.logEvent("login_success_account")
+        Logger.d("facebook log account login success")
+    }
+
+    override fun onRegister(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("facebook log failed , user is null")
+            return
+        }
+
+        fbLogger.logEvent(AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION)
+        Logger.d("facebook log sign up success")
+    }
+
+    override fun onCharge(context: Context, chargeInfo: SdkChargeInfo) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("facebook log failed , user is null")
+            return
+        }
+        val params = Bundle()
+        params.putDouble("price", chargeInfo.amount.toDouble() / 100)
+        params.putString("order", chargeInfo.orderId)
+
+        if (!MMKVManager.instance.eventKV.decodeBool("facebook_first_purchase")) {
+            fbLogger.logEvent("first_purchase", params)
+            Logger.d("facebook log first charge success")
+            MMKVManager.instance.eventKV.encode("facebook_first_purchase", true)
+        }
+
+        fbLogger.logPurchase(BigDecimal.valueOf(chargeInfo.amount.toDouble() / 100), Currency.getInstance("USD"), params)
+        Logger.d("facebook log charge success")
+    }
+
+    override fun onCreate(activity: Activity) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+        AppEventsLogger.activateApp(activity.application)
+    }
+
+    override fun onResume(activity: Activity) {
+    }
+
+    override fun onPause(activity: Activity) {
+    }
+
+    override fun onSdkEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+        fbLogger.logEvent(sdkEvent.eventName)
+        Logger.d("facebook log sdk event ${sdkEvent.eventName} success")
+    }
+
+    override fun onExtEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("facebook log failed , component initialize failed")
+            return
+        }
+        if (sdkEvent.standard) {
+            val eventName = when (sdkEvent.fbAliasName) {
+                "fb_mobile_tutorial_completion" -> AppEventsConstants.EVENT_NAME_COMPLETED_TUTORIAL
+                "fb_mobile_level_achieved" -> AppEventsConstants.EVENT_NAME_ACHIEVED_LEVEL
+                "fb_mobile_spent_credits" -> AppEventsConstants.EVENT_NAME_SPENT_CREDITS
+                "fb_mobile_initiated_checkout" -> AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT
+                "fb_mobile_add_to_cart" -> AppEventsConstants.EVENT_NAME_ADDED_TO_CART
+                "fb_mobile_add_to_wishlist" -> AppEventsConstants.EVENT_NAME_ADDED_TO_WISHLIST
+                "fb_mobile_add_payment_info" -> AppEventsConstants.EVENT_NAME_ADDED_PAYMENT_INFO
+                "fb_mobile_achievement_unlocked" -> AppEventsConstants.EVENT_NAME_UNLOCKED_ACHIEVEMENT
+                "fb_mobile_search" -> AppEventsConstants.EVENT_NAME_SEARCHED
+                "fb_mobile_rate" -> AppEventsConstants.EVENT_NAME_RATED
+                else -> ""
+            }
+            fbLogger.logEvent(eventName)
+        } else {
+            fbLogger.logEvent(sdkEvent.eventName)
+        }
+        Logger.d("facebook log ext event ${sdkEvent.eventName} success")
+    }
+}
+

+ 123 - 0
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/trace/channel/FirebaseEventImpl.kt

@@ -0,0 +1,123 @@
+package cn.yyxx.eyuancomm.comm.trace.channel
+
+import android.app.Activity
+import android.app.Application
+import android.content.Context
+import android.text.TextUtils
+import cn.yyxx.eyuancomm.comm.entity.SdkChargeInfo
+import cn.yyxx.eyuancomm.comm.entity.SdkEvent
+import cn.yyxx.eyuancomm.comm.entity.SdkLoginInfo
+import cn.yyxx.eyuancomm.comm.internal.ITrace
+import cn.yyxx.eyuancomm.comm.utils.Logger
+import cn.yyxx.eyuancomm.comm.utils.MMKVManager
+import com.google.firebase.analytics.FirebaseAnalytics
+import com.google.firebase.analytics.ktx.analytics
+import com.google.firebase.analytics.ktx.logEvent
+import com.google.firebase.ktx.Firebase
+
+/**
+ * @author #Suyghur.
+ * Created on 2021/06/17
+ */
+class FirebaseEventImpl : ITrace {
+
+    private var isInitSuccess = false
+
+    override fun onInitialize(application: Application) {
+        if (MMKVManager.instance.eventKV.decodeBool("firebase_activities")) {
+            isInitSuccess = true
+            return
+        }
+        Firebase.analytics.logEvent("open_app", null)
+        Logger.d("firebase log open app success")
+        MMKVManager.instance.eventKV.encode("firebase_activities", true)
+        isInitSuccess = true
+    }
+
+    override fun onLogin(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("firebase log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("firebase log failed , user is null")
+            return
+        }
+
+        Firebase.analytics.logEvent("login_success_account", null)
+        Logger.d("firebase log account login success")
+    }
+
+    override fun onRegister(context: Context) {
+        if (!isInitSuccess) {
+            Logger.e("firebase log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("firebase log failed , user is null")
+            return
+        }
+
+        Firebase.analytics.logEvent("sign_up", null)
+        Logger.d("firebase log sign up success")
+    }
+
+    override fun onCharge(context: Context, chargeInfo: SdkChargeInfo) {
+        if (!isInitSuccess) {
+            Logger.e("firebase log failed , component initialize failed")
+            return
+        }
+
+        if (TextUtils.isEmpty(SdkLoginInfo.instance.userId)) {
+            Logger.e("firebase log failed , user is null")
+            return
+        }
+
+        if (!MMKVManager.instance.eventKV.decodeBool("firebase_first_purchase")) {
+            Firebase.analytics.logEvent("first_purchase") {
+                param(FirebaseAnalytics.Param.PRICE, (chargeInfo.amount.toDouble() / 100).toString())
+                param("order_id", chargeInfo.orderId)
+            }
+            Logger.d("firebase log first charge success")
+            MMKVManager.instance.eventKV.encode("firebase_first_purchase", true)
+        }
+
+        Firebase.analytics.logEvent("ecommerce_purchase") {
+            param(FirebaseAnalytics.Param.PRICE, (chargeInfo.amount.toDouble() / 100).toString())
+            param("order_id", chargeInfo.orderId)
+        }
+        Logger.d("firebase log charge success")
+
+    }
+
+    override fun onCreate(activity: Activity) {
+    }
+
+    override fun onResume(activity: Activity) {
+    }
+
+    override fun onPause(activity: Activity) {
+    }
+
+
+    override fun onSdkEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("firebase log failed , component initialize failed")
+            return
+        }
+        Firebase.analytics.logEvent(sdkEvent.eventName, null)
+        Logger.d("firebase log sdk event ${sdkEvent.eventName} success")
+    }
+
+    override fun onExtEvent(context: Context, sdkEvent: SdkEvent) {
+        if (!isInitSuccess) {
+            Logger.e("firebase log failed , component initialize failed")
+            return
+        }
+        Firebase.analytics.logEvent(sdkEvent.eventName, null)
+        Logger.d("firebase log ext event ${sdkEvent.eventName} success")
+    }
+
+}

+ 41 - 1
library_comm/src/main/kotlin/cn/yyxx/eyuancomm/comm/utils/ParamsUtils.kt

@@ -15,8 +15,12 @@ object ParamsUtils {
     private const val YYXX_GCP_CODE = "YYXX_GCP_CODE"
     private const val YYXX_GAME_CODE = "YYXX_GAME_CODE"
     private const val YYXX_CHANNEL_ID = "YYXX_CHANNEL_ID"
-    private const val YYXX_ADJSUT_APP_ID = "YYXX_ADJUST_APP_ID"
     private const val YYXX_DO_MAIN_ENV = "YYXX_DO_MAIN_ENV"
+    private const val YYXX_ADJSUT_APP_ID = "YYXX_ADJUST_APP_ID"
+    private const val YYXX_ADJUST_TRACE = "YYXX_ADJUST_TRACE"
+    private const val YYXX_FIREBASE_TRACE = "YYXX_FIREBASE_TRACE"
+    private const val YYXX_FACEBOOK_TRACE = "YYXX_FACEBOOK_TRACE"
+
 
     @JvmStatic
     fun getGcpCode(context: Context): String {
@@ -70,6 +74,42 @@ object ParamsUtils {
         return ""
     }
 
+    fun getAdjustTrace(context: Context): Boolean {
+        try {
+            val enable = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_ADJUST_TRACE)
+            if (!TextUtils.isEmpty(enable)) {
+                return enable.toBoolean()
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+        return false
+    }
+
+    fun getFirebaseTrace(context: Context): Boolean {
+        try {
+            val enable = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_FIREBASE_TRACE)
+            if (!TextUtils.isEmpty(enable)) {
+                return enable.toBoolean()
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+        return false
+    }
+
+    fun getFacebookTrace(context: Context): Boolean {
+        try {
+            val enable = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_FACEBOOK_TRACE)
+            if (!TextUtils.isEmpty(enable)) {
+                return enable.toBoolean()
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+        return false
+    }
+
     @JvmStatic
     fun getDoMainEnv(context: Context): Int {
         try {

+ 9 - 9
library_impl/src/main/java/cn/yyxx/eyuancomm/impl/ImplSdkProxy.kt

@@ -53,15 +53,15 @@ class ImplSdkProxy(channelId: String) {
         mImpl?.charge(activity, chargeInfo, callback)
     }
 
-    fun notifyOrder(activity: Activity, chargeInfo: SdkChargeInfo, callback: ICallback) {
-        if (mImpl is IOrder) {
-            (mImpl as IOrder).notifyOrder(activity, chargeInfo) { code, result ->
-                callback.onResult(code, result)
-            }
-        } else {
-            callback.onResult(-1, "获取订单扩展参数异常")
-        }
-    }
+//    fun notifyOrder(activity: Activity, chargeInfo: SdkChargeInfo, callback: ICallback) {
+//        if (mImpl is IOrder) {
+//            (mImpl as IOrder).notifyOrder(activity, chargeInfo) { code, result ->
+//                callback.onResult(code, result)
+//            }
+//        } else {
+//            callback.onResult(-1, "获取订单扩展参数异常")
+//        }
+//    }
 
     fun roleCreate(activity: Activity, roleInfo: SdkRoleInfo) {
         if (mImpl is IRoleData) {

BIN
libs/apklink.jar


BIN
libs/eyuancommsdk-comm-1.0.0.jar


+ 112 - 61
module_eyuan/library_eyuan/src/main/kotlin/cn/yyxx/eyuancomm/core/network/SdkRequest.kt

@@ -15,6 +15,7 @@ import cn.yyxx.support.encryption.Md5Utils
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
 import org.json.JSONException
 import org.json.JSONObject
 import java.io.File
@@ -33,119 +34,169 @@ class SdkRequest {
     }
 
     fun userLogin(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             if (jsonObject.getInt("login_type") == LoginType.TYPE_ACCOUNT_LOGIN) {
                 jsonObject.put("route_path", Host.BASIC_ROUTE_LOGIN)
             } else {
                 jsonObject.put("route_path", Host.BASIC_ROUTE_THIRD_PART_LOGIN)
             }
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "user login has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun userRegister(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_REGISTER)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "user register has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
 
     fun bindAccount(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_BIND_ACCOUNT)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "bind account has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
+
     }
 
     fun bindPhone(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_BIND_PHONE)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "bind phone has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun bindEmail(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_BIND_EMAIL)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "bind email has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun getPhoneCaptcha(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_GET_PHONE_CAPTCHA)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "get phone captcha has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun getEmailCaptcha(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_GET_EMAIL_CAPTCHA)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "get email captcha has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun forgetUserPwdByPhone(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_FORGET_PWD_BY_PHONE)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "forget pwd by phone has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun forgetUserPwdByEmail(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_FORGET_PWD_BY_EMAIL)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "forget pwd by email has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun modifyUserPwd(context: Context, jsonObject: JSONObject, callback: (ResultInfo) -> Unit) {
-        try {
+        kotlin.runCatching {
             jsonObject.put("route_path", Host.BASIC_ROUTE_MODIFY_PWD)
-        } catch (e: JSONException) {
-            e.printStackTrace()
-        }
-        VolleyRequest.post(context, jsonObject, callback)
-    }
-
-    fun submitRoleData(context: Context, timing: Int, roleInfo: SdkRoleInfo, callback: (ResultInfo) -> Unit) {
-        val jsonObject = JSONObject()
-        try {
-            jsonObject.put("route_path", Host.BASIC_ROUTE_SUBMIT_ROLE_INFO)
-            jsonObject.put("report_type", timing)
-            jsonObject.put("uid", roleInfo.userId)
-            jsonObject.put("role_id", roleInfo.roleId)
-            jsonObject.put("role_name", roleInfo.roleName)
-            jsonObject.put("role_level", roleInfo.roleLevel)
-            jsonObject.put("role_ctime", roleInfo.roleCTime)
-            jsonObject.put("server_id", roleInfo.serverId)
-            jsonObject.put("server_name", roleInfo.serverName)
-            jsonObject.put("vip_level", roleInfo.vipLevel)
-            jsonObject.put("balance", roleInfo.balance)
-            jsonObject.put("total_purchase", roleInfo.totalPurchase)
-        } catch (e: JSONException) {
-            e.printStackTrace()
+        }.onFailure {
+            it.printStackTrace()
+            val msg = if (TextUtils.isEmpty(it.message)) {
+                "modify pwd has some error"
+            } else {
+                it.message!!
+            }
+            callback(ResultInfo(-1, msg))
+        }.onSuccess {
+            VolleyRequest.post(context, jsonObject, callback)
         }
-        VolleyRequest.post(context, jsonObject, callback)
     }
 
     fun downloadImageFile(context: Context, url: String) {

+ 1 - 0
settings.gradle

@@ -3,6 +3,7 @@ include ':demo'
 //include ':library_base'
 include ':library_comm'
 include ':library_impl'
+//include ':library_analytics'
 
 // 渠道库
 include ':channel_registry:channel_oppo'