1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.app;
import android.content.ComponentName;
import android.content.Intent;
import android.hardware.soundtrigger.KeyphraseMetadata;
import android.hardware.soundtrigger.SoundTrigger;
import android.media.AudioFormat;
import android.media.permission.Identity;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.RemoteCallback;
import android.os.SharedMemory;
import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback;
import android.service.voice.IVoiceInteractionService;
import android.service.voice.IVoiceInteractionSession;
import android.service.voice.VisibleActivityInfo;
import com.android.internal.app.IHotwordRecognitionStatusCallback;
import com.android.internal.app.IVoiceActionCheckCallback;
import com.android.internal.app.IVoiceInteractionSessionListener;
import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractionSoundTriggerSession;
import com.android.internal.app.IVoiceInteractor;
interface IVoiceInteractionManagerService {
void showSession(in Bundle sessionArgs, int flags);
boolean deliverNewSession(IBinder token, IVoiceInteractionSession session,
IVoiceInteractor interactor);
boolean showSessionFromSession(IBinder token, in Bundle sessionArgs, int flags);
boolean hideSessionFromSession(IBinder token);
int startVoiceActivity(IBinder token, in Intent intent, String resolvedType,
String callingFeatureId);
int startAssistantActivity(IBinder token, in Intent intent, String resolvedType,
String callingFeatureId);
void setKeepAwake(IBinder token, boolean keepAwake);
void closeSystemDialogs(IBinder token);
void finish(IBinder token);
void setDisabledShowContext(int flags);
int getDisabledShowContext();
int getUserDisabledShowContext();
/**
* 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(maxTargetSdk = 30, trackingBug = 170729553)
SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, in String bcp47Locale);
/**
* 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);
/**
* 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 keyphraseId The unique identifier for the keyphrase.
* @param bcp47Locale The BCP47 language tag for the keyphrase's locale.
*/
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 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(String keyphrase, String bcp47Locale);
/**
* @return the component name for the currently active voice interaction service
*/
ComponentName getActiveServiceComponentName();
/**
* Shows the session for the currently active service. Used to start a new session from system
* affordances.
*
* @param args the bundle to pass as arguments to the voice interaction session
* @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 Bundle hints);
/**
* Requests a list of supported actions from a specific activity.
*/
void requestDirectActions(in IBinder token, int taskId, IBinder assistToken,
in RemoteCallback cancellationCallback, in RemoteCallback callback);
/**
* Requests performing an action from a specific activity.
*/
void performDirectAction(in IBinder token, String actionId, in Bundle arguments, int taskId,
IBinder assistToken, in RemoteCallback cancellationCallback,
in RemoteCallback resultCallback);
/**
* Temporarily disables voice interaction (for example, on Automotive when the display is off).
*
* It will shutdown the service, and only re-enable it after it's called again (or after a
* system restart).
*
* NOTE: it's only effective when the service itself is available / enabled in the device, so
* calling setDisable(false) would be a no-op when it isn't.
*/
void setDisabled(boolean disabled);
/**
* Creates a session, allowing controlling running sound models on detection hardware.
* Caller must provide an identity, used for permission tracking purposes.
* The uid/pid elements of the identity will be ignored by the server and replaced with the ones
* provided by binder.
*
* The client argument is any binder owned by the client, used for tracking is death and
* cleaning up in this event.
*/
IVoiceInteractionSoundTriggerSession createSoundTriggerSessionAsOriginator(
in Identity originatorIdentity,
IBinder client);
/**
* Set configuration and pass read-only data to hotword detection service.
* Caller must provide an identity, used for permission tracking purposes.
* The uid/pid elements of the identity will be ignored by the server and replaced with the ones
* provided by binder.
*
* @param options Application configuration data to provide to the
* {@link HotwordDetectionService}. PersistableBundle does not allow any remotable objects or
* other contents that can be used to communicate with other processes.
* @param sharedMemory The unrestricted data blob to provide to the
* {@link HotwordDetectionService}. Use this to provide the hotword models data or other
* such data to the trusted process.
* @param callback Use this to report {@link HotwordDetectionService} status.
* @param detectorType Indicate which detector is used.
*/
void updateState(
in Identity originatorIdentity,
in PersistableBundle options,
in SharedMemory sharedMemory,
in IHotwordRecognitionStatusCallback callback,
int detectorType);
/**
* Requests to shutdown hotword detection service.
*/
void shutdownHotwordDetectionService();
void startListeningFromMic(
in AudioFormat audioFormat,
in IMicrophoneHotwordDetectionVoiceInteractionCallback callback);
void stopListeningFromMic();
void startListeningFromExternalSource(
in ParcelFileDescriptor audioStream,
in AudioFormat audioFormat,
in PersistableBundle options,
in IMicrophoneHotwordDetectionVoiceInteractionCallback callback);
/**
* Test API to simulate to trigger hardware recognition event for test.
*/
void triggerHardwareRecognitionEventForTest(
in SoundTrigger.KeyphraseRecognitionEvent event,
in IHotwordRecognitionStatusCallback callback);
/**
* Starts to listen the status of visible activity.
*/
void startListeningVisibleActivityChanged(in IBinder token);
/**
* Stops to listen the status of visible activity.
*/
void stopListeningVisibleActivityChanged(in IBinder token);
/**
* Notifies when the session window is shown or hidden.
*/
void setSessionWindowVisible(in IBinder token, boolean visible);
/**
* Notifies when the Activity lifecycle event changed.
*
* @param activityToken The token of activity.
* @param type The type of lifecycle event of the activity lifecycle.
*/
oneway void notifyActivityEventChanged(
in IBinder activityToken,
int type);
}
|