diff options
| author | 2021-02-05 23:24:32 +0000 | |
|---|---|---|
| committer | 2021-02-05 23:24:32 +0000 | |
| commit | b2d60a685f5deacbb239df34169eb2eb7bf54d1e (patch) | |
| tree | 9a14ae8de170281e3503d873294ced6629e88c21 | |
| parent | e22b827b05665e755ba5bdc3cae867d8faa25aab (diff) | |
| parent | fd652d522cfc16e3e3768c400794cea10b2a9fb8 (diff) | |
Merge "Get the HotwordDetectionService from the xml metadata" into sc-dev
5 files changed, 27 insertions, 3 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 053f6cb4b05b..3111b7c00630 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -290,6 +290,7 @@ package android { public static final class R.attr { field public static final int allowClearUserDataOnFailedRestore = 16844288; // 0x1010600 + field public static final int hotwordDetectionService = 16844326; // 0x1010626 field public static final int isVrOnly = 16844152; // 0x1010578 field public static final int minExtensionVersion = 16844305; // 0x1010611 field public static final int requiredSystemPropertyName = 16844133; // 0x1010565 diff --git a/core/java/android/service/voice/VoiceInteractionServiceInfo.java b/core/java/android/service/voice/VoiceInteractionServiceInfo.java index f7710e6a82ce..ff03cc14e73b 100644 --- a/core/java/android/service/voice/VoiceInteractionServiceInfo.java +++ b/core/java/android/service/voice/VoiceInteractionServiceInfo.java @@ -18,6 +18,7 @@ package android.service.voice; import android.Manifest; import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.AppGlobals; import android.content.ComponentName; import android.content.pm.PackageManager; @@ -44,6 +45,7 @@ public class VoiceInteractionServiceInfo { private ServiceInfo mServiceInfo; private String mSessionService; private String mRecognitionService; + private String mHotwordDetectionService; private String mSettingsActivity; private boolean mSupportsAssist; private boolean mSupportsLaunchFromKeyguard; @@ -133,6 +135,8 @@ public class VoiceInteractionServiceInfo { false); mSupportsLocalInteraction = array.getBoolean(com.android.internal. R.styleable.VoiceInteractionService_supportsLocalInteraction, false); + mHotwordDetectionService = array.getString(com.android.internal.R.styleable + .VoiceInteractionService_hotwordDetectionService); array.recycle(); if (mSessionService == null) { mParseError = "No sessionService specified"; @@ -181,4 +185,9 @@ public class VoiceInteractionServiceInfo { public boolean getSupportsLocalInteraction() { return mSupportsLocalInteraction; } + + @Nullable + public String getHotwordDetectionService() { + return mHotwordDetectionService; + } } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index eb867090f8ba..14df77527a08 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -8500,6 +8500,9 @@ interaction requests from an Activity. This flag is new in {@link android.os.Build.VERSION_CODES#N} and not used in previous versions. --> <attr name="supportsLocalInteraction" format="boolean" /> + <!-- The service that provides {@link android.service.voice.HotwordDetectionService}. + @hide @SystemApi --> + <attr name="hotwordDetectionService" format="string" /> </declare-styleable> <!-- Use <code>voice-enrollment-application</code> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a7e8f2adab9c..30cfb8986035 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3059,6 +3059,8 @@ <public name="hand_second" /> <public name="memtagMode" /> <public name="nativeHeapZeroInit" /> + <!-- @hide @SystemApi --> + <public name="hotwordDetectionService" /> </public-group> <public-group type="drawable" first-id="0x010800b5"> diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index 9e8f8eaa855c..04dea3f7a2c6 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -163,8 +163,13 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne mValid = true; mSessionComponentName = new ComponentName(service.getPackageName(), mInfo.getSessionService()); - // TODO : Need to get the hotword detection service from the xml metadata - mHotwordDetectionComponentName = null; + final String hotwordDetectionServiceName = mInfo.getHotwordDetectionService(); + if (hotwordDetectionServiceName != null) { + mHotwordDetectionComponentName = new ComponentName(service.getPackageName(), + hotwordDetectionServiceName); + } else { + mHotwordDetectionComponentName = null; + } mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); IntentFilter filter = new IntentFilter(); @@ -388,7 +393,11 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne if (DEBUG) { Slog.d(TAG, "setHotwordDetectionConfigLocked"); } - + if (mHotwordDetectionComponentName == null) { + Slog.e(TAG, "Calling setHotwordDetectionConfigLocked, but hotword detection service" + + " name not found"); + return VoiceInteractionService.HOTWORD_CONFIG_FAILURE; + } if (!isIsolatedProcessLocked(mHotwordDetectionComponentName)) { return VoiceInteractionService.HOTWORD_CONFIG_FAILURE; } |