Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +22 −17 Original line number Diff line number Diff line Loading @@ -227,7 +227,6 @@ public class AlwaysOnHotwordDetector { @Nullable private KeyphraseMetadata mKeyphraseMetadata; private final KeyphraseEnrollmentInfo mKeyphraseEnrollmentInfo; private final IVoiceInteractionService mVoiceInteractionService; private final IVoiceInteractionManagerService mModelManagementService; private final SoundTriggerListener mInternalCallback; private final Callback mExternalCallback; Loading Loading @@ -413,14 +412,11 @@ public class AlwaysOnHotwordDetector { * @param text The keyphrase text to get the detector for. * @param locale The java locale for the detector. * @param callback A non-null Callback for receiving the recognition events. * @param voiceInteractionService The current voice interaction service. * @param modelManagementService A service that allows management of sound models. * * @hide */ public AlwaysOnHotwordDetector(String text, Locale locale, Callback callback, KeyphraseEnrollmentInfo keyphraseEnrollmentInfo, IVoiceInteractionService voiceInteractionService, IVoiceInteractionManagerService modelManagementService) { mText = text; mLocale = locale; Loading @@ -428,7 +424,6 @@ public class AlwaysOnHotwordDetector { mExternalCallback = callback; mHandler = new MyHandler(); mInternalCallback = new SoundTriggerListener(mHandler); mVoiceInteractionService = voiceInteractionService; mModelManagementService = modelManagementService; new RefreshAvailabiltyTask().execute(); } Loading Loading @@ -471,6 +466,8 @@ public class AlwaysOnHotwordDetector { /** * Get the audio capabilities supported by the platform which can be enabled when * starting a recognition. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @see #AUDIO_CAPABILITY_ECHO_CANCELLATION * @see #AUDIO_CAPABILITY_NOISE_SUPPRESSION Loading @@ -488,7 +485,7 @@ public class AlwaysOnHotwordDetector { private int getSupportedAudioCapabilitiesLocked() { try { ModuleProperties properties = mModelManagementService.getDspModuleProperties(mVoiceInteractionService); mModelManagementService.getDspModuleProperties(); if (properties != null) { return properties.audioCapabilities; } Loading @@ -501,6 +498,8 @@ public class AlwaysOnHotwordDetector { /** * Starts recognition for the associated keyphrase. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @see #RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO * @see #RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS Loading Loading @@ -533,6 +532,8 @@ public class AlwaysOnHotwordDetector { /** * Stops recognition for the associated keyphrase. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @return Indicates whether the call succeeded or not. * @throws UnsupportedOperationException if the recognition isn't supported. Loading Loading @@ -565,6 +566,8 @@ public class AlwaysOnHotwordDetector { * stopping recognition. Once the model is unloaded, the value will be lost. * {@link AlwaysOnHotwordDetector#queryParameter} should be checked first before calling this * method. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @param value Value to set Loading Loading @@ -595,6 +598,8 @@ public class AlwaysOnHotwordDetector { * value is returned. See {@link ModelParams} for parameter default values. * {@link AlwaysOnHotwordDetector#queryParameter} should be checked first before * calling this method. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @return value of parameter Loading @@ -617,6 +622,8 @@ public class AlwaysOnHotwordDetector { * Determine if parameter control is supported for the given model handle. * This method should be checked prior to calling {@link AlwaysOnHotwordDetector#setParameter} * or {@link AlwaysOnHotwordDetector#getParameter}. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @return supported range of parameter, null if not supported Loading Loading @@ -775,7 +782,7 @@ public class AlwaysOnHotwordDetector { int code = STATUS_ERROR; try { code = mModelManagementService.startRecognition(mVoiceInteractionService, code = mModelManagementService.startRecognition( mKeyphraseMetadata.id, mLocale.toLanguageTag(), mInternalCallback, new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, recognitionExtra, null /* additional data */, audioCapabilities)); Loading @@ -791,8 +798,8 @@ public class AlwaysOnHotwordDetector { private int stopRecognitionLocked() { int code = STATUS_ERROR; try { code = mModelManagementService.stopRecognition( mVoiceInteractionService, mKeyphraseMetadata.id, mInternalCallback); code = mModelManagementService.stopRecognition(mKeyphraseMetadata.id, mInternalCallback); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in stopRecognition!", e); } Loading @@ -805,8 +812,8 @@ public class AlwaysOnHotwordDetector { private int setParameterLocked(@ModelParams int modelParam, int value) { try { int code = mModelManagementService.setParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam, value); int code = mModelManagementService.setParameter(mKeyphraseMetadata.id, modelParam, value); if (code != STATUS_OK) { Slog.w(TAG, "setParameter failed with error code " + code); Loading @@ -820,8 +827,7 @@ public class AlwaysOnHotwordDetector { private int getParameterLocked(@ModelParams int modelParam) { try { return mModelManagementService.getParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam); return mModelManagementService.getParameter(mKeyphraseMetadata.id, modelParam); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -831,8 +837,7 @@ public class AlwaysOnHotwordDetector { private ModelParamRange queryParameterLocked(@ModelParams int modelParam) { try { SoundTrigger.ModelParamRange modelParamRange = mModelManagementService.queryParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam); mModelManagementService.queryParameter(mKeyphraseMetadata.id, modelParam); if (modelParamRange == null) { return null; Loading Loading @@ -966,7 +971,7 @@ public class AlwaysOnHotwordDetector { ModuleProperties dspModuleProperties = null; try { dspModuleProperties = mModelManagementService.getDspModuleProperties(mVoiceInteractionService); mModelManagementService.getDspModuleProperties(); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in getDspProperties!", e); } Loading @@ -982,7 +987,7 @@ public class AlwaysOnHotwordDetector { private void internalUpdateEnrolledKeyphraseMetadata() { try { mKeyphraseMetadata = mModelManagementService.getEnrolledKeyphraseMetadata( mVoiceInteractionService, mText, mLocale.toLanguageTag()); mText, mLocale.toLanguageTag()); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in internalUpdateEnrolledKeyphraseMetadata", e); } Loading core/java/android/service/voice/VoiceInteractionService.java +3 −3 Original line number Diff line number Diff line Loading @@ -199,7 +199,7 @@ public class VoiceInteractionService extends Service { throw new IllegalStateException("Not available until onReady() is called"); } try { mSystemService.showSession(mInterface, args, flags); mSystemService.showSession(args, flags); } catch (RemoteException e) { } } Loading Loading @@ -302,7 +302,7 @@ public class VoiceInteractionService extends Service { // Allow only one concurrent recognition via the APIs. safelyShutdownHotwordDetector(); mHotwordDetector = new AlwaysOnHotwordDetector(keyphrase, locale, callback, mKeyphraseEnrollmentInfo, mInterface, mSystemService); mKeyphraseEnrollmentInfo, mSystemService); } return mHotwordDetector; } Loading Loading @@ -373,7 +373,7 @@ public class VoiceInteractionService extends Service { } try { mSystemService.setUiHints(mInterface, hints); mSystemService.setUiHints(hints); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +58 −23 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import android.service.voice.IVoiceInteractionService; import android.service.voice.IVoiceInteractionSession; interface IVoiceInteractionManagerService { void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags); void showSession(in Bundle sessionArgs, int flags); boolean deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor); boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags); Loading @@ -52,68 +52,91 @@ interface IVoiceInteractionManagerService { /** * Gets the registered Sound model for keyphrase detection for the current user. * May be null if no matching sound model exists. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ @UnsupportedAppUsage SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); /** * Add/Update the given keyphrase sound model. * Add/Update the given keyphrase sound model for the current user. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param model The keyphrase sound model to store peristantly. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ int updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model); /** * Deletes the given keyphrase sound model for the current user. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ int deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); /** * Gets the properties of the DSP hardware on this device, null if not present. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ SoundTrigger.ModuleProperties getDspModuleProperties(in IVoiceInteractionService service); SoundTrigger.ModuleProperties getDspModuleProperties(); /** * Indicates if there's a keyphrase sound model available for the given keyphrase ID and the * user ID of the caller. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. */ boolean isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId, String bcp47Locale); boolean isEnrolledForKeyphrase(int keyphraseId, String bcp47Locale); /** * Generates KeyphraseMetadata for an enrolled sound model based on keyphrase string, locale, * and the user ID of the caller. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService * @param keyphrase Keyphrase text associated with the enrolled model * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @return The metadata for the enrolled voice model bassed on the passed in parameters. Null if * no matching voice model exists. */ KeyphraseMetadata getEnrolledKeyphraseMetadata(IVoiceInteractionService service, String keyphrase, String bcp47Locale); KeyphraseMetadata getEnrolledKeyphraseMetadata(String keyphrase, String bcp47Locale); /** * Starts a recognition for the given keyphrase. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ int startRecognition(in IVoiceInteractionService service, int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, int startRecognition(int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig recognitionConfig); /** * Stops a recognition for the given keyphrase. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ int stopRecognition(in IVoiceInteractionService service, int keyphraseId, in IRecognitionStatusCallback callback); int stopRecognition(int keyphraseId, in IRecognitionStatusCallback callback); /** * Set a model specific ModelParams with the given value. This * parameter will keep its value for the duration the model is loaded regardless of starting and * stopping recognition. Once the model is unloaded, the value will be lost. * queryParameter should be checked first before calling this method. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @param value Value to set Loading @@ -123,36 +146,37 @@ interface IVoiceInteractionManagerService { * - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence or * if API is not supported by HAL */ int setParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam, int value); int setParameter(int keyphraseId, in ModelParams modelParam, int value); /** * Get a model specific ModelParams. This parameter will keep its value * for the duration the model is loaded regardless of starting and stopping recognition. * Once the model is unloaded, the value will be lost. If the value is not set, a default * value is returned. See ModelParams for parameter default values. * queryParameter should be checked first before calling this method. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @return value of parameter */ int getParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam); int getParameter(int keyphraseId, in ModelParams modelParam); /** * Determine if parameter control is supported for the given model handle. * This method should be checked prior to calling setParameter or getParameter. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @return supported range of parameter, null if not supported */ @nullable SoundTrigger.ModelParamRange queryParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam); @nullable SoundTrigger.ModelParamRange queryParameter(int keyphraseId, in ModelParams modelParam); /** * @return the component name for the currently active voice interaction service * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ ComponentName getActiveServiceComponentName(); Loading @@ -164,59 +188,70 @@ interface IVoiceInteractionManagerService { * @param sourceFlags flags indicating the source of this show * @param showCallback optional callback to be notified when the session was shown * @param activityToken optional token of activity that needs to be on top * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean showSessionForActiveService(in Bundle args, int sourceFlags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken); /** * Hides the session from the active service, if it is showing. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void hideCurrentSession(); /** * Notifies the active service that a launch was requested from the Keyguard. This will only * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void launchVoiceAssistFromKeyguard(); /** * Indicates whether there is a voice session running (but not necessarily showing). * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean isSessionRunning(); /** * Indicates whether the currently active voice interaction service is capable of handling the * assist gesture. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean activeServiceSupportsAssist(); /** * Indicates whether the currently active voice interaction service is capable of being launched * from the lockscreen. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean activeServiceSupportsLaunchFromKeyguard(); /** * Called when the lockscreen got shown. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void onLockscreenShown(); /** * Register a voice interaction listener. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener); /** * Checks the availability of a set of voice actions for the current active voice service. * Returns all supported voice actions. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback); /** * Provide hints for showing UI. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ void setUiHints(in IVoiceInteractionService service, in Bundle hints); void setUiHints(in Bundle hints); /** * Requests a list of supported actions from a specific activity. Loading media/java/android/media/voice/KeyphraseModelManager.java +14 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ import java.util.Objects; * manage voice based sound trigger models. * Callers of this class are expected to have whitelist manifest permission MANAGE_VOICE_KEYPHRASES. * Callers of this class are expected to be the designated voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * {@link Settings.Secure.VOICE_INTERACTION_SERVICE} or a bundled voice model enrollment application * detected by {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * @hide */ @SystemApi Loading Loading @@ -65,6 +66,10 @@ public final class KeyphraseModelManager { * {@link #updateKeyphraseSoundModel}. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param locale The locale language tag supported by the desired model. Loading Loading @@ -93,6 +98,10 @@ public final class KeyphraseModelManager { * will be overwritten with the new model. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param model Keyphrase sound model to be updated. * @throws ServiceSpecificException Thrown with error code if failed to update the keyphrase Loading Loading @@ -120,6 +129,10 @@ public final class KeyphraseModelManager { * {@link #updateKeyphraseSoundModel}. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param locale The locale language tag supported by the desired model. Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +46 −37 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +22 −17 Original line number Diff line number Diff line Loading @@ -227,7 +227,6 @@ public class AlwaysOnHotwordDetector { @Nullable private KeyphraseMetadata mKeyphraseMetadata; private final KeyphraseEnrollmentInfo mKeyphraseEnrollmentInfo; private final IVoiceInteractionService mVoiceInteractionService; private final IVoiceInteractionManagerService mModelManagementService; private final SoundTriggerListener mInternalCallback; private final Callback mExternalCallback; Loading Loading @@ -413,14 +412,11 @@ public class AlwaysOnHotwordDetector { * @param text The keyphrase text to get the detector for. * @param locale The java locale for the detector. * @param callback A non-null Callback for receiving the recognition events. * @param voiceInteractionService The current voice interaction service. * @param modelManagementService A service that allows management of sound models. * * @hide */ public AlwaysOnHotwordDetector(String text, Locale locale, Callback callback, KeyphraseEnrollmentInfo keyphraseEnrollmentInfo, IVoiceInteractionService voiceInteractionService, IVoiceInteractionManagerService modelManagementService) { mText = text; mLocale = locale; Loading @@ -428,7 +424,6 @@ public class AlwaysOnHotwordDetector { mExternalCallback = callback; mHandler = new MyHandler(); mInternalCallback = new SoundTriggerListener(mHandler); mVoiceInteractionService = voiceInteractionService; mModelManagementService = modelManagementService; new RefreshAvailabiltyTask().execute(); } Loading Loading @@ -471,6 +466,8 @@ public class AlwaysOnHotwordDetector { /** * Get the audio capabilities supported by the platform which can be enabled when * starting a recognition. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @see #AUDIO_CAPABILITY_ECHO_CANCELLATION * @see #AUDIO_CAPABILITY_NOISE_SUPPRESSION Loading @@ -488,7 +485,7 @@ public class AlwaysOnHotwordDetector { private int getSupportedAudioCapabilitiesLocked() { try { ModuleProperties properties = mModelManagementService.getDspModuleProperties(mVoiceInteractionService); mModelManagementService.getDspModuleProperties(); if (properties != null) { return properties.audioCapabilities; } Loading @@ -501,6 +498,8 @@ public class AlwaysOnHotwordDetector { /** * Starts recognition for the associated keyphrase. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @see #RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO * @see #RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS Loading Loading @@ -533,6 +532,8 @@ public class AlwaysOnHotwordDetector { /** * Stops recognition for the associated keyphrase. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @return Indicates whether the call succeeded or not. * @throws UnsupportedOperationException if the recognition isn't supported. Loading Loading @@ -565,6 +566,8 @@ public class AlwaysOnHotwordDetector { * stopping recognition. Once the model is unloaded, the value will be lost. * {@link AlwaysOnHotwordDetector#queryParameter} should be checked first before calling this * method. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @param value Value to set Loading Loading @@ -595,6 +598,8 @@ public class AlwaysOnHotwordDetector { * value is returned. See {@link ModelParams} for parameter default values. * {@link AlwaysOnHotwordDetector#queryParameter} should be checked first before * calling this method. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @return value of parameter Loading @@ -617,6 +622,8 @@ public class AlwaysOnHotwordDetector { * Determine if parameter control is supported for the given model handle. * This method should be checked prior to calling {@link AlwaysOnHotwordDetector#setParameter} * or {@link AlwaysOnHotwordDetector#getParameter}. * Caller must be the active voice interaction service via * Settings.Secure.VOICE_INTERACTION_SERVICE. * * @param modelParam {@link ModelParams} * @return supported range of parameter, null if not supported Loading Loading @@ -775,7 +782,7 @@ public class AlwaysOnHotwordDetector { int code = STATUS_ERROR; try { code = mModelManagementService.startRecognition(mVoiceInteractionService, code = mModelManagementService.startRecognition( mKeyphraseMetadata.id, mLocale.toLanguageTag(), mInternalCallback, new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, recognitionExtra, null /* additional data */, audioCapabilities)); Loading @@ -791,8 +798,8 @@ public class AlwaysOnHotwordDetector { private int stopRecognitionLocked() { int code = STATUS_ERROR; try { code = mModelManagementService.stopRecognition( mVoiceInteractionService, mKeyphraseMetadata.id, mInternalCallback); code = mModelManagementService.stopRecognition(mKeyphraseMetadata.id, mInternalCallback); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in stopRecognition!", e); } Loading @@ -805,8 +812,8 @@ public class AlwaysOnHotwordDetector { private int setParameterLocked(@ModelParams int modelParam, int value) { try { int code = mModelManagementService.setParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam, value); int code = mModelManagementService.setParameter(mKeyphraseMetadata.id, modelParam, value); if (code != STATUS_OK) { Slog.w(TAG, "setParameter failed with error code " + code); Loading @@ -820,8 +827,7 @@ public class AlwaysOnHotwordDetector { private int getParameterLocked(@ModelParams int modelParam) { try { return mModelManagementService.getParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam); return mModelManagementService.getParameter(mKeyphraseMetadata.id, modelParam); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -831,8 +837,7 @@ public class AlwaysOnHotwordDetector { private ModelParamRange queryParameterLocked(@ModelParams int modelParam) { try { SoundTrigger.ModelParamRange modelParamRange = mModelManagementService.queryParameter(mVoiceInteractionService, mKeyphraseMetadata.id, modelParam); mModelManagementService.queryParameter(mKeyphraseMetadata.id, modelParam); if (modelParamRange == null) { return null; Loading Loading @@ -966,7 +971,7 @@ public class AlwaysOnHotwordDetector { ModuleProperties dspModuleProperties = null; try { dspModuleProperties = mModelManagementService.getDspModuleProperties(mVoiceInteractionService); mModelManagementService.getDspModuleProperties(); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in getDspProperties!", e); } Loading @@ -982,7 +987,7 @@ public class AlwaysOnHotwordDetector { private void internalUpdateEnrolledKeyphraseMetadata() { try { mKeyphraseMetadata = mModelManagementService.getEnrolledKeyphraseMetadata( mVoiceInteractionService, mText, mLocale.toLanguageTag()); mText, mLocale.toLanguageTag()); } catch (RemoteException e) { Slog.w(TAG, "RemoteException in internalUpdateEnrolledKeyphraseMetadata", e); } Loading
core/java/android/service/voice/VoiceInteractionService.java +3 −3 Original line number Diff line number Diff line Loading @@ -199,7 +199,7 @@ public class VoiceInteractionService extends Service { throw new IllegalStateException("Not available until onReady() is called"); } try { mSystemService.showSession(mInterface, args, flags); mSystemService.showSession(args, flags); } catch (RemoteException e) { } } Loading Loading @@ -302,7 +302,7 @@ public class VoiceInteractionService extends Service { // Allow only one concurrent recognition via the APIs. safelyShutdownHotwordDetector(); mHotwordDetector = new AlwaysOnHotwordDetector(keyphrase, locale, callback, mKeyphraseEnrollmentInfo, mInterface, mSystemService); mKeyphraseEnrollmentInfo, mSystemService); } return mHotwordDetector; } Loading Loading @@ -373,7 +373,7 @@ public class VoiceInteractionService extends Service { } try { mSystemService.setUiHints(mInterface, hints); mSystemService.setUiHints(hints); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +58 −23 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import android.service.voice.IVoiceInteractionService; import android.service.voice.IVoiceInteractionSession; interface IVoiceInteractionManagerService { void showSession(IVoiceInteractionService service, in Bundle sessionArgs, int flags); void showSession(in Bundle sessionArgs, int flags); boolean deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor); boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags); Loading @@ -52,68 +52,91 @@ interface IVoiceInteractionManagerService { /** * Gets the registered Sound model for keyphrase detection for the current user. * May be null if no matching sound model exists. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ @UnsupportedAppUsage SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); /** * Add/Update the given keyphrase sound model. * Add/Update the given keyphrase sound model for the current user. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param model The keyphrase sound model to store peristantly. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ int updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model); /** * Deletes the given keyphrase sound model for the current user. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES */ int deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale); /** * Gets the properties of the DSP hardware on this device, null if not present. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ SoundTrigger.ModuleProperties getDspModuleProperties(in IVoiceInteractionService service); SoundTrigger.ModuleProperties getDspModuleProperties(); /** * Indicates if there's a keyphrase sound model available for the given keyphrase ID and the * user ID of the caller. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. */ boolean isEnrolledForKeyphrase(IVoiceInteractionService service, int keyphraseId, String bcp47Locale); boolean isEnrolledForKeyphrase(int keyphraseId, String bcp47Locale); /** * Generates KeyphraseMetadata for an enrolled sound model based on keyphrase string, locale, * and the user ID of the caller. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService * @param keyphrase Keyphrase text associated with the enrolled model * @param bcp47Locale The BCP47 language tag for the keyphrase's locale. * @return The metadata for the enrolled voice model bassed on the passed in parameters. Null if * no matching voice model exists. */ KeyphraseMetadata getEnrolledKeyphraseMetadata(IVoiceInteractionService service, String keyphrase, String bcp47Locale); KeyphraseMetadata getEnrolledKeyphraseMetadata(String keyphrase, String bcp47Locale); /** * Starts a recognition for the given keyphrase. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ int startRecognition(in IVoiceInteractionService service, int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, int startRecognition(int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig recognitionConfig); /** * Stops a recognition for the given keyphrase. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ int stopRecognition(in IVoiceInteractionService service, int keyphraseId, in IRecognitionStatusCallback callback); int stopRecognition(int keyphraseId, in IRecognitionStatusCallback callback); /** * Set a model specific ModelParams with the given value. This * parameter will keep its value for the duration the model is loaded regardless of starting and * stopping recognition. Once the model is unloaded, the value will be lost. * queryParameter should be checked first before calling this method. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @param value Value to set Loading @@ -123,36 +146,37 @@ interface IVoiceInteractionManagerService { * - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence or * if API is not supported by HAL */ int setParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam, int value); int setParameter(int keyphraseId, in ModelParams modelParam, int value); /** * Get a model specific ModelParams. This parameter will keep its value * for the duration the model is loaded regardless of starting and stopping recognition. * Once the model is unloaded, the value will be lost. If the value is not set, a default * value is returned. See ModelParams for parameter default values. * queryParameter should be checked first before calling this method. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @return value of parameter */ int getParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam); int getParameter(int keyphraseId, in ModelParams modelParam); /** * Determine if parameter control is supported for the given model handle. * This method should be checked prior to calling setParameter or getParameter. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * * @param service The current VoiceInteractionService. * @param keyphraseId The unique identifier for the keyphrase. * @param modelParam ModelParams * @return supported range of parameter, null if not supported */ @nullable SoundTrigger.ModelParamRange queryParameter(in IVoiceInteractionService service, int keyphraseId, in ModelParams modelParam); @nullable SoundTrigger.ModelParamRange queryParameter(int keyphraseId, in ModelParams modelParam); /** * @return the component name for the currently active voice interaction service * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ ComponentName getActiveServiceComponentName(); Loading @@ -164,59 +188,70 @@ interface IVoiceInteractionManagerService { * @param sourceFlags flags indicating the source of this show * @param showCallback optional callback to be notified when the session was shown * @param activityToken optional token of activity that needs to be on top * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean showSessionForActiveService(in Bundle args, int sourceFlags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken); /** * Hides the session from the active service, if it is showing. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void hideCurrentSession(); /** * Notifies the active service that a launch was requested from the Keyguard. This will only * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void launchVoiceAssistFromKeyguard(); /** * Indicates whether there is a voice session running (but not necessarily showing). * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean isSessionRunning(); /** * Indicates whether the currently active voice interaction service is capable of handling the * assist gesture. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean activeServiceSupportsAssist(); /** * Indicates whether the currently active voice interaction service is capable of being launched * from the lockscreen. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ boolean activeServiceSupportsLaunchFromKeyguard(); /** * Called when the lockscreen got shown. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void onLockscreenShown(); /** * Register a voice interaction listener. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener); /** * Checks the availability of a set of voice actions for the current active voice service. * Returns all supported voice actions. * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE */ void getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback); /** * Provide hints for showing UI. * Caller must be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. */ void setUiHints(in IVoiceInteractionService service, in Bundle hints); void setUiHints(in Bundle hints); /** * Requests a list of supported actions from a specific activity. Loading
media/java/android/media/voice/KeyphraseModelManager.java +14 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ import java.util.Objects; * manage voice based sound trigger models. * Callers of this class are expected to have whitelist manifest permission MANAGE_VOICE_KEYPHRASES. * Callers of this class are expected to be the designated voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}. * {@link Settings.Secure.VOICE_INTERACTION_SERVICE} or a bundled voice model enrollment application * detected by {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * @hide */ @SystemApi Loading Loading @@ -65,6 +66,10 @@ public final class KeyphraseModelManager { * {@link #updateKeyphraseSoundModel}. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param locale The locale language tag supported by the desired model. Loading Loading @@ -93,6 +98,10 @@ public final class KeyphraseModelManager { * will be overwritten with the new model. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param model Keyphrase sound model to be updated. * @throws ServiceSpecificException Thrown with error code if failed to update the keyphrase Loading Loading @@ -120,6 +129,10 @@ public final class KeyphraseModelManager { * {@link #updateKeyphraseSoundModel}. * If the active voice interaction service changes from the current user, all requests will be * rejected, and any registered models will be unregistered. * Caller must either be the active voice interaction service via * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model * enrollment application detected by * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}. * * @param keyphraseId The unique identifier for the keyphrase. * @param locale The locale language tag supported by the desired model. Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +46 −37 File changed.Preview size limit exceeded, changes collapsed. Show changes