Loading core/java/android/service/voice/SoftwareHotwordDetector.java +56 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainMessa import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.RequiresPermission; import android.hardware.soundtrigger.SoundTrigger; import android.media.AudioFormat; import android.media.AudioFormat; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; Loading @@ -31,6 +32,7 @@ import android.os.RemoteException; import android.os.SharedMemory; import android.os.SharedMemory; import android.util.Slog; import android.util.Slog; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVoiceInteractionManagerService; import com.android.internal.app.IVoiceInteractionManagerService; import java.io.PrintWriter; import java.io.PrintWriter; Loading Loading @@ -64,7 +66,8 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { mAudioFormat = audioFormat; mAudioFormat = audioFormat; mCallback = callback; mCallback = callback; mHandler = new Handler(Looper.getMainLooper()); mHandler = new Handler(Looper.getMainLooper()); updateStateLocked(options, sharedMemory, null /* callback */); updateStateLocked(options, sharedMemory, new InitializationStateListener(mHandler, mCallback)); } } @RequiresPermission(RECORD_AUDIO) @RequiresPermission(RECORD_AUDIO) Loading Loading @@ -133,6 +136,58 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { } } } } private static class InitializationStateListener extends IHotwordRecognitionStatusCallback.Stub { private final Handler mHandler; private final HotwordDetector.Callback mCallback; InitializationStateListener(Handler handler, HotwordDetector.Callback callback) { this.mHandler = handler; this.mCallback = callback; } @Override public void onKeyphraseDetected(SoundTrigger.KeyphraseRecognitionEvent recognitionEvent) throws RemoteException { } @Override public void onGenericSoundTriggerDetected( SoundTrigger.GenericRecognitionEvent recognitionEvent) throws RemoteException { } @Override public void onRejected(HotwordRejectedResult result) throws RemoteException { } @Override public void onError(int status) throws RemoteException { } @Override public void onRecognitionPaused() throws RemoteException { } @Override public void onRecognitionResumed() throws RemoteException { } @Override public void onStatusReported(int status) { Slog.v(TAG, "onStatusReported" + (DEBUG ? "(" + status + ")" : "")); mHandler.sendMessage(obtainMessage( HotwordDetector.Callback::onHotwordDetectionServiceInitialized, mCallback, status)); } } /** @hide */ /** @hide */ public void dump(String prefix, PrintWriter pw) { public void dump(String prefix, PrintWriter pw) { // TODO: implement this // TODO: implement this Loading Loading
core/java/android/service/voice/SoftwareHotwordDetector.java +56 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainMessa import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.RequiresPermission; import android.hardware.soundtrigger.SoundTrigger; import android.media.AudioFormat; import android.media.AudioFormat; import android.os.Handler; import android.os.Handler; import android.os.Looper; import android.os.Looper; Loading @@ -31,6 +32,7 @@ import android.os.RemoteException; import android.os.SharedMemory; import android.os.SharedMemory; import android.util.Slog; import android.util.Slog; import com.android.internal.app.IHotwordRecognitionStatusCallback; import com.android.internal.app.IVoiceInteractionManagerService; import com.android.internal.app.IVoiceInteractionManagerService; import java.io.PrintWriter; import java.io.PrintWriter; Loading Loading @@ -64,7 +66,8 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { mAudioFormat = audioFormat; mAudioFormat = audioFormat; mCallback = callback; mCallback = callback; mHandler = new Handler(Looper.getMainLooper()); mHandler = new Handler(Looper.getMainLooper()); updateStateLocked(options, sharedMemory, null /* callback */); updateStateLocked(options, sharedMemory, new InitializationStateListener(mHandler, mCallback)); } } @RequiresPermission(RECORD_AUDIO) @RequiresPermission(RECORD_AUDIO) Loading Loading @@ -133,6 +136,58 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { } } } } private static class InitializationStateListener extends IHotwordRecognitionStatusCallback.Stub { private final Handler mHandler; private final HotwordDetector.Callback mCallback; InitializationStateListener(Handler handler, HotwordDetector.Callback callback) { this.mHandler = handler; this.mCallback = callback; } @Override public void onKeyphraseDetected(SoundTrigger.KeyphraseRecognitionEvent recognitionEvent) throws RemoteException { } @Override public void onGenericSoundTriggerDetected( SoundTrigger.GenericRecognitionEvent recognitionEvent) throws RemoteException { } @Override public void onRejected(HotwordRejectedResult result) throws RemoteException { } @Override public void onError(int status) throws RemoteException { } @Override public void onRecognitionPaused() throws RemoteException { } @Override public void onRecognitionResumed() throws RemoteException { } @Override public void onStatusReported(int status) { Slog.v(TAG, "onStatusReported" + (DEBUG ? "(" + status + ")" : "")); mHandler.sendMessage(obtainMessage( HotwordDetector.Callback::onHotwordDetectionServiceInitialized, mCallback, status)); } } /** @hide */ /** @hide */ public void dump(String prefix, PrintWriter pw) { public void dump(String prefix, PrintWriter pw) { // TODO: implement this // TODO: implement this Loading