1 /* 2 * Copyright (C) 2020 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.hardware.soundtrigger.SoundTrigger; 20 import android.service.voice.HotwordDetectedResult; 21 import android.service.voice.HotwordDetectionServiceFailure; 22 import android.service.voice.HotwordRejectedResult; 23 import android.service.voice.SoundTriggerFailure; 24 import android.service.voice.VisualQueryDetectionServiceFailure; 25 import com.android.internal.infra.AndroidFuture; 26 27 /** 28 * @hide 29 */ 30 oneway interface IHotwordRecognitionStatusCallback { 31 /** 32 * Called when the keyphrase is spoken. 33 * 34 * @param recognitionEvent Object containing data relating to the 35 * keyphrase recognition event such as keyphrase 36 * extras. 37 * @param result Successful detection result payload. 38 */ onKeyphraseDetected( in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent, in HotwordDetectedResult result)39 void onKeyphraseDetected( 40 in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent, 41 in HotwordDetectedResult result); 42 43 /** 44 * Called when a generic sound trigger event is witnessed. 45 * 46 * @param recognitionEvent Object containing data relating to the 47 * recognition event such as trigger audio data (if 48 * requested). 49 */ onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent)50 void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent); 51 52 /** 53 * Called when the {@link HotwordDetectionService second stage detection} did not detect the 54 * keyphrase. 55 * 56 * @param result Info about the second stage detection result, provided by the 57 * {@link HotwordDetectionService}. 58 */ onRejected(in HotwordRejectedResult result)59 void onRejected(in HotwordRejectedResult result); 60 61 /** 62 * Called when the detection fails due to an error occurs in the 63 * {@link HotwordDetectionService}. 64 * 65 * @param hotwordDetectionServiceFailure It provides the error code, error message and 66 * suggested action. 67 */ onHotwordDetectionServiceFailure( in HotwordDetectionServiceFailure hotwordDetectionServiceFailure)68 void onHotwordDetectionServiceFailure( 69 in HotwordDetectionServiceFailure hotwordDetectionServiceFailure); 70 71 /** 72 * Called when the detection fails due to an error occurs in the 73 * {@link VisualQueryDetectionService}. 74 * 75 * @param visualQueryDetectionServiceFailure It provides the error code, error message and 76 * suggested action. 77 */ onVisualQueryDetectionServiceFailure( in VisualQueryDetectionServiceFailure visualQueryDetectionServiceFailure)78 void onVisualQueryDetectionServiceFailure( 79 in VisualQueryDetectionServiceFailure visualQueryDetectionServiceFailure); 80 81 /** 82 * Called when the detection fails due to an error occurs in the 83 * {@link com.android.server.soundtrigger.SoundTriggerService}. 84 * 85 * @param soundTriggerFailure It provides the error code, error message and 86 * suggested action. 87 */ onSoundTriggerFailure(in SoundTriggerFailure soundTriggerFailure)88 void onSoundTriggerFailure(in SoundTriggerFailure soundTriggerFailure); 89 90 /** 91 * Called when the detection fails due to an unknown error occurs. 92 * 93 * @param errorMessage It provides the error message. 94 */ onUnknownFailure(in String errorMessage)95 void onUnknownFailure(in String errorMessage); 96 97 /** 98 * Called when the recognition is paused temporarily for some reason. 99 */ onRecognitionPaused()100 void onRecognitionPaused(); 101 102 /** 103 * Called when the recognition is resumed after it was temporarily paused. 104 */ onRecognitionResumed()105 void onRecognitionResumed(); 106 107 /** 108 * Called when the {@link HotwordDetectionService} reported the result for requesting update 109 * state action. 110 * 111 * @param status The status about the result of requesting update state action. 112 */ onStatusReported(int status)113 void onStatusReported(int status); 114 115 /** Called when the hotword detection process is restarted */ onProcessRestarted()116 void onProcessRestarted(); 117 118 /** 119 * Called when a file open request is sent. 120 */ onOpenFile(in String filename, in AndroidFuture future)121 void onOpenFile(in String filename, in AndroidFuture future); 122 } 123