diff options
author | Charles Chen <clchen@google.com> | 2010-03-17 19:19:17 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-03-17 19:19:17 -0700 |
commit | 6c261f327a58ebf1393ef94c9228d11771fe65cc (patch) | |
tree | eac72351e6a267a7e63d5dfa8f1e61504e7eced9 /packages | |
parent | fdd9d1878b7c14671d82cc88c80a528eeda010d9 (diff) | |
parent | dd5b4e2150c8e9f1511ab1b19890d9170407d9a6 (diff) | |
download | frameworks_base-6c261f327a58ebf1393ef94c9228d11771fe65cc.zip frameworks_base-6c261f327a58ebf1393ef94c9228d11771fe65cc.tar.gz frameworks_base-6c261f327a58ebf1393ef94c9228d11771fe65cc.tar.bz2 |
Merge "Added a check to TtsService to make sure that the engine is enabled before using it; if the engine is not enabled, TtsService will fall back to using the default system engine."
Diffstat (limited to 'packages')
-rwxr-xr-x | packages/TtsService/src/android/tts/TtsService.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index 6b7ab3f..2b9e7e1 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -122,7 +122,8 @@ public class TtsService extends Service implements OnCompletionListener { private static final int MAX_FILENAME_LENGTH = 250; // TODO use the TTS stream type when available private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_MUSIC; - + // TODO use TextToSpeech.DEFAULT_SYNTH once it is unhidden + private static final String DEFAULT_SYNTH = "com.svox.pico"; private static final String ACTION = "android.intent.action.START_TTS_SERVICE"; private static final String CATEGORY = "android.intent.category.TTS"; private static final String PKGNAME = "android.tts"; @@ -210,10 +211,29 @@ public class TtsService extends Service implements OnCompletionListener { if (isDefaultEnforced()) { enginePackageName = getDefaultEngine(); } + + // Make sure that the engine has been allowed by the user + if (!enginePackageName.equals(DEFAULT_SYNTH)) { + String[] enabledEngines = android.provider.Settings.Secure.getString(mResolver, + android.provider.Settings.Secure.TTS_ENABLED_PLUGINS).split(" "); + boolean isEnabled = false; + for (int i=0; i<enabledEngines.length; i++) { + if (enabledEngines[i].equals(enginePackageName)) { + isEnabled = true; + break; + } + } + if (!isEnabled) { + // Do not use an engine that the user has not enabled; fall back + // to using the default synthesizer. + enginePackageName = DEFAULT_SYNTH; + } + } + // The SVOX TTS is an exception to how the TTS packaging scheme works // because it is part of the system and not a 3rd party add-on; thus // its binary is actually located under /system/lib/ - if (enginePackageName.equals("com.svox.pico")) { + if (enginePackageName.equals(DEFAULT_SYNTH)) { soFilename = "/system/lib/libttspico.so"; } else { // Find the package |