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 the keyphrase is detected from audio coming from an external source. 45 * 46 * @param result Successful detection result payload. 47 */ onKeyphraseDetectedFromExternalSource(in HotwordDetectedResult result)48 void onKeyphraseDetectedFromExternalSource(in HotwordDetectedResult result); 49 50 /** 51 * Called when a generic sound trigger event is witnessed. 52 * 53 * @param recognitionEvent Object containing data relating to the 54 * recognition event such as trigger audio data (if 55 * requested). 56 */ onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent)57 void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent); 58 59 /** 60 * Called when the {@link HotwordDetectionService second stage detection} did not detect the 61 * keyphrase. 62 * 63 * @param result Info about the second stage detection result, provided by the 64 * {@link HotwordDetectionService}. 65 */ onRejected(in HotwordRejectedResult result)66 void onRejected(in HotwordRejectedResult result); 67 68 /** 69 * Called when the detection fails due to an error occurs in the 70 * {@link HotwordDetectionService}. 71 * 72 * @param hotwordDetectionServiceFailure It provides the error code, error message and 73 * suggested action. 74 */ onHotwordDetectionServiceFailure( in HotwordDetectionServiceFailure hotwordDetectionServiceFailure)75 void onHotwordDetectionServiceFailure( 76 in HotwordDetectionServiceFailure hotwordDetectionServiceFailure); 77 78 /** 79 * Called when the detection fails due to an error occurs in the 80 * {@link VisualQueryDetectionService}. 81 * 82 * @param visualQueryDetectionServiceFailure It provides the error code, error message and 83 * suggested action. 84 */ onVisualQueryDetectionServiceFailure( in VisualQueryDetectionServiceFailure visualQueryDetectionServiceFailure)85 void onVisualQueryDetectionServiceFailure( 86 in VisualQueryDetectionServiceFailure visualQueryDetectionServiceFailure); 87 88 /** 89 * Called when the detection fails due to an error occurs in the 90 * {@link com.android.server.soundtrigger.SoundTriggerService}. 91 * 92 * @param soundTriggerFailure It provides the error code, error message and 93 * suggested action. 94 */ onSoundTriggerFailure(in SoundTriggerFailure soundTriggerFailure)95 void onSoundTriggerFailure(in SoundTriggerFailure soundTriggerFailure); 96 97 /** 98 * Called when the detection fails due to an unknown error occurs. 99 * 100 * @param errorMessage It provides the error message. 101 */ onUnknownFailure(in String errorMessage)102 void onUnknownFailure(in String errorMessage); 103 104 /** 105 * Called when the recognition is paused temporarily for some reason. 106 */ onRecognitionPaused()107 void onRecognitionPaused(); 108 109 /** 110 * Called when the recognition is resumed after it was temporarily paused. 111 */ onRecognitionResumed()112 void onRecognitionResumed(); 113 114 /** 115 * Called when the {@link HotwordDetectionService} reported the result for requesting update 116 * state action. 117 * 118 * @param status The status about the result of requesting update state action. 119 */ onStatusReported(int status)120 void onStatusReported(int status); 121 122 /** Called when the hotword detection process is restarted */ onProcessRestarted()123 void onProcessRestarted(); 124 125 /** 126 * Called when a file open request is sent. 127 */ onOpenFile(in String filename, in AndroidFuture future)128 void onOpenFile(in String filename, in AndroidFuture future); 129 } 130