From 8252a0507078ed8bc337bc7b634e6dcd2a8b7a03 Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Mon, 15 Feb 2021 23:22:24 -0800 Subject: [PATCH 1/2] Introduce a default speech recognizer. This is used to populate the new recognizer role and is used by VoiceInteractionManagerService to init the voice_recognition_service setting to a default value. Bug: 175480455 Test: `adb dumpsys role` - check that the default is set Change-Id: If749a9dcd4527929383110f83a136899a7b16bc1 --- core/api/system-current.txt | 1 + core/res/res/values/config.xml | 2 ++ core/res/res/values/public.xml | 2 ++ 3 files changed, 5 insertions(+) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 17783b7ee0d08..f87512d393fcf 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -352,6 +352,7 @@ package android { field public static final int config_systemContacts = 17039403; // 0x104002b field public static final int config_systemGallery = 17039399; // 0x1040027 field public static final int config_systemShell = 17039402; // 0x104002a + field public static final int config_systemSpeechRecognizer = 17039406; // 0x104002e } public static final class R.style { diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 592a3a1ff083f..12cb3980f785c 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1953,6 +1953,8 @@ com.android.shell com.android.contacts + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 9b2573f3d62f8..2004d0a8d15c8 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3166,6 +3166,8 @@ + + From 3a1cef2e92772f89d101dfa0dcefe51d78f7c2e3 Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Mon, 8 Feb 2021 22:41:37 -0800 Subject: [PATCH 2/2] VIMS: Use the new recognizer config resource for init. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When initializing or resetting the recognizer setting, the configured package is preferred over other available recognizers. Bug: 175480455 Test: manual - unset recognizer, reboot, and check the setting Test: atest CtsAssistTestCases CtsVoiceInteractionTestCases \ CtsVoiceSettingsTestCases Change-Id: I2fc225eba56bc787b267262d9917e718035c6047 --- .../VoiceInteractionManagerService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index 8628f89a49c1c..dce63ebb08892 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -76,6 +76,7 @@ import android.util.ArraySet; import android.util.Log; import android.util.Slog; +import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVoiceActionCheckCallback; @@ -643,6 +644,10 @@ public class VoiceInteractionManagerService extends SystemService { } ComponentName findAvailRecognizer(String prefPackage, int userHandle) { + if (prefPackage == null) { + prefPackage = getDefaultRecognizer(); + } + List available = mContext.getPackageManager().queryIntentServicesAsUser( new Intent(RecognitionService.SERVICE_INTERFACE), @@ -670,6 +675,12 @@ public class VoiceInteractionManagerService extends SystemService { } } + @Nullable + public String getDefaultRecognizer() { + String recognizer = mContext.getString(R.string.config_systemSpeechRecognizer); + return TextUtils.isEmpty(recognizer) ? null : recognizer; + } + ComponentName getCurRecognizer(int userHandle) { String curRecognizer = Settings.Secure.getStringForUser( mContext.getContentResolver(),