diff options
author | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2013-05-31 13:12:52 +0100 |
---|---|---|
committer | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2013-06-05 14:44:52 +0000 |
commit | 653278341d76d0b23a008087ff94250ae0beb54b (patch) | |
tree | 802faaf535e8b34ab3c6dfd95a151f58524604d5 /core/java/android/speech | |
parent | 5b27decb1d59b3d35194f28e49d98485c0e57427 (diff) | |
download | frameworks_base-653278341d76d0b23a008087ff94250ae0beb54b.zip frameworks_base-653278341d76d0b23a008087ff94250ae0beb54b.tar.gz frameworks_base-653278341d76d0b23a008087ff94250ae0beb54b.tar.bz2 |
Allow TTS service to identify caller.
Added new field (+setter and getter) to SynthesisRequest with
Uid of a calling process. TTS service will be able to discover
packages names associated with caller using
PackageManager.getPackagesForUid.
This will allow to block buggy or poorly designed programs from
an unintentional DDoS attacks against TTS service.
Bug: 8625440
Change-Id: I5ac0ea191f952495c00301f17efdf28205353ae4
Diffstat (limited to 'core/java/android/speech')
-rw-r--r-- | core/java/android/speech/tts/SynthesisRequest.java | 15 | ||||
-rw-r--r-- | core/java/android/speech/tts/TextToSpeechService.java | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/speech/tts/SynthesisRequest.java b/core/java/android/speech/tts/SynthesisRequest.java index 6398d3d..917a109 100644 --- a/core/java/android/speech/tts/SynthesisRequest.java +++ b/core/java/android/speech/tts/SynthesisRequest.java @@ -41,6 +41,7 @@ public final class SynthesisRequest { private String mVariant; private int mSpeechRate; private int mPitch; + private int mCallerUid; public SynthesisRequest(String text, Bundle params) { mText = text; @@ -98,6 +99,13 @@ public final class SynthesisRequest { } /** + * Gets the request caller Uid. + */ + public int getCallerUid() { + return mCallerUid; + } + + /** * Sets the locale for the request. */ void setLanguage(String language, String country, String variant) { @@ -119,4 +127,11 @@ public final class SynthesisRequest { void setPitch(int pitch) { mPitch = pitch; } + + /** + * Sets Caller Uid + */ + void setCallerUid(int uid) { + mCallerUid = uid; + } } diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java index 703dcff..575855c 100644 --- a/core/java/android/speech/tts/TextToSpeechService.java +++ b/core/java/android/speech/tts/TextToSpeechService.java @@ -557,11 +557,13 @@ public abstract class TextToSpeechService extends Service { // guarded by 'this'. private AbstractSynthesisCallback mSynthesisCallback; private final EventLogger mEventLogger; + private final int mCallerUid; public SynthesisSpeechItem(Object callerIdentity, int callerUid, int callerPid, Bundle params, String text) { super(callerIdentity, callerUid, callerPid, params); mText = text; + mCallerUid = callerUid; mSynthesisRequest = new SynthesisRequest(mText, mParams); mDefaultLocale = getSettingsLocale(); setRequestParams(mSynthesisRequest); @@ -611,7 +613,7 @@ public abstract class TextToSpeechService extends Service { private void setRequestParams(SynthesisRequest request) { request.setLanguage(getLanguage(), getCountry(), getVariant()); request.setSpeechRate(getSpeechRate()); - + request.setCallerUid(mCallerUid); request.setPitch(getPitch()); } |