summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Oghina <hackz@google.com>2023-02-15 15:32:51 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-09-15 21:19:05 +0000
commit17fc586c25143984f6642ea8f25dd2e2d86a5e05 (patch)
tree3e61d657c3073b6647dc0502abadeea224cf5ed3
parent79aabce061b0e661d3d9c1698f216966a97a574d (diff)
downloadbase-17fc586c25143984f6642ea8f25dd2e2d86a5e05.tar.gz
Fix NPE in TTS service if no engine string
Test: added test in TextToSpeechServiceTest Bug: 232438498 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e5364f93d3208a66d599d7256d2e4cfaba989e0e) Merged-In: Ia587d34e2898930c0956024c56a1f19debb445e4 Change-Id: Ia587d34e2898930c0956024c56a1f19debb445e4
-rw-r--r--services/texttospeech/java/com/android/server/texttospeech/TextToSpeechManagerService.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/services/texttospeech/java/com/android/server/texttospeech/TextToSpeechManagerService.java b/services/texttospeech/java/com/android/server/texttospeech/TextToSpeechManagerService.java
index 9015563f439e..24114988d6ba 100644
--- a/services/texttospeech/java/com/android/server/texttospeech/TextToSpeechManagerService.java
+++ b/services/texttospeech/java/com/android/server/texttospeech/TextToSpeechManagerService.java
@@ -63,6 +63,12 @@ public final class TextToSpeechManagerService extends
public void createSession(String engine,
ITextToSpeechSessionCallback sessionCallback) {
synchronized (mLock) {
+ if (engine == null) {
+ runSessionCallbackMethod(
+ () -> sessionCallback.onError("Engine cannot be null"));
+ return;
+ }
+
TextToSpeechManagerPerUserService perUserService = getServiceForUserLocked(
UserHandle.getCallingUserId());
if (perUserService != null) {