带阿里标识的版本
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
package com.aliyun.ams.httpdns
|
||||
package com.TrustAPP.ams.httpdns
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.annotation.NonNull
|
||||
import com.alibaba.sdk.android.httpdns.HttpDns
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService
|
||||
import com.alibaba.sdk.android.httpdns.InitConfig
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.alibaba.sdk.android.httpdns.log.HttpDnsLog
|
||||
import com.Trust.sdk.android.httpdns.HttpDns
|
||||
import com.Trust.sdk.android.httpdns.HttpDnsService
|
||||
import com.Trust.sdk.android.httpdns.InitConfig
|
||||
import com.Trust.sdk.android.httpdns.RequestIpType
|
||||
import com.Trust.sdk.android.httpdns.log.HttpDnsLog
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
|
||||
class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
class TrustAPPHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
private lateinit var channel: MethodChannel
|
||||
private var appContext: Context? = null
|
||||
|
||||
@@ -36,7 +36,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
appContext = flutterPluginBinding.applicationContext
|
||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "aliyun_httpdns")
|
||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "TrustAPP_httpdns")
|
||||
channel.setMethodCallHandler(this)
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
else -> ""
|
||||
}
|
||||
if (parsedAppId.isBlank()) {
|
||||
Log.i("AliyunHttpDns", "initialize missing appId")
|
||||
Log.i("TrustAPPHttpDns", "initialize missing appId")
|
||||
result.success(false)
|
||||
return
|
||||
}
|
||||
|
||||
val primaryHostArg = (args["primaryServiceHost"] as? String)?.trim()
|
||||
if (primaryHostArg.isNullOrBlank()) {
|
||||
Log.i("AliyunHttpDns", "initialize missing primaryServiceHost")
|
||||
Log.i("TrustAPPHttpDns", "initialize missing primaryServiceHost")
|
||||
result.success(false)
|
||||
return
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
servicePort = if (port != null && port > 0) port else null
|
||||
|
||||
Log.i(
|
||||
"AliyunHttpDns",
|
||||
"TrustAPPHttpDns",
|
||||
"initialize appId=$appId, primaryServiceHost=$primaryServiceHost, backupServiceHost=$backupServiceHost, servicePort=$servicePort"
|
||||
)
|
||||
result.success(true)
|
||||
@@ -194,7 +194,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
.invoke(builder, primaryServiceHost)
|
||||
hostConfigApplied = true
|
||||
} catch (t: Throwable) {
|
||||
Log.w("AliyunHttpDns", "setPrimaryServiceHost failed: ${t.message}")
|
||||
Log.w("TrustAPPHttpDns", "setPrimaryServiceHost failed: ${t.message}")
|
||||
}
|
||||
try {
|
||||
backupServiceHost?.let {
|
||||
@@ -250,7 +250,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
try {
|
||||
desiredIPRankingMap?.let { map ->
|
||||
if (map.isNotEmpty()) {
|
||||
val beanClass = Class.forName("com.alibaba.sdk.android.httpdns.ranking.IPRankingBean")
|
||||
val beanClass = Class.forName("com.Trust.sdk.android.httpdns.ranking.IPRankingBean")
|
||||
val ctor = beanClass.getConstructor(String::class.java, Int::class.javaPrimitiveType)
|
||||
val list = ArrayList<Any>()
|
||||
map.forEach { (host, port) ->
|
||||
@@ -264,7 +264,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
}
|
||||
|
||||
if (!hostConfigApplied) {
|
||||
Log.w("AliyunHttpDns", "build failed: sdk core does not support primaryServiceHost")
|
||||
Log.w("TrustAPPHttpDns", "build failed: sdk core does not support primaryServiceHost")
|
||||
result.success(false)
|
||||
return
|
||||
}
|
||||
@@ -279,7 +279,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
|
||||
|
||||
result.success(true)
|
||||
} catch (t: Throwable) {
|
||||
Log.w("AliyunHttpDns", "build failed: ${t.message}")
|
||||
Log.w("TrustAPPHttpDns", "build failed: ${t.message}")
|
||||
result.success(false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user