1 /*
2  * Copyright (C) 2019 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 package android.media.soundtrigger_middleware;
17 
18 import android.media.soundtrigger_middleware.RecognitionEvent;
19 import android.media.soundtrigger_middleware.PhraseRecognitionEvent;
20 
21 /**
22  * Main interface for a client to get notifications of events coming from this module.
23  *
24  * {@hide}
25  */
26 oneway interface ISoundTriggerCallback {
27     /**
28      * Invoked whenever a recognition event is triggered (typically, on recognition, but also in
29      * case of external aborting of a recognition or a forced recognition event - see the status
30      * code in the event for determining).
31      */
onRecognition(int modelHandle, in RecognitionEvent event)32     void onRecognition(int modelHandle, in RecognitionEvent event);
33      /**
34       * Invoked whenever a phrase recognition event is triggered (typically, on recognition, but
35       * also in case of external aborting of a recognition or a forced recognition event - see the
36       * status code in the event for determining).
37       */
onPhraseRecognition(int modelHandle, in PhraseRecognitionEvent event)38     void onPhraseRecognition(int modelHandle, in PhraseRecognitionEvent event);
39     /**
40      * Notifies the client the recognition has become available after previously having been
41      * unavailable, or vice versa. This method will always be invoked once immediately after
42      * attachment, and then every time there is a change in availability.
43      * When availability changes from available to unavailable, all active recognitions are aborted,
44      * and this event will be sent in addition to the abort event.
45      */
onRecognitionAvailabilityChange(boolean available)46     void onRecognitionAvailabilityChange(boolean available);
47     /**
48      * Notifies the client that the associated module has crashed and restarted. The module instance
49      * is no longer usable and will throw a ServiceSpecificException with a Status.DEAD_OBJECT code
50      * for every call. The client should detach, then re-attach to the module in order to get a new,
51      * usable instance. All state for this module has been lost.
52      */
onModuleDied()53      void onModuleDied();
54 }
55