From a1dddbcf92f8de7973a0f91c0fe5222b101cbe0b Mon Sep 17 00:00:00 2001 From: renwj Date: Thu, 3 Nov 2022 12:10:13 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=8A=B6=E6=80=81=E6=A0=8F]=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E8=AF=B7=E6=B1=82topic=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../status/StatusManager.kt | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) 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() }