This commit is contained in:
wangcongtao
2020-03-18 20:50:22 +08:00
parent 78f87fbfd6
commit 0f0bd23d11
9 changed files with 43 additions and 11 deletions

View File

@@ -42,6 +42,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
}
public synchronized void release() {
Logger.d( TAG, "release" );
if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
for ( String cmd : mCmdMap.keySet() ) {
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
@@ -235,10 +236,9 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
if ( mHasFlush ) {
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
mCacheUnWakeupCommands.remove( cmd );
} else {
Logger.i( TAG, "cache un wakeup command2. %s", cmd );
mCacheUnWakeupCommands.put( cmd, cmdWords );
}
Logger.i( TAG, "cache un wakeup command2. %s", cmd );
mCacheUnWakeupCommands.put( cmd, cmdWords );
}
/**
@@ -251,10 +251,9 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
if ( mHasFlush ) {
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
mCacheUnWakeupCommands.remove( cmd );
} else {
Logger.i( TAG, "cache un wakeup command. %s", cmd );
mCacheUnWakeupCommands.put( cmd, cmdWords );
}
Logger.i( TAG, "cache un wakeup command. %s", cmd );
mCacheUnWakeupCommands.put( cmd, cmdWords );
}
/**
@@ -287,12 +286,14 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
* @param cmd
*/
public synchronized void unregisterUnWakeupCommand( String cmd, IMogoVoiceCmdCallBack callBack ) {
mCacheUnWakeupCommands.remove( cmd );
if ( mCmdMap.containsKey( cmd ) ) {
List< IMogoVoiceCmdCallBack > callBacks = mCmdMap.get( cmd );
if ( callBacks != null ) {
callBacks.remove( callBack );
}
if ( callBacks.isEmpty() ) {
mCacheUnWakeupCommands.remove( cmd );
}
}
}
@@ -314,7 +315,6 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
for ( String cmd : mCacheUnWakeupCommands.keySet() ) {
registerUnWakeupCommand( cmd, mCacheUnWakeupCommands.get( cmd ) );
}
mCacheUnWakeupCommands.clear();
}
private boolean isVoiceServiceReady( Context context ) {