diff options
author | Fergus Henderson <fergus@google.com> | 2013-05-08 10:47:56 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-08 10:47:56 -0700 |
commit | 6c641d3c67bbd91033254debedff56893d6c53a1 (patch) | |
tree | ad66d85f7f8bf66e19140e8af854d60de747dba2 | |
parent | 1b81da5f955e60e028a8ce7e61eddc3d9ddff030 (diff) | |
parent | 3cf3a0b30cd3d3be806eeb04861731d7ed6e6f23 (diff) | |
download | frameworks_base-6c641d3c67bbd91033254debedff56893d6c53a1.zip frameworks_base-6c641d3c67bbd91033254debedff56893d6c53a1.tar.gz frameworks_base-6c641d3c67bbd91033254debedff56893d6c53a1.tar.bz2 |
am 3cf3a0b3: Merge "Fix for TTS.setLanguage throwing MissingResourceException" into jb-mr2-dev
* commit '3cf3a0b30cd3d3be806eeb04861731d7ed6e6f23':
Fix for TTS.setLanguage throwing MissingResourceException
-rw-r--r-- | core/java/android/speech/tts/TextToSpeech.java | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java index 73d400e..578a86e 100644 --- a/core/java/android/speech/tts/TextToSpeech.java +++ b/core/java/android/speech/tts/TextToSpeech.java @@ -42,6 +42,7 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.MissingResourceException; import java.util.Set; /** @@ -1128,9 +1129,23 @@ public class TextToSpeech { if (loc == null) { return LANG_NOT_SUPPORTED; } - String language = loc.getISO3Language(); - String country = loc.getISO3Country(); + String language = null, country = null; + try { + language = loc.getISO3Language(); + } catch (MissingResourceException e) { + Log.w(TAG, "Couldn't retrieve ISO 639-2/T language code for locale: " + loc, e); + return LANG_NOT_SUPPORTED; + } + + try { + country = loc.getISO3Country(); + } catch (MissingResourceException e) { + Log.w(TAG, "Couldn't retrieve ISO 3166 country code for locale: " + loc, e); + return LANG_NOT_SUPPORTED; + } + String variant = loc.getVariant(); + // Check if the language, country, variant are available, and cache // the available parts. // Note that the language is not actually set here, instead it is cached so it @@ -1195,8 +1210,23 @@ public class TextToSpeech { return runAction(new Action<Integer>() { @Override public Integer run(ITextToSpeechService service) throws RemoteException { - return service.isLanguageAvailable(loc.getISO3Language(), - loc.getISO3Country(), loc.getVariant()); + String language = null, country = null; + + try { + language = loc.getISO3Language(); + } catch (MissingResourceException e) { + Log.w(TAG, "Couldn't retrieve ISO 639-2/T language code for locale: " + loc, e); + return LANG_NOT_SUPPORTED; + } + + try { + country = loc.getISO3Country(); + } catch (MissingResourceException e) { + Log.w(TAG, "Couldn't retrieve ISO 3166 country code for locale: " + loc, e); + return LANG_NOT_SUPPORTED; + } + + return service.isLanguageAvailable(language, country, loc.getVariant()); } }, LANG_NOT_SUPPORTED, "isLanguageAvailable"); } |