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.RecognitionEventSys; 19 import android.media.soundtrigger_middleware.PhraseRecognitionEventSys; 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 * In case of abortion, the caller may retry after the next onRecognitionAvailabilityChange() 32 * callback. 33 */ onRecognition(int modelHandle, in RecognitionEventSys event, int captureSession)34 void onRecognition(int modelHandle, in RecognitionEventSys event, int captureSession); 35 /** 36 * Invoked whenever a phrase recognition event is triggered (typically, on recognition, but 37 * also in case of external aborting of a recognition or a forced recognition event - see the 38 * status code in the event for determining). 39 * In case of abortion, the caller may retry after the next onRecognitionAvailabilityChange() 40 * callback. 41 */ onPhraseRecognition(int modelHandle, in PhraseRecognitionEventSys event, int captureSession)42 void onPhraseRecognition(int modelHandle, in PhraseRecognitionEventSys event, int captureSession); 43 /** 44 * Notifies the client that some start/load operations that have previously failed for resource 45 * reasons (threw a ServiceSpecificException(RESOURCE_CONTENTION) or have been preempted) may 46 * now succeed. This is not a guarantee, but a hint for the client to retry. 47 */ onResourcesAvailable()48 void onResourcesAvailable(); 49 /** 50 * Notifies the client that a model had been preemptively unloaded by the service. 51 * The caller may retry after the next onRecognitionAvailabilityChange() callback. 52 */ onModelUnloaded(int modelHandle)53 void onModelUnloaded(int modelHandle); 54 /** 55 * Notifies the client that the associated module has crashed and restarted. The module instance 56 * is no longer usable and will throw a ServiceSpecificException with a Status.DEAD_OBJECT code 57 * for every call. The client should detach, then re-attach to the module in order to get a new, 58 * usable instance. All state for this module has been lost. 59 */ onModuleDied()60 void onModuleDied(); 61 } 62