diff --git a/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java b/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java index ae23b9e46d238..5db4a7b4a6f6e 100644 --- a/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java +++ b/services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java @@ -268,9 +268,17 @@ final class SpeechRecognitionManagerServiceImpl extends } private boolean componentMapsToRecognitionService(@NonNull ComponentName serviceComponent) { - List resolveInfos = - getContext().getPackageManager().queryIntentServicesAsUser( - new Intent(RecognitionService.SERVICE_INTERFACE), 0, getUserId()); + List resolveInfos; + + final long identityToken = Binder.clearCallingIdentity(); + try { + resolveInfos = + getContext().getPackageManager().queryIntentServicesAsUser( + new Intent(RecognitionService.SERVICE_INTERFACE), 0, getUserId()); + } finally { + Binder.restoreCallingIdentity(identityToken); + } + if (resolveInfos == null) { return false; }