diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SingleTrafficLightView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SingleTrafficLightView.kt index b856ecf35e..12842094df 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SingleTrafficLightView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SingleTrafficLightView.kt @@ -7,6 +7,7 @@ import android.view.View import android.widget.ImageView import android.widget.TextView import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils @@ -49,7 +50,9 @@ class SingleTrafficLightView @JvmOverloads constructor( override fun showWarningTrafficLight(checkLightId: Int,lightSource: Int) { super.showWarningTrafficLight(checkLightId,lightSource) mCurrentLightId = checkLightId - updateTrafficLightIcon(checkLightId,lightSource) + if(!HmiBuildConfig.isShowTrafficLightView){ + updateTrafficLightIcon(checkLightId,lightSource) + } } /** diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml index 042c7ad3ce..444016d9fd 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/fragment_hmi.xml @@ -8,7 +8,7 @@ > linkedList = new LinkedList<>(); + public void release() { CallerLogger.INSTANCE.d(TAG, "release"); ThreadUtils.runOnUiThread(() -> { @@ -73,6 +79,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList } mQAndAMap.clear(); mVoiceClient.release(); + curTtsLevel = -1; if (mEngine != null) { mEngine.destroy(); mEngine = null; @@ -344,12 +351,15 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList if (mSpeakVoiceMap.containsKey(text)) { mSpeakVoiceMap.remove(text); } + curTtsLevel = -1; mEngine.stop(); } } public void stopTts() { if (mEngine != null && mHasAuth) { + // tts过程中调用stop不会有回调事件 + curTtsLevel = -1; mEngine.stop(); } } @@ -367,6 +377,67 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList } } + @MainThread + public void speakTTSVoiceWithLevel(String text, int ttsLevel) { + if (mEngine != null) { + if (ttsLevel == curTtsLevel) { + // 对应p3、p2级别的排队 + if (ttsLevel == 0 || ttsLevel == 1) { + CallerLogger.INSTANCE.d(TAG, "==================="); + CallerLogger.INSTANCE.d(TAG, "插入消息:" + text + ",level为:" + ttsLevel); + insertTts(text, ttsLevel); + return; + } else { + // 打断并合成新的 + stopTts(); + CallerLogger.INSTANCE.d(TAG, "非Level1同级别打断!"); + } + } else { + // 将要TTS的比现在正在TTS的优先级高 + if (ttsLevel > curTtsLevel) { + if (curTtsLevel >= 0) { + // 打断并合成高优先级的 + stopTts(); + } + CallerLogger.INSTANCE.d(TAG, "高优先级打断低级别的!"); + } else { + if (ttsLevel == 0 || ttsLevel == 1) { + CallerLogger.INSTANCE.d(TAG, "==================="); + CallerLogger.INSTANCE.d(TAG, "插入消息:" + text + ",level为:" + ttsLevel); + insertTts(text, ttsLevel); + } + return; + } + } + curTtsLevel = ttsLevel; + // 合成并播放 + CallerLogger.INSTANCE.d(TAG, "tts准备合成:" + text + ",curTtsLevel为:" + curTtsLevel); + mEngine.speak(text, text, mAILocalTTSIntent); + } + } + + // 降序插入Tts(目前Level0、1可排队) + private void insertTts(String text, int level) { + int index = -1; + for (int i = linkedList.size() - 1; i >= 0; i--) { + int nodeLevel = linkedList.get(i).second; + // 只有高优先级才插入到前面,等于的情况下是插到后面 + if (level > nodeLevel) { + index = i; + } + } + if (index >= 0) { + linkedList.add(index, new Pair(text, level)); + } else { + linkedList.addLast(new Pair(text, level)); + } + for (Pair ttsPair: + linkedList) { + CallerLogger.INSTANCE.d(TAG, "tts文本为:" + ttsPair.first + ",level为:" + ttsPair.second); + } + CallerLogger.INSTANCE.d(TAG, "==================="); + } + /** * 语音播报 * @@ -669,6 +740,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList @Override public void onError(String utteranceId, AIError aiError) { CallerLogger.INSTANCE.d(TAG, "检测到错误:" + aiError.toString()); + curTtsLevel = -1; IMogoTTSCallback callBack = PadTTS.this.mSpeakVoiceMap.remove(utteranceId); if (callBack != null) { callBack.onSpeakError(utteranceId, aiError.getError()); @@ -682,7 +754,9 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList @Override public void onCompletion(String utteranceId) { + curTtsLevel = -1; CallerLogger.INSTANCE.d(TAG, "播放完成"); + ttsNext(); IMogoTTSCallback callBack = PadTTS.this.mSpeakVoiceMap.remove(utteranceId); if (callBack != null) { callBack.onSpeakEnd(utteranceId); @@ -711,6 +785,18 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList } } + @MainThread + private void ttsNext() { + if (!linkedList.isEmpty()) { + Pair ttsPair = linkedList.removeFirst(); + CallerLogger.INSTANCE.i(TAG, "排队播放的下一条文本为:" + ttsPair.first + ",级别为:" + ttsPair.second); + curTtsLevel = ttsPair.second; + speakTTSVoice(ttsPair.first); + } else { + CallerLogger.INSTANCE.i(TAG, "队列为空"); + } + } + public static boolean isProcessRunning(Context context, int uid) { if (context == null) { return false;