• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.app;
18 
19 import android.content.ComponentName;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.os.RemoteCallback;
23 
24 import com.android.internal.app.IVoiceActionCheckCallback;
25 import com.android.internal.app.IVoiceInteractionSessionShowCallback;
26 import com.android.internal.app.IVoiceInteractor;
27 import com.android.internal.app.IVoiceInteractionSessionListener;
28 import android.hardware.soundtrigger.IRecognitionStatusCallback;
29 import android.hardware.soundtrigger.KeyphraseMetadata;
30 import android.hardware.soundtrigger.ModelParams;
31 import android.hardware.soundtrigger.SoundTrigger;
32 import android.service.voice.IVoiceInteractionService;
33 import android.service.voice.IVoiceInteractionSession;
34 
35 interface IVoiceInteractionManagerService {
showSession(in Bundle sessionArgs, int flags)36     void showSession(in Bundle sessionArgs, int flags);
deliverNewSession(IBinder token, IVoiceInteractionSession session, IVoiceInteractor interactor)37     boolean deliverNewSession(IBinder token, IVoiceInteractionSession session,
38             IVoiceInteractor interactor);
showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags)39     boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags);
hideSessionFromSession(IBinder token)40     boolean hideSessionFromSession(IBinder token);
startVoiceActivity(IBinder token, in Intent intent, String resolvedType, String callingFeatureId)41     int startVoiceActivity(IBinder token, in Intent intent, String resolvedType,
42             String callingFeatureId);
startAssistantActivity(IBinder token, in Intent intent, String resolvedType, String callingFeatureId)43     int startAssistantActivity(IBinder token, in Intent intent, String resolvedType,
44             String callingFeatureId);
setKeepAwake(IBinder token, boolean keepAwake)45     void setKeepAwake(IBinder token, boolean keepAwake);
closeSystemDialogs(IBinder token)46     void closeSystemDialogs(IBinder token);
finish(IBinder token)47     void finish(IBinder token);
setDisabledShowContext(int flags)48     void setDisabledShowContext(int flags);
getDisabledShowContext()49     int getDisabledShowContext();
getUserDisabledShowContext()50     int getUserDisabledShowContext();
51 
52     /**
53      * Gets the registered Sound model for keyphrase detection for the current user.
54      * May be null if no matching sound model exists.
55      * Caller must either be the active voice interaction service via
56      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model
57      * enrollment application detected by
58      * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}.
59      *
60      * @param keyphraseId The unique identifier for the keyphrase.
61      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
62      * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES
63      */
64     @UnsupportedAppUsage
getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)65     SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
66     /**
67      * Add/Update the given keyphrase sound model for the current user.
68      * Caller must either be the active voice interaction service via
69      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model
70      * enrollment application detected by
71      * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}.
72      *
73      * @param model The keyphrase sound model to store peristantly.
74      * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES
75      */
updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model)76     int updateKeyphraseSoundModel(in SoundTrigger.KeyphraseSoundModel model);
77     /**
78      * Deletes the given keyphrase sound model for the current user.
79      * Caller must either be the active voice interaction service via
80      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}, or the caller must be a voice model
81      * enrollment application detected by
82      * {@link android.hardware.soundtrigger.KeyphraseEnrollmentInfo}.
83      *
84      * @param keyphraseId The unique identifier for the keyphrase.
85      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
86      * @RequiresPermission Manifest.permission.MANAGE_VOICE_KEYPHRASES
87      */
deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale)88     int deleteKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
89 
90     /**
91      * Gets the properties of the DSP hardware on this device, null if not present.
92      * Caller must be the active voice interaction service via
93      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
94      */
getDspModuleProperties()95     SoundTrigger.ModuleProperties getDspModuleProperties();
96     /**
97      * Indicates if there's a keyphrase sound model available for the given keyphrase ID and the
98      * user ID of the caller.
99      * Caller must be the active voice interaction service via
100      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
101      *
102      * @param keyphraseId The unique identifier for the keyphrase.
103      * @param bcp47Locale The BCP47 language tag  for the keyphrase's locale.
104      */
isEnrolledForKeyphrase(int keyphraseId, String bcp47Locale)105     boolean isEnrolledForKeyphrase(int keyphraseId, String bcp47Locale);
106     /**
107      * Generates KeyphraseMetadata for an enrolled sound model based on keyphrase string, locale,
108      * and the user ID of the caller.
109      * Caller must be the active voice interaction service via
110      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
111      *
112      * @param keyphrase Keyphrase text associated with the enrolled model
113      * @param bcp47Locale The BCP47 language tag for the keyphrase's locale.
114      * @return The metadata for the enrolled voice model bassed on the passed in parameters. Null if
115      *         no matching voice model exists.
116      */
getEnrolledKeyphraseMetadata(String keyphrase, String bcp47Locale)117     KeyphraseMetadata getEnrolledKeyphraseMetadata(String keyphrase, String bcp47Locale);
118     /**
119      * Starts a recognition for the given keyphrase.
120      * Caller must be the active voice interaction service via
121      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
122      */
startRecognition(int keyphraseId, in String bcp47Locale, in IRecognitionStatusCallback callback, in SoundTrigger.RecognitionConfig recognitionConfig)123     int startRecognition(int keyphraseId, in String bcp47Locale,
124             in IRecognitionStatusCallback callback,
125             in SoundTrigger.RecognitionConfig recognitionConfig);
126     /**
127      * Stops a recognition for the given keyphrase.
128      * Caller must be the active voice interaction service via
129      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
130      */
stopRecognition(int keyphraseId, in IRecognitionStatusCallback callback)131     int stopRecognition(int keyphraseId, in IRecognitionStatusCallback callback);
132     /**
133      * Set a model specific ModelParams with the given value. This
134      * parameter will keep its value for the duration the model is loaded regardless of starting and
135      * stopping recognition. Once the model is unloaded, the value will be lost.
136      * queryParameter should be checked first before calling this method.
137      * Caller must be the active voice interaction service via
138      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
139      *
140      * @param keyphraseId The unique identifier for the keyphrase.
141      * @param modelParam   ModelParams
142      * @param value        Value to set
143      * @return - {@link SoundTrigger#STATUS_OK} in case of success
144      *         - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached
145      *         - {@link SoundTrigger#STATUS_BAD_VALUE} invalid input parameter
146      *         - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence or
147      *           if API is not supported by HAL
148      */
setParameter(int keyphraseId, in ModelParams modelParam, int value)149     int setParameter(int keyphraseId, in ModelParams modelParam, int value);
150     /**
151      * Get a model specific ModelParams. This parameter will keep its value
152      * for the duration the model is loaded regardless of starting and stopping recognition.
153      * Once the model is unloaded, the value will be lost. If the value is not set, a default
154      * value is returned. See ModelParams for parameter default values.
155      * queryParameter should be checked first before calling this method.
156      * Caller must be the active voice interaction service via
157      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
158      *
159      * @param keyphraseId The unique identifier for the keyphrase.
160      * @param modelParam   ModelParams
161      * @return value of parameter
162      */
getParameter(int keyphraseId, in ModelParams modelParam)163     int getParameter(int keyphraseId, in ModelParams modelParam);
164     /**
165      * Determine if parameter control is supported for the given model handle.
166      * This method should be checked prior to calling setParameter or getParameter.
167      * Caller must be the active voice interaction service via
168      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
169      *
170      * @param keyphraseId The unique identifier for the keyphrase.
171      * @param modelParam ModelParams
172      * @return supported range of parameter, null if not supported
173      */
queryParameter(int keyphraseId, in ModelParams modelParam)174     @nullable SoundTrigger.ModelParamRange queryParameter(int keyphraseId,
175             in ModelParams modelParam);
176 
177     /**
178      * @return the component name for the currently active voice interaction service
179      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
180      */
getActiveServiceComponentName()181     ComponentName getActiveServiceComponentName();
182 
183     /**
184      * Shows the session for the currently active service. Used to start a new session from system
185      * affordances.
186      *
187      * @param args the bundle to pass as arguments to the voice interaction session
188      * @param sourceFlags flags indicating the source of this show
189      * @param showCallback optional callback to be notified when the session was shown
190      * @param activityToken optional token of activity that needs to be on top
191      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
192      */
showSessionForActiveService(in Bundle args, int sourceFlags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken)193     boolean showSessionForActiveService(in Bundle args, int sourceFlags,
194             IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken);
195 
196     /**
197      * Hides the session from the active service, if it is showing.
198      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
199      */
hideCurrentSession()200     void hideCurrentSession();
201 
202     /**
203      * Notifies the active service that a launch was requested from the Keyguard. This will only
204      * be called if {@link #activeServiceSupportsLaunchFromKeyguard()} returns true.
205      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
206      */
launchVoiceAssistFromKeyguard()207     void launchVoiceAssistFromKeyguard();
208 
209     /**
210      * Indicates whether there is a voice session running (but not necessarily showing).
211      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
212      */
isSessionRunning()213     boolean isSessionRunning();
214 
215     /**
216      * Indicates whether the currently active voice interaction service is capable of handling the
217      * assist gesture.
218      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
219      */
activeServiceSupportsAssist()220     boolean activeServiceSupportsAssist();
221 
222     /**
223      * Indicates whether the currently active voice interaction service is capable of being launched
224      * from the lockscreen.
225      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
226      */
activeServiceSupportsLaunchFromKeyguard()227     boolean activeServiceSupportsLaunchFromKeyguard();
228 
229     /**
230      * Called when the lockscreen got shown.
231      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
232      */
onLockscreenShown()233     void onLockscreenShown();
234 
235     /**
236      * Register a voice interaction listener.
237      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
238      */
registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener)239     void registerVoiceInteractionSessionListener(IVoiceInteractionSessionListener listener);
240 
241     /**
242      * Checks the availability of a set of voice actions for the current active voice service.
243      * Returns all supported voice actions.
244      * @RequiresPermission Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE
245      */
getActiveServiceSupportedActions(in List<String> voiceActions, in IVoiceActionCheckCallback callback)246     void getActiveServiceSupportedActions(in List<String> voiceActions,
247      in IVoiceActionCheckCallback callback);
248 
249     /**
250      * Provide hints for showing UI.
251      * Caller must be the active voice interaction service via
252      * {@link Settings.Secure.VOICE_INTERACTION_SERVICE}.
253      */
setUiHints(in Bundle hints)254     void setUiHints(in Bundle hints);
255 
256     /**
257      * Requests a list of supported actions from a specific activity.
258      */
requestDirectActions(in IBinder token, int taskId, IBinder assistToken, in RemoteCallback cancellationCallback, in RemoteCallback callback)259     void requestDirectActions(in IBinder token, int taskId, IBinder assistToken,
260              in RemoteCallback cancellationCallback, in RemoteCallback callback);
261 
262     /**
263      * Requests performing an action from a specific activity.
264      */
performDirectAction(in IBinder token, String actionId, in Bundle arguments, int taskId, IBinder assistToken, in RemoteCallback cancellationCallback, in RemoteCallback resultCallback)265     void performDirectAction(in IBinder token, String actionId, in Bundle arguments, int taskId,
266             IBinder assistToken, in RemoteCallback cancellationCallback,
267             in RemoteCallback resultCallback);
268 
269     /**
270      * Temporarily disables voice interaction (for example, on Automotive when the display is off).
271      *
272      * It will shutdown the service, and only re-enable it after it's called again (or after a
273      * system restart).
274      *
275      * NOTE: it's only effective when the service itself is available / enabled in the device, so
276      * calling setDisable(false) would be a no-op when it isn't.
277      */
setDisabled(boolean disabled)278     void setDisabled(boolean disabled);
279 
280 }
281