From 4b945427b9cd0823728c43429209f4ba598cba89 Mon Sep 17 00:00:00 2001 From: Aleksandar Kiridzic Date: Wed, 20 Apr 2022 17:40:02 +0100 Subject: [PATCH] speech: Mask client identity when running the package manager call Allow speech recognizers to list all the recognition services. Bug: 210471821 Test: manual by reproducing the corresponding bug Change-Id: If2dc9b81e26ca531cadd0ca25e207db036df9cdc --- .../SpeechRecognitionManagerServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; }