diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/StatusManager.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/StatusManager.kt index 7ce7f46979..cde60c8612 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/StatusManager.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/StatusManager.kt @@ -42,51 +42,51 @@ object StatusManager { private const val TAG = "StatusManager" private lateinit var model: StatusModel - private var timer: Job? = null +// private var timer: Job? = null private var hasInit = false private val listeners by lazy { CopyOnWriteArrayList() } private var container: WeakReference? = null - private val listener = object : IMoGoAutopilotStatusListener { - override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { - super.onAutopilotGuardian(guardianInfo) - guardianInfo?.code?.takeIf { - CallerLogger.d("$M_DEVA$TAG", "-- onAutopilotGuardian ---: code: $it") - it.contains("RTK_STATUS", true) || it.contains("CAN", true) || it == "ILCT_RTK_OR_SLAM_CHANGE" - }?.run { - CallerLogger.d("$M_DEVA$TAG", "-- onAutopilotGuardian trigger req ---: code: $this") - req() - } - } - } +// private val listener = object : IMoGoAutopilotStatusListener { +// override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { +// super.onAutopilotGuardian(guardianInfo) +// guardianInfo?.code?.takeIf { +// CallerLogger.d("$M_DEVA$TAG", "-- onAutopilotGuardian ---: code: $it") +// it.contains("RTK_STATUS", true) || it.contains("CAN", true) || it == "ILCT_RTK_OR_SLAM_CHANGE" +// }?.run { +// CallerLogger.d("$M_DEVA$TAG", "-- onAutopilotGuardian trigger req ---: code: $this") +// req() +// } +// } +// } - private val appStateListener = object : IAppStateListener { - - override fun onAppStateChanged(isForeground: Boolean) { - if (isForeground) { - req() - } else { - timer?.cancel() - } - } - } +// private val appStateListener = object : IAppStateListener { +// +// override fun onAppStateChanged(isForeground: Boolean) { +// if (isForeground) { +// req() +// } else { +// timer?.cancel() +// } +// } +// } private val flows: ArrayList> by lazy { ArrayList() } - private fun req() { - timer?.cancel() - model.viewModelScope.launch(Dispatchers.IO) { - CallerAutoPilotManager.sendStatusQueryReq() - while (true) { - delay(60000) //一分钟主动请求一次 - CallerAutoPilotManager.sendStatusQueryReq() - } - }.also { - timer = it - } - } +// private fun req() { +// timer?.cancel() +// model.viewModelScope.launch(Dispatchers.IO) { +// CallerAutoPilotManager.sendStatusQueryReq() +// while (true) { +// delay(60000) //一分钟主动请求一次 +// CallerAutoPilotManager.sendStatusQueryReq() +// } +// }.also { +// timer = it +// } +// } fun init(ctx: Context) { if (hasInit) { @@ -109,9 +109,9 @@ object StatusManager { private fun onCreate(ctx: Context) { val values = model.status.value?.second ?: throw IllegalStateException("state is not right.") - CallerAutoPilotStatusListenerManager.addListener(TAG, listener) - AppStateManager.registerAppStateListener(appStateListener) - req() +// CallerAutoPilotStatusListenerManager.addListener(TAG, listener) +// AppStateManager.registerAppStateListener(appStateListener) +// req() values.map { when (it) { is CanStatus -> CanImpl(ctx) @@ -166,9 +166,9 @@ object StatusManager { private fun onDestroy(ctx: Context) { hasInit = false - CallerAutoPilotStatusListenerManager.removeListener(TAG) - AppStateManager.unRegisterAppStateListener(appStateListener) - timer?.cancel() +// CallerAutoPilotStatusListenerManager.removeListener(TAG) +// AppStateManager.unRegisterAppStateListener(appStateListener) +// timer?.cancel() flows.forEach { it.onDestroy() }