Fix speech CTS test.

Note that the function being modified is pretty flaky, but
there is no requirement that the engine supports a given locale.

This should ideally be fixed by using a mock engine, but that
seems not possible since there is an option to force the engine
to the user default.

Change-Id: Id32277fd63f7f8f301e82e13a6a5bcf54785f389
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
index cb8aa81..799fd8d 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
@@ -58,6 +58,18 @@
      */
     private boolean checkAndSetLanguageAvailable() {
         // checks if at least one language is available in Tts
+        final Locale defaultLocale = Locale.getDefault();
+        // If the language for the default locale is available, then
+        // use that.
+        int defaultAvailability = getTts().isLanguageAvailable(defaultLocale);
+
+        if (defaultAvailability == TextToSpeech.LANG_AVAILABLE ||
+            defaultAvailability == TextToSpeech.LANG_COUNTRY_AVAILABLE ||
+            defaultAvailability == TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE) {
+            getTts().setLanguage(defaultLocale);
+            return true;
+        }
+
         for (Locale locale : Locale.getAvailableLocales()) {
             int availability = getTts().isLanguageAvailable(locale);
             if (availability == TextToSpeech.LANG_AVAILABLE ||