fix bug of sn null problem which influence the fw log and telemetics cloud connect , plus close the v2x log

This commit is contained in:
zhongchao
2022-07-21 15:05:50 +08:00
parent 3d2202a927
commit 27356390fc
7 changed files with 123 additions and 27 deletions

View File

@@ -0,0 +1,62 @@
package com.mogo.eagle.core.function.call.cloud
import androidx.annotation.Nullable
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
import java.util.concurrent.ConcurrentHashMap
object CallerCloudListenerManager {
private val M_CLOUD_LISTENER: ConcurrentHashMap<String, IMoGoCloudListener> =
ConcurrentHashMap()
/**
* 添加监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun registerCloudListener(
@Nullable tag: String,
@Nullable listener: IMoGoCloudListener
) {
if (M_CLOUD_LISTENER.containsKey(tag)) {
return
}
M_CLOUD_LISTENER[tag] = listener
}
/**
* 删除监听
* @param tag 标记,用来注销监听使用
*/
fun unRegisterCloudListener(@Nullable tag: String) {
if (!M_CLOUD_LISTENER.containsKey(tag)) {
return
}
M_CLOUD_LISTENER.remove(tag)
}
/**
* 删除监听
* @param listener 要删除的监听对象
*/
fun unRegisterCloudListener(@Nullable listener: IMoGoCloudListener) {
if (!M_CLOUD_LISTENER.containsValue(listener)) {
return
}
M_CLOUD_LISTENER.forEach {
if (it.value == listener) {
M_CLOUD_LISTENER.remove(it.key)
}
}
}
/**
* 分发获取到的设备sn
*/
fun invokeCloudTokenGot(sn: String) {
M_CLOUD_LISTENER.forEach {
val listener = it.value
listener.tokenGot(sn)
}
}
}