From 5e08c38c8954101b98fd8819c3a23aec874d79af Mon Sep 17 00:00:00 2001 From: ryanlwlin Date: Wed, 6 May 2020 20:06:11 +0800 Subject: [PATCH] Fix Voice shortcuts not working system-wide in R SpeechRecognizer binds RecognitionService to realize it's feature. When RecognitionService checks the record_audio permission, itself doesn't have the capabilities to use the permission since it's not a foreground process. We use the addition flag to allow the bounded process to get same capabilities. Bug: 154954447 Test: manual test: 1. Install Talkback with voice shortcut feature 3. assign voice shorct function to any gesture 2. launch any app to leave home and trigger shortcut via the gesture Change-Id: I2f867af739c69a5ba29bb49397819cb61915e42d --- 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 92f3538a48deb..aea94bfb1bbb6 100644 --- a/core/java/android/speech/SpeechRecognizer.java +++ b/core/java/android/speech/SpeechRecognizer.java @@ -283,8 +283,8 @@ public class SpeechRecognizer { } else { serviceIntent.setComponent(mServiceComponent); } - - if (!mContext.bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE)) { + if (!mContext.bindService(serviceIntent, mConnection, + Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES)) { Log.e(TAG, "bind to recognition service failed"); mConnection = null; mService = null;