diff options
author | Charles Chen <clchen@google.com> | 2010-02-18 10:11:25 -0800 |
---|---|---|
committer | Charles Chen <clchen@google.com> | 2010-02-18 10:32:48 -0800 |
commit | d5f013a4fa1366bfa321b1db4818625c0aff48c0 (patch) | |
tree | 37ecdf976d57320790aa2c33d1ff9b9e2af3b3c5 /src/com/android/settings/TextToSpeechSettings.java | |
parent | c8fd872e56c90086df5998aa385e7bece860df00 (diff) | |
download | packages_apps_Settings-d5f013a4fa1366bfa321b1db4818625c0aff48c0.zip packages_apps_Settings-d5f013a4fa1366bfa321b1db4818625c0aff48c0.tar.gz packages_apps_Settings-d5f013a4fa1366bfa321b1db4818625c0aff48c0.tar.bz2 |
Adding checks for null to TextToSpeechSettings to handle cases
where the plugin fails to return properly from CheckVoiceData
and GetSampleString.
Diffstat (limited to 'src/com/android/settings/TextToSpeechSettings.java')
-rw-r--r-- | src/com/android/settings/TextToSpeechSettings.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java index 3c55d10..2182894 100644 --- a/src/com/android/settings/TextToSpeechSettings.java +++ b/src/com/android/settings/TextToSpeechSettings.java @@ -289,12 +289,27 @@ public class TextToSpeechSettings extends PreferenceActivity implements */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == VOICE_DATA_INTEGRITY_CHECK) { + if (data == null){ + // The CHECK_TTS_DATA activity for the plugin did not run properly; + // disable the preview and install controls and return. + mEnableDemo = false; + mVoicesMissing = false; + updateWidgetState(); + return; + } // TODO (clchen): Add these extras to TextToSpeech.Engine ArrayList<String> available = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES"); ArrayList<String> unavailable = data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES"); - + if ((available == null) || (unavailable == null)){ + // The CHECK_TTS_DATA activity for the plugin did not run properly; + // disable the preview and install controls and return. + mEnableDemo = false; + mVoicesMissing = false; + updateWidgetState(); + return; + } if (available.size() > 0){ if (mTts == null) { mTts = new TextToSpeech(this, this); @@ -335,8 +350,18 @@ public class TextToSpeechSettings extends PreferenceActivity implements updateWidgetState(); } else if (requestCode == GET_SAMPLE_TEXT) { if (resultCode == TextToSpeech.LANG_AVAILABLE) { + if (data == null){ + // The GET_SAMPLE_TEXT activity for the plugin did not run properly; + // return without doing anything. + return; + } if (mTts != null) { - String sample = data.getExtras().getString("sampleText"); + String sample = data.getStringExtra("sampleText"); + if (sample == null){ + // The GET_SAMPLE_TEXT activity for the plugin did not run properly; + // return without doing anything. + return; + } mTts.speak(sample, TextToSpeech.QUEUE_FLUSH, null); } } else { |