Merge "Fix for bug 2548048 - it was impossible for applications to discover if their TTS settings were being overridden by the user or not." into froyo

This commit is contained in:
Charles Chen
2010-03-29 18:37:41 -07:00
committed by Android (Google) Code Review
3 changed files with 54 additions and 1 deletions

View File

@@ -63,5 +63,7 @@ interface ITts {
int setEngineByPackageName(in String enginePackageName);
String getDefaultEngine();
String getDefaultEngine();
boolean areDefaultsEnforced();
}

View File

@@ -1379,4 +1379,45 @@ public class TextToSpeech {
}
}
}
/**
* Returns whether or not the user is forcing their defaults to override the
* Text-To-Speech settings set by applications.
*
* @return Whether or not defaults are enforced.
*
* @hide
*/
public boolean areDefaultsEnforced() {
synchronized (mStartLock) {
boolean defaultsEnforced = false;
if (!mStarted) {
return defaultsEnforced;
}
try {
defaultsEnforced = mITts.areDefaultsEnforced();
} catch (RemoteException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - areDefaultsEnforced", "RemoteException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (NullPointerException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - areDefaultsEnforced", "NullPointerException");
e.printStackTrace();
mStarted = false;
initTts();
} catch (IllegalStateException e) {
// TTS died; restart it.
Log.e("TextToSpeech.java - areDefaultsEnforced", "IllegalStateException");
e.printStackTrace();
mStarted = false;
initTts();
} finally {
return defaultsEnforced;
}
}
}
}

View File

@@ -1445,6 +1445,16 @@ public class TtsService extends Service implements OnCompletionListener {
return mSelf.getDefaultEngine();
}
/**
* Returns whether or not the user is forcing their defaults to override the
* Text-To-Speech settings set by applications.
*
* @return Whether or not defaults are enforced.
*/
public boolean areDefaultsEnforced() {
return mSelf.isDefaultEnforced();
}
};
}