[状态栏]优化循迹/算路状态逻辑获取

This commit is contained in:
renwj
2022-09-14 19:28:12 +08:00
parent c22a967e1e
commit 0adf85f61f
3 changed files with 19 additions and 13 deletions

View File

@@ -230,18 +230,13 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
override fun isException(): Boolean = state.isException()
}
fun String.toState(): Tracing? {
val ss = split("|")
var code = ""
if (ss.isNotEmpty()) {
code = ss[0]
}
fun String.toState(msg: String?): Tracing? {
val ss = msg?.split("|")
var extra: Map<String, String>? = null
if (ss.size > 1) {
if (ss != null && ss.isNotEmpty()) {
val sb = StringBuilder()
for (i in 1 until ss.size) {
sb.append(ss[i])
for (element in ss) {
sb.append(element)
sb.append(",")
}
if (sb.isNotEmpty()) {
@@ -249,7 +244,7 @@ fun String.toState(): Tracing? {
}
extra = mutableMapOf("extra" to sb.toString())
}
return when(code) {
return when(this) {
"IMAP_TRA_EXIST" -> TRACK_FINDED.apply {
this.extra = extra
}

View File

@@ -21,7 +21,8 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
override fun onCreate() {
val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
val state = code.toState() ?: UNKNOWN
val msg = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageContent()
val state = code.toState(msg) ?: UNKNOWN
old = state
send(TracingStatus(state))
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
@@ -31,7 +32,7 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo)
val current = guardianInfo?.code
val newState = current?.toState()
val newState = current?.toState(guardianInfo.msg)
if (newState != null && newState != old) {
send(TracingStatus(newState))
old = newState