Merge "Making it possible to determine which TTS engine is currently set as the default by the user."

This commit is contained in:
Charles Chen
2010-03-26 09:24:49 -07:00
committed by Android (Google) Code Review
3 changed files with 51 additions and 1 deletions

View File

@@ -61,5 +61,7 @@ interface ITts {
int playSilence(in String callingApp, in long duration, in int queueMode, in String[] params);
int setEngineByPackageName(in String enginePackageName);
int setEngineByPackageName(in String enginePackageName);
String getDefaultEngine();
}

View File

@@ -1340,4 +1340,43 @@ public class TextToSpeech {
}
}
/**
* Gets the packagename of the default speech synthesis engine.
*
* @return Packagename of the TTS engine that the user has chosen as their default.
*
* @hide
*/
public String getDefaultEngine() {
synchronized (mStartLock) {
String engineName = "";
if (!mStarted) {
return engineName;
}
try {
engineName = mITts.getDefaultEngine();
} catch (RemoteException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "RemoteException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (NullPointerException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "NullPointerException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (IllegalStateException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - setEngineByPackageName", "IllegalStateException");
e.printStackTrace();
mStarted = false;
initTts();
} finally {
return engineName;
}
}
}
}

View File

@@ -1436,6 +1436,15 @@ public class TtsService extends Service implements OnCompletionListener {
return mSelf.setEngine(packageName);
}
/**
* Returns the packagename of the default speech synthesis engine.
*
* @return Packagename of the TTS engine that the user has chosen as their default.
*/
public String getDefaultEngine() {
return mSelf.getDefaultEngine();
}
};
}