Merge "Making it possible to determine which TTS engine is currently set as the default by the user."
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user