解决语音sdk注销时的异常

This commit is contained in:
wangcongtao
2020-12-01 15:15:13 +08:00
parent b2c2c0ba05
commit 676cd58852
2 changed files with 18 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package com.zhidao.roadcondition.service
import com.mogo.commons.AbsMogoApplication
import com.zhidao.auto.platform.voice.VoiceClient
import java.lang.Exception
/**
* @description 声音控制类
@@ -45,7 +46,11 @@ object VoiceController {
* @param customType 命令
*/
fun unRegisterCustomWakeupCmd(customType: String) {
voiceClient.unRegisterCustomWakeupCmd(customType)
try {
voiceClient.unRegisterCustomWakeupCmd(customType)
} catch (e:Exception){
}
}
/**

View File

@@ -45,7 +45,10 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
Logger.d( TAG, "release" );
if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
for ( String cmd : mCmdMap.keySet() ) {
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
try {
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
} catch ( Exception e ) {
}
}
}
mQAndAMap.clear();
@@ -314,7 +317,10 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
*/
public synchronized void unregisterUnWakeupCommand( String cmd ) {
mCmdMap.remove( cmd );
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
try {
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
} catch ( Exception e ) {
}
mCacheUnWakeupCommands.remove( cmd );
}
@@ -331,7 +337,10 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
}
if ( callBacks.isEmpty() ) {
mCmdMap.remove( cmd );
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
try {
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
} catch ( Exception e ) {
}
mCacheUnWakeupCommands.remove( cmd );
}
}