Loading core/java/android/speech/tts/TextToSpeech.java +25 −20 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public class TextToSpeech { * * @hide * @deprecated No longer in use, the default engine is determined by * the sort order defined in {@link EngineInfoComparator}. Note that * the sort order defined in {@link TtsEngines}. Note that * this doesn't "break" anything because there is no guarantee that * the engine specified below is installed on a given build, let * alone be the default. Loading Loading @@ -504,36 +504,39 @@ public class TextToSpeech { } private int initTts() { String defaultEngine = getDefaultEngine(); String engine = defaultEngine; if (mEnginesHelper.isEngineInstalled(mRequestedEngine)) { engine = mRequestedEngine; } // Try requested engine if (connectToEngine(engine)) { mCurrentEngine = engine; // Step 1: Try connecting to the engine that was requested. if (mRequestedEngine != null && mEnginesHelper.isEngineInstalled(mRequestedEngine)) { if (connectToEngine(mRequestedEngine)) { mCurrentEngine = mRequestedEngine; return SUCCESS; } } // Fall back to user's default engine if different from the already tested one if (!engine.equals(defaultEngine)) { // Step 2: Try connecting to the user's default engine. final String defaultEngine = getDefaultEngine(); if (defaultEngine != null && !defaultEngine.equals(mRequestedEngine)) { if (connectToEngine(defaultEngine)) { mCurrentEngine = engine; mCurrentEngine = defaultEngine; return SUCCESS; } } // Step 3: Try connecting to the highest ranked engine in the // system. final String highestRanked = mEnginesHelper.getHighestRankedEngineName(); // Fall back to the hardcoded default if different from the two above if (!defaultEngine.equals(highestRanked) && !engine.equals(highestRanked)) { if (highestRanked != null && !highestRanked.equals(mRequestedEngine) && !highestRanked.equals(defaultEngine)) { if (connectToEngine(highestRanked)) { mCurrentEngine = engine; mCurrentEngine = highestRanked; return SUCCESS; } } // NOTE: The API currently does not allow the caller to query whether // they are actually connected to any engine. This might fail for various // reasons like if the user disables all her TTS engines. mCurrentEngine = null; dispatchOnInit(ERROR); return ERROR; } Loading Loading @@ -1073,7 +1076,9 @@ public class TextToSpeech { * * @deprecated This doesn't inform callers when the TTS engine has been * initialized. {@link #TextToSpeech(Context, OnInitListener, String)} * can be used with the appropriate engine name. * can be used with the appropriate engine name. Also, there is no * guarantee that the engine specified will be loaded. If it isn't * installed or disabled, the user / system wide defaults will apply. * * @param enginePackageName The package name for the synthesis engine (e.g. "com.svox.pico") * Loading Loading
core/java/android/speech/tts/TextToSpeech.java +25 −20 Original line number Diff line number Diff line Loading @@ -181,7 +181,7 @@ public class TextToSpeech { * * @hide * @deprecated No longer in use, the default engine is determined by * the sort order defined in {@link EngineInfoComparator}. Note that * the sort order defined in {@link TtsEngines}. Note that * this doesn't "break" anything because there is no guarantee that * the engine specified below is installed on a given build, let * alone be the default. Loading Loading @@ -504,36 +504,39 @@ public class TextToSpeech { } private int initTts() { String defaultEngine = getDefaultEngine(); String engine = defaultEngine; if (mEnginesHelper.isEngineInstalled(mRequestedEngine)) { engine = mRequestedEngine; } // Try requested engine if (connectToEngine(engine)) { mCurrentEngine = engine; // Step 1: Try connecting to the engine that was requested. if (mRequestedEngine != null && mEnginesHelper.isEngineInstalled(mRequestedEngine)) { if (connectToEngine(mRequestedEngine)) { mCurrentEngine = mRequestedEngine; return SUCCESS; } } // Fall back to user's default engine if different from the already tested one if (!engine.equals(defaultEngine)) { // Step 2: Try connecting to the user's default engine. final String defaultEngine = getDefaultEngine(); if (defaultEngine != null && !defaultEngine.equals(mRequestedEngine)) { if (connectToEngine(defaultEngine)) { mCurrentEngine = engine; mCurrentEngine = defaultEngine; return SUCCESS; } } // Step 3: Try connecting to the highest ranked engine in the // system. final String highestRanked = mEnginesHelper.getHighestRankedEngineName(); // Fall back to the hardcoded default if different from the two above if (!defaultEngine.equals(highestRanked) && !engine.equals(highestRanked)) { if (highestRanked != null && !highestRanked.equals(mRequestedEngine) && !highestRanked.equals(defaultEngine)) { if (connectToEngine(highestRanked)) { mCurrentEngine = engine; mCurrentEngine = highestRanked; return SUCCESS; } } // NOTE: The API currently does not allow the caller to query whether // they are actually connected to any engine. This might fail for various // reasons like if the user disables all her TTS engines. mCurrentEngine = null; dispatchOnInit(ERROR); return ERROR; } Loading Loading @@ -1073,7 +1076,9 @@ public class TextToSpeech { * * @deprecated This doesn't inform callers when the TTS engine has been * initialized. {@link #TextToSpeech(Context, OnInitListener, String)} * can be used with the appropriate engine name. * can be used with the appropriate engine name. Also, there is no * guarantee that the engine specified will be loaded. If it isn't * installed or disabled, the user / system wide defaults will apply. * * @param enginePackageName The package name for the synthesis engine (e.g. "com.svox.pico") * Loading