From 653278341d76d0b23a008087ff94250ae0beb54b Mon Sep 17 00:00:00 2001 From: Przemyslaw Szczepaniak Date: Fri, 31 May 2013 13:12:52 +0100 Subject: 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 --- core/java/android/speech/tts/SynthesisRequest.java | 15 +++++++++++++++ core/java/android/speech/tts/TextToSpeechService.java | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'core/java/android/speech/tts') 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()); } -- cgit v1.1