Bug 1472623 - Don't use tts.getAvailableLanguages on Androids older than M. r=snorp a=lizzard
authorEitan Isaacson <eitan@monotonous.org>
Thu, 05 Jul 2018 15:42:00 +0300
changeset 477865 33216e31fc3a81ea67e7cdde095ea93a58d5ec6b
parent 477864 76f1a92b24ca9b2a06d27da38eaf837dd762cfba
child 477866 ecb1c1bf6f4829779354abfc0ca6e9d8fb1ab637
push id9448
push userarchaeopteryx@coole-files.de
push dateMon, 09 Jul 2018 17:22:41 +0000
treeherdermozilla-beta@32cde6cdb297 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, lizzard
bugs1472623
milestone62.0
Bug 1472623 - Don't use tts.getAvailableLanguages on Androids older than M. r=snorp a=lizzard
mobile/android/geckoview/src/main/java/org/mozilla/gecko/SpeechSynthesisService.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/SpeechSynthesisService.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/SpeechSynthesisService.java
@@ -61,17 +61,19 @@ public class SpeechSynthesisService  {
                     registerVoice("moz-tts:android:" + localeStr, locale.getDisplayName(), localeStr.replace("_", "-"), !isLocal, defaultLocale == locale);
                 }
                 doneRegisteringVoices();
             }
         });
     }
 
     private static Set<Locale> getAvailableLanguages() {
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            // While this method was introduced in 21, it seems that it
+            // has not been implemented in the speech service side until 23.
             return sTTS.getAvailableLanguages();
         }
         Set<Locale> locales = new HashSet<Locale>();
         for (Locale locale : Locale.getAvailableLocales()) {
             if (locale.getVariant().isEmpty() && sTTS.isLanguageAvailable(locale) > 0) {
                 locales.add(locale);
             }
         }