Enabling plugin engines to pass in their engine specific settings
via a ContentProvider to the TtsService so that the TtsService can
invoke their .so file with those settings.
Change-Id: Icd0e966971c36ebb4da191a50cda96d6f4525df5
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java
index 2a3486f..0d2921e 100755
--- a/packages/TtsService/src/android/tts/TtsService.java
+++ b/packages/TtsService/src/android/tts/TtsService.java
@@ -24,6 +24,7 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.database.Cursor;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
@@ -164,11 +165,6 @@
currentSpeechEngineSOFile = "";
setEngine(getDefaultEngine());
- String soLibPath = "/system/lib/libttspico.so";
- if (sNativeSynth == null) {
- sNativeSynth = new SynthProxy(soLibPath, "");
- }
-
mSelf = this;
mIsSpeaking = false;
mSynthBusy = false;
@@ -269,7 +265,25 @@
sNativeSynth.shutdown();
sNativeSynth = null;
}
- sNativeSynth = new SynthProxy(soFilename, "");
+
+ // Load the engineConfig from the plugin if it has any special configuration
+ // to be loaded. By convention, if an engine wants the TTS framework to pass
+ // in any configuration, it must put it into its content provider which has the URI:
+ // content://<packageName>.providers.SettingsProvider
+ // That content provider must provide a Cursor which returns the String that
+ // is to be passed back to the native .so file for the plugin when getString(0) is
+ // called on it.
+ // Note that the TTS framework does not care what this String data is: it is something
+ // that comes from the engine plugin and is consumed only by the engine plugin itself.
+ String engineConfig = "";
+ Cursor c = getContentResolver().query(Uri.parse("content://" + enginePackageName
+ + ".providers.SettingsProvider"), null, null, null, null);
+ if (c != null){
+ c.moveToFirst();
+ engineConfig = c.getString(0);
+ c.close();
+ }
+ sNativeSynth = new SynthProxy(soFilename, engineConfig);
currentSpeechEngineSOFile = soFilename;
return TextToSpeech.SUCCESS;
}