From 21f971c35316e9aa70e04510b3a6404a9cc3e3c5 Mon Sep 17 00:00:00 2001 From: Felix Oghina Date: Wed, 15 Feb 2023 15:32:51 +0000 Subject: Fix NPE in TTS service if no engine string Test: added test in TextToSpeechServiceTest Bug: 232438498 Change-Id: Ia587d34e2898930c0956024c56a1f19debb445e4 --- .../com/android/server/texttospeech/TextToSpeechManagerService.java | 6 ++++++ 1 file changed, 6 insertions(+) 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) { -- cgit v1.2.3-59-g8ed1b