add logic of biz pull when get car config mac
This commit is contained in:
@@ -7,9 +7,12 @@ import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_FUNC_CONFIG_CHANGED
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD_SHOW
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsFuncConfigListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.SPUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigConst.Companion.FUNC_CONFIG_TYPE
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigConst.Companion.defaultFuncConfig
|
||||
@@ -18,10 +21,14 @@ import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import com.zhjt.service_biz.BizManager
|
||||
import com.zhjt.service_biz.FuncConfig
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
class FuncConfigCenter : IMogoOnMessageListener<FuncConfig>, IMoGoAutopilotCarConfigListener {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TAG = "FuncConfigCenter"
|
||||
|
||||
val bizConfigCenter by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
FuncConfigCenter()
|
||||
}
|
||||
@@ -34,17 +41,24 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
mContext = context
|
||||
MogoAiCloudSocketManager.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
.registerOnMessageListener(FUNC_CONFIG_TYPE, this)
|
||||
UiThreadHandler.postDelayed({
|
||||
funcConfigNetWorkModel.requestFuncConfig({
|
||||
SPUtils.getInstance("biz_config").put("config", GsonUtils.toJson(it))
|
||||
refreshConfig(it)
|
||||
}, {
|
||||
val bizJson = SPUtils.getInstance("biz_config")
|
||||
.getString("config", GsonUtils.toJson(defaultFuncConfig()))
|
||||
refreshConfig(GsonUtils.fromJson(bizJson, FuncConfig::class.java))
|
||||
})
|
||||
}, 1000L * 5)
|
||||
CallerAutopilotCarConfigListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) {
|
||||
if (!carConfigResp.macAddress.isNullOrEmpty()) {
|
||||
UiThreadHandler.post {
|
||||
funcConfigNetWorkModel.requestFuncConfig({
|
||||
SPUtils.getInstance("biz_config").put("config", GsonUtils.toJson(it))
|
||||
refreshConfig(it)
|
||||
}, {
|
||||
val bizJson = SPUtils.getInstance("biz_config")
|
||||
.getString("config", GsonUtils.toJson(defaultFuncConfig()))
|
||||
refreshConfig(GsonUtils.fromJson(bizJson, FuncConfig::class.java))
|
||||
})
|
||||
}
|
||||
}else{
|
||||
ToastUtils.showLong("未获取到域控mac信息")
|
||||
}
|
||||
}
|
||||
|
||||
override fun target(): Class<FuncConfig> {
|
||||
@@ -78,7 +92,9 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
fun onDestroy() {
|
||||
MogoAiCloudSocketManager.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
.unregisterLifecycleListener(FUNC_CONFIG_TYPE)
|
||||
CallerAutopilotCarConfigListenerManager.removeListener(TAG)
|
||||
mContext = null
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -33,13 +33,12 @@ class FuncConfigNetWorkModel {
|
||||
if (error == null) {
|
||||
error = onError
|
||||
}
|
||||
//todo test
|
||||
// map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
map["sn"] = "X20202203105S688HZ"
|
||||
// map["mac"] = DeviceUtils.getMacAddress()
|
||||
map["mac"] = "48:b0:2d:3a:bc:78"
|
||||
// map["channelVersion"] = FuncConfigConst.getChannelCode()
|
||||
map["channelVersion"] = 1
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
// map["sn"] = "X20202203105S688HZ"
|
||||
map["mac"] = DeviceUtils.getMacAddress()
|
||||
// map["mac"] = "48:b0:2d:3a:bc:78"
|
||||
map["channelVersion"] = FuncConfigConst.getChannelCode()
|
||||
// map["channelVersion"] = 1
|
||||
}
|
||||
loader {
|
||||
apiCall {
|
||||
|
||||
Reference in New Issue
Block a user