[3.2.0][Fix]解决首次安装Tts不播报的问题

原因:
先分发数据且没缓存,而后才去监听,没有收到sn相关的事件
This commit is contained in:
chenfufeng
2023-05-24 17:02:31 +08:00
parent db7a48302b
commit beacde1fed
4 changed files with 22 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package com.zhjt.mogo_core_function_devatools.tts
import android.content.Context
import android.util.Log
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
@@ -26,7 +27,7 @@ class TtsManager : IMoGoCloudListener {
}
override fun tokenGot(token: String, sn: String) {
CallerLogger.d(TAG, "网络获取到sn为:${sn}准备重新初始化Tts")
Log.d(TAG, "网络获取到sn为:${sn}准备重新初始化Tts")
ThreadUtils.runOnUiThread({
AIAssist.getInstance(AbsMogoApplication.getApp()).initTtsAgain(sn)
}, ThreadUtils.MODE.QUEUE)

View File

@@ -6,10 +6,25 @@ import com.mogo.eagle.core.function.call.base.CallerBase
object CallerCloudListenerManager : CallerBase<IMoGoCloudListener>() {
@Volatile
private var token: String? = null
@Volatile
private var sn: String? = null
override fun doSomeAfterAddListener(tag: String, listener: IMoGoCloudListener) {
super.doSomeAfterAddListener(tag, listener)
if (!token.isNullOrEmpty() && !sn.isNullOrEmpty()) {
listener.tokenGot(token!!, sn!!)
}
}
/**
* 分发获取到的设备sn
*/
fun invokeCloudTokenGot(token: String, sn: String) {
this.token = token
this.sn = sn
M_LISTENERS.forEach {
val listener = it.value
listener.tokenGot(token, sn)