summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2011-06-16 03:05:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-16 03:05:07 -0700
commitedd12149f050028844ca4449d3da0c16580ae486 (patch)
treeed4955942a9531f7b0825168e5cab430681ea206
parent9266847e6b666c1f43a08fb18a4f8dd78d9ce66c (diff)
parentc3edf2a01a2cf2123a3de17ec1da11a3b6c459f0 (diff)
downloadframeworks_base-edd12149f050028844ca4449d3da0c16580ae486.zip
frameworks_base-edd12149f050028844ca4449d3da0c16580ae486.tar.gz
frameworks_base-edd12149f050028844ca4449d3da0c16580ae486.tar.bz2
Merge "Don't enforce defaults any more in the TextToSpeech API."
-rwxr-xr-xcore/java/android/speech/tts/TextToSpeech.java11
-rw-r--r--core/java/android/speech/tts/TextToSpeechService.java29
-rw-r--r--core/java/android/speech/tts/TtsEngines.java51
3 files changed, 14 insertions, 77 deletions
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 7d596df..40e9355 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -498,8 +498,7 @@ public class TextToSpeech {
private int initTts() {
String defaultEngine = getDefaultEngine();
String engine = defaultEngine;
- if (!areDefaultsEnforced() && !TextUtils.isEmpty(mRequestedEngine)
- && mEnginesHelper.isEngineEnabled(mRequestedEngine)) {
+ if (mEnginesHelper.isEngineInstalled(mRequestedEngine)) {
engine = mRequestedEngine;
}
@@ -1080,12 +1079,12 @@ public class TextToSpeech {
}
/**
- * Checks whether the user's settings should override settings requested by the calling
- * application.
+ * Checks whether the user's settings should override settings requested
+ * by the calling application. As of the Ice cream sandwich release,
+ * user settings never forcibly override the app's settings.
*/
public boolean areDefaultsEnforced() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.TTS_USE_DEFAULTS, Engine.USE_DEFAULTS) == 1;
+ return false;
}
/**
diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java
index 3eea6b7..7ea9373 100644
--- a/core/java/android/speech/tts/TextToSpeechService.java
+++ b/core/java/android/speech/tts/TextToSpeechService.java
@@ -191,11 +191,6 @@ public abstract class TextToSpeechService extends Service {
protected abstract void onSynthesizeText(SynthesisRequest request,
SynthesisCallback callback);
- private boolean areDefaultsEnforced() {
- return getSecureSettingInt(Settings.Secure.TTS_USE_DEFAULTS,
- TextToSpeech.Engine.USE_DEFAULTS) == 1;
- }
-
private int getDefaultSpeechRate() {
return getSecureSettingInt(Settings.Secure.TTS_DEFAULT_RATE, Engine.DEFAULT_RATE);
}
@@ -504,13 +499,9 @@ public abstract class TextToSpeechService extends Service {
}
private void setRequestParams(SynthesisRequest request) {
- if (areDefaultsEnforced()) {
- request.setLanguage(getDefaultLanguage(), getDefaultCountry(), getDefaultVariant());
- request.setSpeechRate(getDefaultSpeechRate());
- } else {
- request.setLanguage(getLanguage(), getCountry(), getVariant());
- request.setSpeechRate(getSpeechRate());
- }
+ request.setLanguage(getLanguage(), getCountry(), getVariant());
+ request.setSpeechRate(getSpeechRate());
+
request.setPitch(getPitch());
}
@@ -749,13 +740,6 @@ public abstract class TextToSpeechService extends Service {
return TextToSpeech.ERROR;
}
- if (areDefaultsEnforced()) {
- if (isDefault(lang, country, variant)) {
- return mDefaultAvailability;
- } else {
- return TextToSpeech.LANG_NOT_SUPPORTED;
- }
- }
return onIsLanguageAvailable(lang, country, variant);
}
@@ -768,13 +752,6 @@ public abstract class TextToSpeechService extends Service {
return TextToSpeech.ERROR;
}
- if (areDefaultsEnforced()) {
- if (isDefault(lang, country, variant)) {
- return mDefaultAvailability;
- } else {
- return TextToSpeech.LANG_NOT_SUPPORTED;
- }
- }
return onLoadLanguage(lang, country, variant);
}
diff --git a/core/java/android/speech/tts/TtsEngines.java b/core/java/android/speech/tts/TtsEngines.java
index 715894f..ed9e048 100644
--- a/core/java/android/speech/tts/TtsEngines.java
+++ b/core/java/android/speech/tts/TtsEngines.java
@@ -117,30 +117,10 @@ public class TtsEngines {
return engines;
}
- /**
- * Checks whether a given engine is enabled or not. Note that all system
- * engines are enabled by default.
- */
+ // TODO: Used only by the settings app. Remove once
+ // the settings UI change has been finalized.
public boolean isEngineEnabled(String engine) {
- // System engines are enabled by default always.
- EngineInfo info = getEngineInfo(engine);
- if (info == null) {
- // The engine is not installed, and therefore cannot
- // be enabled.
- return false;
- }
-
- if (info.system) {
- // All system engines are enabled by default.
- return true;
- }
-
- for (String enabled : getUserEnabledEngines()) {
- if (engine.equals(enabled)) {
- return true;
- }
- }
- return false;
+ return isEngineInstalled(engine);
}
private boolean isSystemEngine(ServiceInfo info) {
@@ -149,22 +129,14 @@ public class TtsEngines {
}
/**
- * @return true if a given engine is installed on the system. Useful to deal
- * with cases where an engine has been uninstalled by the user or removed
- * for any other reason.
+ * @return true if a given engine is installed on the system.
*/
- private boolean isEngineInstalled(String engine) {
+ public boolean isEngineInstalled(String engine) {
if (engine == null) {
return false;
}
- for (EngineInfo info : getEngines()) {
- if (engine.equals(info.name)) {
- return true;
- }
- }
-
- return false;
+ return getEngineInfo(engine) != null;
}
private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
@@ -185,17 +157,6 @@ public class TtsEngines {
return null;
}
- // Note that in addition to this list, all engines that are a part
- // of the system are enabled by default.
- private String[] getUserEnabledEngines() {
- String str = Settings.Secure.getString(mContext.getContentResolver(),
- Settings.Secure.TTS_ENABLED_PLUGINS);
- if (TextUtils.isEmpty(str)) {
- return new String[0];
- }
- return str.split(" ");
- }
-
private static class EngineInfoComparator implements Comparator<EngineInfo> {
private EngineInfoComparator() { }