diff options
author | Charles Chen <clchen@google.com> | 2010-03-17 19:15:41 -0700 |
---|---|---|
committer | Charles Chen <clchen@google.com> | 2010-03-17 19:15:41 -0700 |
commit | dd5b4e2150c8e9f1511ab1b19890d9170407d9a6 (patch) | |
tree | 6ae3c5202efb6e38805389b0bb353528eb1f6160 /packages/TtsService | |
parent | a378de742f6da53db442722894c5d68259593ef1 (diff) | |
download | frameworks_base-dd5b4e2150c8e9f1511ab1b19890d9170407d9a6.zip frameworks_base-dd5b4e2150c8e9f1511ab1b19890d9170407d9a6.tar.gz frameworks_base-dd5b4e2150c8e9f1511ab1b19890d9170407d9a6.tar.bz2 |
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.
Change-Id: I401f9c19cc1351c0ae6daf2b11069e5036febc51
Diffstat (limited to 'packages/TtsService')
-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 |