1 /** 2 * Copyright (C) 2014 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.server.soundtrigger; 18 19 import android.hardware.soundtrigger.IRecognitionStatusCallback; 20 import android.hardware.soundtrigger.SoundTrigger; 21 import android.hardware.soundtrigger.SoundTrigger.Keyphrase; 22 import android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent; 23 import android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra; 24 import android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel; 25 import android.hardware.soundtrigger.SoundTrigger.ModuleProperties; 26 import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig; 27 import android.hardware.soundtrigger.SoundTrigger.RecognitionEvent; 28 import android.hardware.soundtrigger.SoundTrigger.SoundModelEvent; 29 import android.hardware.soundtrigger.SoundTriggerModule; 30 31 import java.io.FileDescriptor; 32 import java.io.PrintWriter; 33 34 /** 35 * Provides a local service for managing voice-related recoginition models. This is primarily used 36 * by the {@link VoiceInteractionManagerService}. 37 */ 38 public abstract class SoundTriggerInternal { 39 /** 40 * Return codes for {@link #startRecognition(int, KeyphraseSoundModel, 41 * IRecognitionStatusCallback, RecognitionConfig)}, 42 * {@link #stopRecognition(int, IRecognitionStatusCallback)} 43 */ 44 public static final int STATUS_ERROR = SoundTrigger.STATUS_ERROR; 45 public static final int STATUS_OK = SoundTrigger.STATUS_OK; 46 47 /** 48 * Starts recognition for the given keyphraseId. 49 * 50 * @param keyphraseId The identifier of the keyphrase for which 51 * the recognition is to be started. 52 * @param soundModel The sound model to use for recognition. 53 * @param listener The listener for the recognition events related to the given keyphrase. 54 * @return One of {@link #STATUS_ERROR} or {@link #STATUS_OK}. 55 */ startRecognition(int keyphraseId, KeyphraseSoundModel soundModel, IRecognitionStatusCallback listener, RecognitionConfig recognitionConfig)56 public abstract int startRecognition(int keyphraseId, KeyphraseSoundModel soundModel, 57 IRecognitionStatusCallback listener, RecognitionConfig recognitionConfig); 58 59 /** 60 * Stops recognition for the given {@link Keyphrase} if a recognition is 61 * currently active. 62 * 63 * @param keyphraseId The identifier of the keyphrase for which 64 * the recognition is to be stopped. 65 * @param listener The listener for the recognition events related to the given keyphrase. 66 * 67 * @return One of {@link #STATUS_ERROR} or {@link #STATUS_OK}. 68 */ stopRecognition(int keyphraseId, IRecognitionStatusCallback listener)69 public abstract int stopRecognition(int keyphraseId, IRecognitionStatusCallback listener); 70 getModuleProperties()71 public abstract ModuleProperties getModuleProperties(); 72 73 /** 74 * Unloads (and stops if running) the given keyphraseId 75 */ unloadKeyphraseModel(int keyphaseId)76 public abstract int unloadKeyphraseModel(int keyphaseId); 77 dump(FileDescriptor fd, PrintWriter pw, String[] args)78 public abstract void dump(FileDescriptor fd, PrintWriter pw, String[] args); 79 } 80