From dfac66be91554fc3b32cf72d1f6283b1432a8687 Mon Sep 17 00:00:00 2001 From: Aleksandar Kiridzic Date: Thu, 18 May 2023 16:44:24 +0100 Subject: [PATCH] speech: Null-check service connection before usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In SpeechRecognizer handleStartListening, handleStopMessage and handleCancelMessage, there is a null-check before calling the service’s methods. The same check is now added to handleCheckRecognitionSupport and handleTriggerModelDownload. Bug: 282013412 Test: atest CtsVoiceRecognitionTestCases Change-Id: I506282779e02747f8904cf9cbbdbc3ce135ee2b7 --- core/java/android/speech/SpeechRecognizer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java index dacb25ca16288..bb5dd7f0cdfec 100644 --- a/core/java/android/speech/SpeechRecognizer.java +++ b/core/java/android/speech/SpeechRecognizer.java @@ -812,7 +812,7 @@ public class SpeechRecognizer { Intent recognizerIntent, Executor callbackExecutor, RecognitionSupportCallback recognitionSupportCallback) { - if (!maybeInitializeManagerService()) { + if (!maybeInitializeManagerService() || !checkOpenConnection()) { return; } try { @@ -831,7 +831,7 @@ public class SpeechRecognizer { Intent recognizerIntent, @Nullable Executor callbackExecutor, @Nullable ModelDownloadListener modelDownloadListener) { - if (!maybeInitializeManagerService()) { + if (!maybeInitializeManagerService() || !checkOpenConnection()) { return; }