Making it possible to determine which TTS engine is currently set

as the default by the user.

Change-Id: I513c2a9c96091320700c530346f90a9696207923
This commit is contained in:
Charles Chen
2010-03-25 19:59:50 -07:00
parent dd65431637
commit 56ccaa0838
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;
}
}
}
}