Fix a bug in the TTS settings.

Send the CheckVoiceData intent to the currently
selected engine.

Change-Id: I63d4b7fc935126a0fe7c5717b2455bcf11135b8b
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index f7945d8..d76f08f 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -26,15 +26,12 @@
 import android.app.AlertDialog;
 import android.content.ActivityNotFoundException;
 import android.content.ContentResolver;
-import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceGroup;
 import android.provider.Settings;
 import android.provider.Settings.SettingNotFoundException;
 import android.speech.tts.TextToSpeech;
@@ -695,13 +692,16 @@
         mTts = new TextToSpeech(getActivity().getApplicationContext(), this, engine);
         mEnableDemo = false;
         mVoicesMissing = false;
-        updateWidgetState();
-        checkVoiceData();
 
-        // Finally, persist this value to settings.
+        // Persist this value to settings and update the UI before we check
+        // voice data because if the TTS class connected without any exception, "engine"
+        // will be the default engine irrespective of whether the voice check
+        // passes or not.
         Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
-        // .. and update the UI.
         mDefaultSynthPref.setValue(engine);
+        updateWidgetState();
+
+        checkVoiceData();
 
         Log.v(TAG, "The default synth is now: " + engine);
     }