[3.2.0][Fix]解决首次安装Tts不播报的问题
原因: 先分发数据且没缓存,而后才去监听,没有收到sn相关的事件
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.commons.voice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
@@ -82,11 +83,11 @@ public class AIAssist {
|
||||
* 重新初始化Tts(首次sn获取比较慢,而TTS初始化比较早会拿不到授权)
|
||||
*/
|
||||
public void initTtsAgain(String sn) {
|
||||
CallerLogger.INSTANCE.d(TAG, "网络获取SN后重新初始化Tts!");
|
||||
Log.d(TAG, "网络获取SN后重新初始化Tts!");
|
||||
if (mTTS != null) {
|
||||
mTTS.initTts(sn);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(TAG, "TTS对象创建失败!");
|
||||
Log.d(TAG, "TTS对象创建失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
@@ -134,7 +135,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
|
||||
if (!mHasAuth && sn != null && !sn.isEmpty() && !isAuthing) {
|
||||
initTtsConfig(sn);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(TAG, "不满足Tts初始化条件!" + mHasAuth + "," + sn + "," + isAuthing);
|
||||
Log.d(TAG, "不满足Tts初始化条件!" + mHasAuth + "," + sn + "," + isAuthing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user