[speech] fix settings robo tests

Bug: 300161951
Test: atest SettingsRoboTests:com.android.settings.tts
Change-Id: I31a97eb9dae4fb65c52af3075ad4aa82a7165d49
This commit is contained in:
Felix Oghina
2023-10-11 15:41:10 +00:00
parent b7f8c15ff0
commit 800db77e62
2 changed files with 27 additions and 14 deletions

View File

@@ -165,16 +165,16 @@ public class TtsEnginePreferenceFragment extends RadioButtonPickerFragment {
private void updateDefaultEngine(String engine) {
Log.d(TAG, "Updating default synth to : " + engine);
// Keep track of the previous engine that was being used. So that
// we can reuse the previous engine.
//
// Note that if TextToSpeech#getCurrentEngine is not null, it means at
// the very least that we successfully bound to the engine service.
mPreviousEngine = mTts.getCurrentEngine();
// Step 1: Shut down the existing TTS engine.
Log.i(TAG, "Shutting down current tts engine");
if (mTts != null) {
// Keep track of the previous engine that was being used. So that
// we can reuse the previous engine.
//
// Note that if TextToSpeech#getCurrentEngine is not null, it means at
// the very least that we successfully bound to the engine service.
mPreviousEngine = mTts.getCurrentEngine();
try {
mTts.shutdown();
mTts = null;