Skip to content

Commit a314f32

Browse files
jmtriviAndroid (Google) Code Review
authored andcommitted
Merge "Bug 3365937 notify TTS initialization listener of binding errors" into gingerbread
2 parents c5694eb + 1e13a02 commit a314f32

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

core/java/android/speech/tts/TextToSpeech.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,17 @@ public void onServiceDisconnected(ComponentName name) {
464464

465465
Intent intent = new Intent("android.intent.action.START_TTS_SERVICE");
466466
intent.addCategory("android.intent.category.TTS");
467-
mContext.bindService(intent, mServiceConnection,
468-
Context.BIND_AUTO_CREATE);
469-
// TODO handle case where the binding works (should always work) but
470-
// the plugin fails
467+
boolean bound = mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
468+
if (!bound) {
469+
Log.e("TextToSpeech.java", "initTts() failed to bind to service");
470+
if (mInitListener != null) {
471+
mInitListener.onInit(ERROR);
472+
}
473+
} else {
474+
// initialization listener will be called inside ServiceConnection
475+
Log.i("TextToSpeech.java", "initTts() successfully bound to service");
476+
}
477+
// TODO handle plugin failures
471478
}
472479

473480

@@ -717,8 +724,9 @@ public int speak(String text, int queueMode, HashMap<String,String> params)
717724
{
718725
synchronized (mStartLock) {
719726
int result = ERROR;
720-
Log.i("TTS received: ", text);
727+
Log.i("TextToSpeech.java - speak", "speak text of length " + text.length());
721728
if (!mStarted) {
729+
Log.e("TextToSpeech.java - speak", "service isn't started");
722730
return result;
723731
}
724732
try {
@@ -1226,7 +1234,10 @@ public int synthesizeToFile(String text, HashMap<String,String> params,
12261234
String filename) {
12271235
synchronized (mStartLock) {
12281236
int result = ERROR;
1237+
Log.i("TextToSpeech.java - synthesizeToFile", "synthesizeToFile text of length "
1238+
+ text.length());
12291239
if (!mStarted) {
1240+
Log.e("TextToSpeech.java - synthesizeToFile", "service isn't started");
12301241
return result;
12311242
}
12321243
try {

0 commit comments

Comments
 (0)