5656
5757abstract class BaseVoiceCommandManager extends BaseSubManager {
5858 private static final String TAG = "BaseVoiceCommandManager" ;
59- List <VoiceCommand > voiceCommands , currentVoiceCommands , originalVoiceCommands ;
59+ List <VoiceCommand > voiceCommands , currentVoiceCommands ;
6060
6161 int lastVoiceCommandId ;
6262 private static final int voiceCommandIdMin = 1900000000 ;
@@ -132,12 +132,18 @@ private void updateTransactionQueueSuspended() {
132132 public void setVoiceCommands (List <VoiceCommand > voiceCommands ) {
133133
134134 // we actually need voice commands to set.
135- if (voiceCommands == null || voiceCommands . equals ( this . originalVoiceCommands ) ) {
136- DebugTool .logInfo (TAG , "Voice commands list was null or matches the current voice commands " );
135+ if (voiceCommands == null ) {
136+ DebugTool .logInfo (TAG , "Voice commands list was null" );
137137 return ;
138138 }
139139
140- List <VoiceCommand > validatedVoiceCommands = removeEmptyVoiceCommands (voiceCommands );
140+ // Clone voice commands
141+ this .voiceCommands = new ArrayList <>();
142+ for (VoiceCommand voiceCommand : voiceCommands ) {
143+ this .voiceCommands .add (voiceCommand .clone ());
144+ }
145+
146+ List <VoiceCommand > validatedVoiceCommands = removeEmptyVoiceCommands (this .voiceCommands );
141147
142148 if (validatedVoiceCommands .size () == 0 ) {
143149 DebugTool .logError (TAG , "New voice commands are invalid, skipping..." );
@@ -147,10 +153,9 @@ public void setVoiceCommands(List<VoiceCommand> voiceCommands) {
147153 if (!isVoiceCommandsUnique (validatedVoiceCommands )) {
148154 DebugTool .logError (TAG , "Not all voice command strings are unique across all voice commands. Voice commands will not be set." );
149155 return ;
156+
150157 }
151158
152- this .originalVoiceCommands = new ArrayList <>(voiceCommands );
153- this .voiceCommands = validatedVoiceCommands ;
154159 updateIdsOnVoiceCommands (this .voiceCommands );
155160
156161 cleanTransactionQueue ();
0 commit comments