speech: Null-check service connection before usage

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
This commit is contained in:
Aleksandar Kiridzic
2023-05-18 16:44:24 +01:00
parent 862d7365c9
commit dfac66be91

View File

@@ -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;
}