Fix a Parcel collection == null exception.

This is caused by the Voice features being set to null. The fix in
Android Marshmallow is to make onGetFeaturesForLanguage return an
empty HashSet object. This does not work for eSpeak because:

  1.  eSpeak was overriding onGetVoices and initializing each Voice's
      features to null;

  2.  the bug is still present on Lollipop.

Thus, the fix here is two-fold:

  1.  make onGetVoices use onGetFeaturesForLanguage;

  2.  make onGetFeaturesForLanguage return an empty HashSet, so that
      eSpeak does not crash on Lollipop either.
This commit is contained in:
Reece H. Dunn
2015-10-11 09:16:21 +01:00
parent 0b86bc71ad
commit c094f4840b
3 changed files with 23 additions and 3 deletions
@@ -26,6 +26,7 @@ import com.reecedunn.espeak.TtsService;
import com.reecedunn.espeak.Voice;
import java.util.Locale;
import java.util.Set;
import static com.reecedunn.espeak.test.TtsMatcher.isTtsLangCode;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -52,6 +53,10 @@ public class TextToSpeechServiceTest extends AndroidTestCase
return super.onLoadLanguage(language, country, variant);
}
public Set<String> onGetFeaturesForLanguage(String language, String country, String variant) {
return super.onGetFeaturesForLanguage(language, country, variant);
}
public Voice getActiveVoice() {
return mMatchingVoice;
}
@@ -242,6 +247,10 @@ public class TextToSpeechServiceTest extends AndroidTestCase
assertThat(locale.getISO3Language(), is(data.javaLanguage));
assertThat(locale.getISO3Country(), is(data.javaCountry));
assertThat(locale.getVariant(), is(data.variant));
Set<String> features = mService.onGetFeaturesForLanguage(data.javaLanguage, data.javaCountry, data.variant);
assertThat(features, is(notNullValue()));
assertThat(features.size(), is(0));
}
}
}