summaryrefslogtreecommitdiffstats
path: root/core/java/android/speech/tts
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2011-11-28 17:10:04 +0000
committerNarayan Kamath <narayan@google.com>2011-11-28 17:49:01 +0000
commit68e2af55d65d2e61fbf8096eccaa2e4ca02b6c5a (patch)
tree615e93c009edd0eeb2535c9fddc6a7d878ebebb5 /core/java/android/speech/tts
parente35581ad5ad635f9dcfe4ab6a432c48b46b782cd (diff)
downloadframeworks_base-68e2af55d65d2e61fbf8096eccaa2e4ca02b6c5a.zip
frameworks_base-68e2af55d65d2e61fbf8096eccaa2e4ca02b6c5a.tar.gz
frameworks_base-68e2af55d65d2e61fbf8096eccaa2e4ca02b6c5a.tar.bz2
Fix TTS instantiation from webview accessibility handlers.
The TTS instantiated from here shouldn't clobber any existing TTS objects opened within the same package context. Ideally, the TTS API should work fine with multiple TTS object instances within the same package context but making that happen correctly is a larger change. bug:5659758 Change-Id: Ia1f63c61b9f12ac92ff42a427a004d414e42a759
Diffstat (limited to 'core/java/android/speech/tts')
-rwxr-xr-xcore/java/android/speech/tts/TextToSpeech.java20
-rw-r--r--core/java/android/speech/tts/TextToSpeechService.java6
2 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 38699ea..a220615 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -490,6 +490,7 @@ public class TextToSpeech {
private final Map<String, Uri> mUtterances;
private final Bundle mParams = new Bundle();
private final TtsEngines mEnginesHelper;
+ private final String mPackageName;
private volatile String mCurrentEngine = null;
/**
@@ -518,19 +519,36 @@ public class TextToSpeech {
* @param engine Package name of the TTS engine to use.
*/
public TextToSpeech(Context context, OnInitListener listener, String engine) {
+ this(context, listener, engine, null);
+ }
+
+ /**
+ * Used by the framework to instantiate TextToSpeech objects with a supplied
+ * package name, instead of using {@link android.content.Context#getPackageName()}
+ *
+ * @hide
+ */
+ public TextToSpeech(Context context, OnInitListener listener, String engine,
+ String packageName) {
mContext = context;
mInitListener = listener;
mRequestedEngine = engine;
mEarcons = new HashMap<String, Uri>();
mUtterances = new HashMap<String, Uri>();
+ mUtteranceProgressListener = null;
mEnginesHelper = new TtsEngines(mContext);
+ if (packageName != null) {
+ mPackageName = packageName;
+ } else {
+ mPackageName = mContext.getPackageName();
+ }
initTts();
}
private String getPackageName() {
- return mContext.getPackageName();
+ return mPackageName;
}
private <R> R runActionNoReconnect(Action<R> action, R errorResult, String method) {
diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java
index f82a659..aee678a 100644
--- a/core/java/android/speech/tts/TextToSpeechService.java
+++ b/core/java/android/speech/tts/TextToSpeechService.java
@@ -450,7 +450,7 @@ public abstract class TextToSpeechService extends Service {
@Override
public void dispatchOnDone() {
final String utteranceId = getUtteranceId();
- if (!TextUtils.isEmpty(utteranceId)) {
+ if (utteranceId != null) {
mCallbacks.dispatchOnDone(getCallingApp(), utteranceId);
}
}
@@ -458,7 +458,7 @@ public abstract class TextToSpeechService extends Service {
@Override
public void dispatchOnStart() {
final String utteranceId = getUtteranceId();
- if (!TextUtils.isEmpty(utteranceId)) {
+ if (utteranceId != null) {
mCallbacks.dispatchOnStart(getCallingApp(), utteranceId);
}
}
@@ -466,7 +466,7 @@ public abstract class TextToSpeechService extends Service {
@Override
public void dispatchOnError() {
final String utteranceId = getUtteranceId();
- if (!TextUtils.isEmpty(utteranceId)) {
+ if (utteranceId != null) {
mCallbacks.dispatchOnError(getCallingApp(), utteranceId);
}
}