Merge change 6880 into donut
* changes: Fixing TTS breakage.
This commit is contained in:
@@ -281,14 +281,20 @@ public class TextToSpeech {
|
|||||||
return TTS_SUCCESS;
|
return TTS_SUCCESS;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
}
|
}
|
||||||
@@ -319,14 +325,20 @@ public class TextToSpeech {
|
|||||||
return TTS_SUCCESS;
|
return TTS_SUCCESS;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - addSpeech", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
}
|
}
|
||||||
@@ -361,25 +373,33 @@ public class TextToSpeech {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String extra = params.get(Engine.TTS_KEY_PARAM_STREAM);
|
if ((params != null) && (!params.isEmpty())) {
|
||||||
if (extra != null) {
|
String extra = params.get(Engine.TTS_KEY_PARAM_STREAM);
|
||||||
mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra;
|
if (extra != null) {
|
||||||
}
|
mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra;
|
||||||
extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
|
}
|
||||||
if (extra != null) {
|
extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
|
||||||
mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra;
|
if (extra != null) {
|
||||||
|
mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result = mITts.speak(mPackageName, text, queueMode, mCachedParams);
|
result = mITts.speak(mPackageName, text, queueMode, mCachedParams);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - speak", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - speak", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - speak", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -423,14 +443,20 @@ public class TextToSpeech {
|
|||||||
result = mITts.playEarcon(mPackageName, earcon, queueMode, null);
|
result = mITts.playEarcon(mPackageName, earcon, queueMode, null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playEarcon", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playEarcon", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playEarcon", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -461,14 +487,20 @@ public class TextToSpeech {
|
|||||||
result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams);
|
result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playSilence", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playSilence", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - playSilence", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -492,14 +524,20 @@ public class TextToSpeech {
|
|||||||
return mITts.isSpeaking();
|
return mITts.isSpeaking();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isSpeaking", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isSpeaking", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isSpeaking", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
}
|
}
|
||||||
@@ -523,14 +561,20 @@ public class TextToSpeech {
|
|||||||
result = mITts.stop(mPackageName);
|
result = mITts.stop(mPackageName);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - stop", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - stop", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - stop", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -569,6 +613,20 @@ public class TextToSpeech {
|
|||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setSpeechRate", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setSpeechRate", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setSpeechRate", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -605,6 +663,20 @@ public class TextToSpeech {
|
|||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setPitch", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setPitch", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setPitch", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -642,6 +714,20 @@ public class TextToSpeech {
|
|||||||
mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] );
|
mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] );
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setLanguage", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setLanguage", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - setLanguage", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -670,6 +756,20 @@ public class TextToSpeech {
|
|||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - getLanguage", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - getLanguage", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - getLanguage", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
}
|
}
|
||||||
@@ -697,6 +797,20 @@ public class TextToSpeech {
|
|||||||
loc.getISO3Country(), loc.getVariant());
|
loc.getISO3Country(), loc.getVariant());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isLanguageAvailable", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isLanguageAvailable", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
|
mStarted = false;
|
||||||
|
initTts();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - isLanguageAvailable", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -727,24 +841,32 @@ public class TextToSpeech {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// no need to read the stream type here
|
if ((params != null) && (!params.isEmpty())) {
|
||||||
String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
|
// no need to read the stream type here
|
||||||
if (extra != null) {
|
String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
|
||||||
mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra;
|
if (extra != null) {
|
||||||
|
mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){
|
if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){
|
||||||
result = TTS_SUCCESS;
|
result = TTS_SUCCESS;
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - synthesizeToFile", "RemoteException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - synthesizeToFile", "NullPointerException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// TTS died; restart it.
|
// TTS died; restart it.
|
||||||
|
Log.e("TextToSpeech.java - synthesizeToFile", "IllegalStateException");
|
||||||
|
e.printStackTrace();
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
initTts();
|
initTts();
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class TtsService extends Service implements OnCompletionListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
//Log.i("TTS", "TTS starting");
|
Log.i("TTS", "TTS starting");
|
||||||
|
|
||||||
mResolver = getContentResolver();
|
mResolver = getContentResolver();
|
||||||
|
|
||||||
@@ -326,6 +326,7 @@ public class TtsService extends Service implements OnCompletionListener {
|
|||||||
* engines.
|
* engines.
|
||||||
*/
|
*/
|
||||||
private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) {
|
private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) {
|
||||||
|
Log.i("TTS service received", text);
|
||||||
if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
|
if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
|
||||||
stop(callingApp);
|
stop(callingApp);
|
||||||
}
|
}
|
||||||
@@ -455,14 +456,16 @@ public class TtsService extends Service implements OnCompletionListener {
|
|||||||
String variant = "";
|
String variant = "";
|
||||||
for (int i = 0; i < params.size() - 1; i = i + 2){
|
for (int i = 0; i < params.size() - 1; i = i + 2){
|
||||||
String param = params.get(i);
|
String param = params.get(i);
|
||||||
if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){
|
if (param != null){
|
||||||
setSpeechRate("", Integer.parseInt(params.get(i+1)));
|
if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
|
setSpeechRate("", Integer.parseInt(params.get(i+1)));
|
||||||
language = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
|
language = params.get(i+1);
|
||||||
country = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
|
country = params.get(i+1);
|
||||||
variant = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
|
||||||
|
variant = params.get(i+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (language.length() > 0){
|
if (language.length() > 0){
|
||||||
@@ -510,14 +513,16 @@ public class TtsService extends Service implements OnCompletionListener {
|
|||||||
String variant = "";
|
String variant = "";
|
||||||
for (int i = 0; i < params.size() - 1; i = i + 2){
|
for (int i = 0; i < params.size() - 1; i = i + 2){
|
||||||
String param = params.get(i);
|
String param = params.get(i);
|
||||||
if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){
|
if (param != null){
|
||||||
setSpeechRate("", Integer.parseInt(params.get(i+1)));
|
if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
|
setSpeechRate("", Integer.parseInt(params.get(i+1)));
|
||||||
language = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
|
language = params.get(i+1);
|
||||||
country = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
|
||||||
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
|
country = params.get(i+1);
|
||||||
variant = params.get(i+1);
|
} else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
|
||||||
|
variant = params.get(i+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (language.length() > 0){
|
if (language.length() > 0){
|
||||||
|
|||||||
Reference in New Issue
Block a user