1/*
2 * Copyright (C) 2022 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
17syntax = "proto2";
18
19package android.os.statsd.hotword;
20
21import "frameworks/proto_logging/stats/atom_field_options.proto";
22import "frameworks/proto_logging/stats/enums/hotword/enums.proto";
23
24option java_package = "com.android.os.hotword";
25option java_multiple_files = true;
26
27/**
28 * Logs information related to creating hotword detector.
29 */
30message HotwordDetectorCreateRequested {
31    // The type of detector.
32    optional android.hotword.HotwordDetectorType detector_type = 1;
33
34    // True if the detector is created successfully.
35    optional bool is_created_done = 2;
36
37    // The UID for which assistant application is active.
38    optional int32 uid = 3 [(is_uid) = true];
39}
40
41/**
42 * Logs information related to hotword detection service init result.
43 */
44message HotwordDetectionServiceInitResultReported {
45    // The type of detector.
46    optional android.hotword.HotwordDetectorType detector_type = 1;
47
48    // The result of initialization.
49    enum Result {
50        // Indicates that the service was initialized successfully.
51        CALLBACK_INIT_STATE_SUCCESS = 0;
52
53        // Indicates that the service was not initialized successfully.
54        CALLBACK_INIT_STATE_ERROR = 1;
55
56        // Indicates that the callback was invoked without init state.
57        CALLBACK_INIT_STATE_UNKNOWN_NO_VALUE = 2;
58
59        // Indicates that the callback was invoked, but the init state value exceeded
60        // the defined maximum.
61        CALLBACK_INIT_STATE_UNKNOWN_OVER_MAX_CUSTOM_VALUE = 3;
62
63        // Indicates that the callback was not invoked within timeout.
64        CALLBACK_INIT_STATE_UNKNOWN_TIMEOUT = 4;
65    }
66    optional Result result = 2;
67
68    // The UID for which the assistant application is active.
69    optional int32 uid = 3 [(is_uid) = true];
70}
71
72/**
73 * Logs information related to restarting hotword detection service.
74 */
75message HotwordDetectionServiceRestarted {
76    // The type of detector.
77    optional android.hotword.HotwordDetectorType detector_type = 1;
78
79    // The reason for restarting service.
80    enum Reason {
81        // UNKNOWN value.
82        UNKNOWN = 0;
83
84        // Indicates that the service was restarted due to audio service died.
85        AUDIO_SERVICE_DIED = 1;
86
87        // Indicates that the service was restarted regularly.
88        SCHEDULE = 2;
89
90        // Deprecated. Indicates that the service was restarted due to service crashed.
91        CRASH = 3 [deprecated = true];
92    }
93    optional Reason reason = 2;
94
95    // The UID for which the assistant application is active.
96    optional int32 uid = 3 [(is_uid) = true];
97}
98
99/**
100 * Logs information related to keyphrase trigger.
101 */
102message HotwordDetectorKeyphraseTriggered {
103    // The type of detector.
104    optional android.hotword.HotwordDetectorType detector_type = 1;
105
106    // The result of detection.
107    enum Result {
108        // Indicates that the system got the keyphrase from DSP.
109        KEYPHRASE_TRIGGER = 0;
110
111        // Deprecated. Indicates that the system can not inform the service to verify the keyphrase.
112        FAILED_TO_INFORM_SERVICE = 1 [deprecated = true];
113
114        // Indicates that the callback was not invoked within timeout after informing
115        // the service.
116        DETECT_TIMEOUT = 2;
117
118        // Indicates that the system got the exception after informing the service.
119        DETECT_EXCEPTION = 3;
120
121        // Indicates that the service crashed.
122        SERVICE_CRASH = 4;
123
124        // Indicates that the keyphrase was detected.
125        DETECTED = 5;
126
127        // Indicates that the keyphrase was not detected.
128        REJECTED = 6;
129
130        // Indicates that the system got the unexpected detected callback.
131        DETECT_UNEXPECTED_CALLBACK = 7;
132
133        // Indicates that the system got the security exception when handling detected callback.
134        DETECT_SECURITY_EXCEPTION = 8;
135
136        // Indicates that the system got the unexpected rejected callback.
137        REJECT_UNEXPECTED_CALLBACK = 9;
138
139        // Indicates that the system called rejected callback when the trusted process was
140        // restarted.
141        REJECTED_FROM_RESTART = 10;
142
143        // Indicates keyphrase was classified as training data.
144        TRAINING_DATA = 11;
145
146        // Indicates training data egress limit was reached.
147        TRAINING_DATA_EGRESS_LIMIT_REACHED = 12;
148
149        // Indicates that system got security exception when handling training data callback.
150        TRAINING_DATA_SECURITY_EXCEPTION = 13;
151
152        // Indicates that system got remote exception when handling training data callback.
153        TRAINING_DATA_REMOTE_EXCEPTION = 14;
154    }
155    // What result after detecting.
156    optional Result result = 2;
157
158    // The UID for which the assistant application is active.
159    optional int32 uid = 3 [(is_uid) = true];
160}
161
162/**
163 * Logs information related to hotword detector events.
164 */
165message HotwordDetectorEvents {
166    // The type of detector.
167    optional android.hotword.HotwordDetectorType detector_type = 1;
168
169    // The type of event.
170    enum Event {
171        // UNKNOWN value.
172        UNKNOWN = 0;
173
174        // Indicates that the system requested to bind the service.
175        REQUEST_BIND_SERVICE = 1;
176
177        // Indicates that the system connected the service successfully.
178        ON_CONNECTED = 2;
179
180        // Indicates that the system failed to bind the service.
181        REQUEST_BIND_SERVICE_FAIL = 3;
182
183        // Indicates that the system called the updateState function of service.
184        REQUEST_UPDATE_STATE = 4;
185
186        // Indicates that the callback was not invoked within timeout after calling
187        // the updateState function of service.
188        CALLBACK_UPDATE_STATE_AFTER_TIMEOUT = 5;
189
190        // Indicates that no starting recognition after creating the detector.
191        DID_NOT_CALL_START_RECOGNITION = 6;
192
193        // Indicates that the system disconnected the service.
194        ON_DISCONNECTED = 7;
195
196        // Indicates that the application called the updateState function.
197        APP_REQUEST_UPDATE_STATE = 8;
198
199        // Indicates that starting to listen software detection.
200        START_SOFTWARE_DETECTION = 9;
201
202        // Indicates that starting to listen external source detection.
203        START_EXTERNAL_SOURCE_DETECTION = 10;
204
205        // Indicates that the external source detection was detected.
206        EXTERNAL_SOURCE_DETECTED = 11;
207
208        // Indicates that the external source detection was not detected.
209        EXTERNAL_SOURCE_REJECTED = 12;
210
211        // Indicates that the system got the security exception when handling external
212        // source detected callback.
213        EXTERNAL_SOURCE_DETECT_SECURITY_EXCEPTION = 13;
214
215        // Indicates that the callback onStatusReported was not invoked successfully.
216        CALLBACK_ON_STATUS_REPORTED_EXCEPTION = 14;
217
218        // Indicates that the callback onError was not invoked successfully.
219        CALLBACK_ON_ERROR_EXCEPTION = 15;
220
221        // Indicates that the callback onRejected was not invoked successfully.
222        CALLBACK_ON_REJECTED_EXCEPTION = 16;
223
224        // Indicates that the callback onDetected was not invoked successfully.
225        CALLBACK_ON_DETECTED_EXCEPTION = 17;
226
227        // Indicates that the callback onProcessRestarted was not invoked successfully.
228        CALLBACK_ON_PROCESS_RESTARTED_EXCEPTION = 18;
229
230        // Indicates that the updateState was not invoked successfully.
231        CALL_UPDATE_STATE_EXCEPTION = 19;
232
233        // Deprecated. Use HotwordAudioEgressEventReported instead.
234        // Indicates that the audio egress starts.
235        AUDIO_EGRESS_START = 20 [deprecated = true];
236
237        // Deprecated. Use HotwordAudioEgressEventReported instead.
238        // Indicates that the audio egress ends.
239        AUDIO_EGRESS_END = 21 [deprecated = true];
240
241        // Deprecated. Use HotwordAudioEgressEventReported instead.
242        // Indicates that the audio egress got interrupted exception.
243        AUDIO_EGRESS_INTERRUPTED_EXCEPTION = 22 [deprecated = true];
244
245        // Deprecated. Use HotwordAudioEgressEventReported instead.
246        // Indicates that the client is not granted permission to access audio egress.
247        AUDIO_EGRESS_NO_PERMISSION = 23 [deprecated = true];
248
249        // Deprecated. Use HotwordAudioEgressEventReported instead.
250        // Indicates that the client is inactive over a period of time.
251        AUDIO_EGRESS_INACTIVE_CLIENT = 24 [deprecated = true];
252
253        // Deprecated. Use HotwordAudioEgressEventReported instead.
254        // Indicates that the HotwordDetectionService is inactive over a period
255        // of time.
256        AUDIO_EGRESS_INACTIVE_HOTWORD_DETECTION_SERVICE = 25 [deprecated = true];
257
258        // Deprecated. Use HotwordAudioEgressEventReported instead.
259        // Indicates that the list of audio stream is empty.
260        AUDIO_EGRESS_EMPTY_AUDIO_STREAM_LIST = 26 [deprecated = true];
261
262        // Deprecated. Use HotwordAudioEgressEventReported instead.
263        // Indicates that there is no data from the system audio stream.
264        AUDIO_EGRESS_SOURCE_IS_EMPTY = 27 [deprecated = true];
265
266        // Deprecated. Use HotwordAudioEgressEventReported instead.
267        // Indicates that the copy buffer size the client sets is illegal.
268        AUDIO_EGRESS_ILLEGAL_COPY_BUFFER_SIZE = 28 [deprecated = true];
269
270        // Deprecated. Use HotwordAudioEgressEventReported instead.
271        // Indicates that the audio egress is closed with error from the system.
272        AUDIO_EGRESS_CLOSE_ERROR_FROM_SYSTEM = 29 [deprecated = true];
273
274        // Deprecated. Use HotwordAudioEgressEventReported instead.
275        // Indicates that the audio egress is closed with error from the client
276        // side.
277        AUDIO_EGRESS_CLOSE_ERROR_FROM_CLIENT = 30 [deprecated = true];
278
279        // Deprecated. Use HotwordAudioEgressEventReported instead.
280        // Indicates that the audio egress is closed with error from the
281        // HotwordDetectionService.
282        AUDIO_EGRESS_CLOSE_ERROR_FROM_HOTWORD_DETECTION_SERVICE = 31 [deprecated = true];
283    }
284    optional Event event = 2;
285
286    // The UID for which assistant application is active.
287    optional int32 uid = 3 [(is_uid) = true];
288}
289
290/**
291 * Logs information related to audio egress in hotword.
292 */
293message HotwordAudioEgressEventReported {
294    // The type of detector.
295    optional android.hotword.HotwordDetectorType detector_type = 1;
296
297    // The type of event.
298    enum Event {
299        // UNKNOWN value.
300        UNKNOWN = 0;
301
302        // Indicates that the audio egress started.
303        STARTED = 1;
304
305        // Indicates that the audio egress ended.
306        ENDED = 2;
307
308        // Indicates that the audio egress got interrupted exception.
309        INTERRUPTED_EXCEPTION = 3;
310
311        // Indicates that the client is not granted permission to access audio egress.
312        NO_PERMISSION = 4;
313
314        // Indicates that the client is inactive over a period of time.
315        INACTIVE_CLIENT = 5;
316
317        // Indicates that the HotwordDetectionService is inactive over a period
318        // of time.
319        INACTIVE_HOTWORD_DETECTION_SERVICE = 6;
320
321        // Indicates that the list of audio stream is empty.
322        EMPTY_AUDIO_STREAM_LIST = 7;
323
324        // Indicates that there is no data from the system audio stream.
325        SOURCE_IS_EMPTY = 8;
326
327        // Indicates that the copy buffer size the client sets is illegal.
328        ILLEGAL_COPY_BUFFER_SIZE = 9;
329
330        // Indicates that the audio egress is closed with error from the system.
331        CLOSE_ERROR_FROM_SYSTEM = 10;
332
333        // Indicates that the audio egress is closed with error from the client side.
334        CLOSE_ERROR_FROM_CLIENT = 11;
335
336        // Indicates that the audio egress is closed with error from the
337        // HotwordDetectionService.
338        CLOSE_ERROR_FROM_HOTWORD_DETECTION_SERVICE = 12;
339   }
340    optional Event event = 2;
341
342    // The UID for which the assistant application is active.
343    optional int32 uid = 3 [(is_uid) = true];
344
345    // The number of bytes egressed in audio stream
346    optional int32 egressed_stream_size_bytes = 4;
347
348    // The number of bytes egressed in metadata bundle
349    optional int32 egressed_metadata_bundle_size_bytes = 5;
350
351    // The count of audio streams
352    optional int32 stream_count = 6;
353}
354