FileDocCategorySizeDatePackage
SoundTriggerModule.javaAPI DocAndroid 5.1 API8993Thu Mar 12 22:22:10 GMT 2015android.hardware.soundtrigger

SoundTriggerModule

public class SoundTriggerModule extends Object
The SoundTriggerModule provides APIs to control sound models and sound detection on a given sound trigger hardware module.
hide

Fields Summary
private long
mNativeContext
private int
mId
private NativeEventHandlerDelegate
mEventHandlerDelegate
private static final int
EVENT_RECOGNITION
private static final int
EVENT_SERVICE_DIED
private static final int
EVENT_SOUNDMODEL
private static final int
EVENT_SERVICE_STATE_CHANGE
Constructors Summary
SoundTriggerModule(int moduleId, SoundTrigger.StatusListener listener, android.os.Handler handler)


          
        mId = moduleId;
        mEventHandlerDelegate = new NativeEventHandlerDelegate(listener, handler);
        native_setup(new WeakReference<SoundTriggerModule>(this));
    
Methods Summary
public native voiddetach()
Detach from this module. The {@link SoundTrigger.StatusListener} callback will not be called anymore and associated resources will be released.

protected voidfinalize()

        native_finalize();
    
public native intloadSoundModel(SoundTrigger.SoundModel model, int[] soundModelHandle)
Load a {@link SoundTrigger.SoundModel} to the hardware. A sound model must be loaded in order to start listening to a key phrase in this model.

param
model The sound model to load.
param
soundModelHandle an array of int where the sound model handle will be returned.
return
- {@link SoundTrigger#STATUS_OK} in case of success - {@link SoundTrigger#STATUS_ERROR} in case of unspecified error - {@link SoundTrigger#STATUS_PERMISSION_DENIED} if the caller does not have system permission - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached - {@link SoundTrigger#STATUS_BAD_VALUE} if parameters are invalid - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native service fails - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence

private native voidnative_finalize()

private native voidnative_setup(java.lang.Object module_this)

private static voidpostEventFromNative(java.lang.Object module_ref, int what, int arg1, int arg2, java.lang.Object obj)

        SoundTriggerModule module = (SoundTriggerModule)((WeakReference)module_ref).get();
        if (module == null) {
            return;
        }

        NativeEventHandlerDelegate delegate = module.mEventHandlerDelegate;
        if (delegate != null) {
            Handler handler = delegate.handler();
            if (handler != null) {
                Message m = handler.obtainMessage(what, arg1, arg2, obj);
                handler.sendMessage(m);
            }
        }
    
public native intstartRecognition(int soundModelHandle, SoundTrigger.RecognitionConfig config)
Start listening to all key phrases in a {@link SoundTrigger.SoundModel}. Recognition must be restarted after each callback (success or failure) received on the {@link SoundTrigger.StatusListener}.

param
soundModelHandle The sound model handle to start listening to
param
config contains configuration information for this recognition request: recognition mode, keyphrases, users, minimum confidence levels...
return
- {@link SoundTrigger#STATUS_OK} in case of success - {@link SoundTrigger#STATUS_ERROR} in case of unspecified error - {@link SoundTrigger#STATUS_PERMISSION_DENIED} if the caller does not have system permission - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached - {@link SoundTrigger#STATUS_BAD_VALUE} if the sound model handle is invalid - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native service fails - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence

public native intstopRecognition(int soundModelHandle)
Stop listening to all key phrases in a {@link SoundTrigger.SoundModel}

param
soundModelHandle The sound model handle to stop listening to
return
- {@link SoundTrigger#STATUS_OK} in case of success - {@link SoundTrigger#STATUS_ERROR} in case of unspecified error - {@link SoundTrigger#STATUS_PERMISSION_DENIED} if the caller does not have system permission - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached - {@link SoundTrigger#STATUS_BAD_VALUE} if the sound model handle is invalid - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native service fails - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence

public native intunloadSoundModel(int soundModelHandle)
Unload a {@link SoundTrigger.SoundModel} and abort any pendiong recognition

param
soundModelHandle The sound model handle
return
- {@link SoundTrigger#STATUS_OK} in case of success - {@link SoundTrigger#STATUS_ERROR} in case of unspecified error - {@link SoundTrigger#STATUS_PERMISSION_DENIED} if the caller does not have system permission - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached - {@link SoundTrigger#STATUS_BAD_VALUE} if the sound model handle is invalid - {@link SoundTrigger#STATUS_DEAD_OBJECT} if the binder transaction to the native service fails