Loading core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl +24 −6 Original line number Diff line number Diff line Loading @@ -41,12 +41,6 @@ oneway interface IRecognitionStatusCallback { void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent); /** * Called when the detection fails due to an error. * * @param status The error code that was seen. */ void onError(int status); /** * Called when the recognition is paused temporarily for some reason. */ Loading @@ -55,4 +49,28 @@ oneway interface IRecognitionStatusCallback { * Called when the recognition is resumed after it was temporarily paused. */ void onRecognitionResumed(); // Error callbacks to follow /** * Called when this recognition has been preempted by another. */ void onPreempted(); /** * Called when the underlying ST module service has died. */ void onModuleDied(); /** * Called when the service failed to gracefully resume recognition following a pause. * @param status - The received error code. */ void onResumeFailed(int status); /** * Called when the service failed to pause recognition when required. * TODO(b/276507281) Remove. This should never happen, so we should abort instead. * @param status - The received error code. */ void onPauseFailed(int status); } core/java/android/service/voice/AlwaysOnHotwordDetector.java +6 −10 Original line number Diff line number Diff line Loading @@ -1572,16 +1572,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { Message.obtain(mHandler, MSG_HOTWORD_REJECTED, result).sendToTarget(); } @Override public void onError(int status) { Slog.i(TAG, "onError: " + status); // TODO(b/271534248): This is a workaround before the sound trigger uses the new error // method. Message.obtain(mHandler, MSG_DETECTION_SOUND_TRIGGER_FAILURE, new SoundTriggerFailure(SoundTriggerFailure.ERROR_CODE_UNKNOWN, "Sound trigger error")).sendToTarget(); } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) { Loading @@ -1604,6 +1594,12 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { "onVisualQueryDetectionServiceFailure: " + visualQueryDetectionServiceFailure); } @Override public void onSoundTriggerFailure(SoundTriggerFailure soundTriggerFailure) { Message.obtain(mHandler, MSG_DETECTION_SOUND_TRIGGER_FAILURE, Objects.requireNonNull(soundTriggerFailure)).sendToTarget(); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading core/java/android/service/voice/SoftwareHotwordDetector.java +7 −8 Original line number Diff line number Diff line Loading @@ -233,14 +233,6 @@ class SoftwareHotwordDetector extends AbstractDetector { } } @Override public void onError(int status) throws RemoteException { if (DEBUG) { Slog.i(TAG, "Ignored #onError (" + status + ") event"); } // TODO: Check if we still need to implement this method with DetectorFailure mechanism. } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) Loading @@ -264,6 +256,13 @@ class SoftwareHotwordDetector extends AbstractDetector { + visualQueryDetectionServiceFailure); } @Override public void onSoundTriggerFailure(SoundTriggerFailure onSoundTriggerFailure) throws RemoteException { // It should never be called here. Slog.wtf(TAG, "Unexpected STFailure in software detector: " + onSoundTriggerFailure); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading core/java/android/service/voice/SoundTriggerFailure.java +16 −5 Original line number Diff line number Diff line Loading @@ -73,18 +73,28 @@ public final class SoundTriggerFailure implements Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface SoundTriggerErrorCode {} private int mErrorCode = ERROR_CODE_UNKNOWN; private String mErrorMessage = "Unknown"; private final int mErrorCode; private final String mErrorMessage; /** * @hide */ @TestApi public SoundTriggerFailure(int errorCode, @NonNull String errorMessage) { public SoundTriggerFailure(@SoundTriggerErrorCode int errorCode, @NonNull String errorMessage) { if (TextUtils.isEmpty(errorMessage)) { throw new IllegalArgumentException("errorMessage is empty or null."); } switch (errorCode) { case ERROR_CODE_UNKNOWN: case ERROR_CODE_MODULE_DIED: case ERROR_CODE_RECOGNITION_RESUME_FAILED: case ERROR_CODE_UNEXPECTED_PREEMPTION: mErrorCode = errorCode; break; default: throw new IllegalArgumentException("Invalid ErrorCode: " + errorCode); } mErrorMessage = errorMessage; } Loading @@ -110,13 +120,14 @@ public final class SoundTriggerFailure implements Parcelable { @FailureSuggestedAction.FailureSuggestedActionDef public int getSuggestedAction() { switch (mErrorCode) { case ERROR_CODE_UNKNOWN: case ERROR_CODE_MODULE_DIED: case ERROR_CODE_UNEXPECTED_PREEMPTION: return FailureSuggestedAction.RECREATE_DETECTOR; case ERROR_CODE_RECOGNITION_RESUME_FAILED: return FailureSuggestedAction.RESTART_RECOGNITION; default: return FailureSuggestedAction.NONE; throw new AssertionError("Unexpected error code"); } } Loading core/java/android/service/voice/VisualQueryDetector.java +5 −6 Original line number Diff line number Diff line Loading @@ -390,12 +390,6 @@ public class VisualQueryDetector { () -> mCallback.onVisualQueryDetectionServiceRestarted())); } @Override public void onError(int status) throws RemoteException { Slog.v(TAG, "Initialization Error: (" + status + ")"); // Do nothing } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) Loading @@ -419,6 +413,11 @@ public class VisualQueryDetector { })); } @Override public void onSoundTriggerFailure(SoundTriggerFailure soundTriggerFailure) { Slog.wtf(TAG, "Unexpected STFailure in VisualQueryDetector" + soundTriggerFailure); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading Loading
core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl +24 −6 Original line number Diff line number Diff line Loading @@ -41,12 +41,6 @@ oneway interface IRecognitionStatusCallback { void onGenericSoundTriggerDetected(in SoundTrigger.GenericRecognitionEvent recognitionEvent); /** * Called when the detection fails due to an error. * * @param status The error code that was seen. */ void onError(int status); /** * Called when the recognition is paused temporarily for some reason. */ Loading @@ -55,4 +49,28 @@ oneway interface IRecognitionStatusCallback { * Called when the recognition is resumed after it was temporarily paused. */ void onRecognitionResumed(); // Error callbacks to follow /** * Called when this recognition has been preempted by another. */ void onPreempted(); /** * Called when the underlying ST module service has died. */ void onModuleDied(); /** * Called when the service failed to gracefully resume recognition following a pause. * @param status - The received error code. */ void onResumeFailed(int status); /** * Called when the service failed to pause recognition when required. * TODO(b/276507281) Remove. This should never happen, so we should abort instead. * @param status - The received error code. */ void onPauseFailed(int status); }
core/java/android/service/voice/AlwaysOnHotwordDetector.java +6 −10 Original line number Diff line number Diff line Loading @@ -1572,16 +1572,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { Message.obtain(mHandler, MSG_HOTWORD_REJECTED, result).sendToTarget(); } @Override public void onError(int status) { Slog.i(TAG, "onError: " + status); // TODO(b/271534248): This is a workaround before the sound trigger uses the new error // method. Message.obtain(mHandler, MSG_DETECTION_SOUND_TRIGGER_FAILURE, new SoundTriggerFailure(SoundTriggerFailure.ERROR_CODE_UNKNOWN, "Sound trigger error")).sendToTarget(); } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) { Loading @@ -1604,6 +1594,12 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { "onVisualQueryDetectionServiceFailure: " + visualQueryDetectionServiceFailure); } @Override public void onSoundTriggerFailure(SoundTriggerFailure soundTriggerFailure) { Message.obtain(mHandler, MSG_DETECTION_SOUND_TRIGGER_FAILURE, Objects.requireNonNull(soundTriggerFailure)).sendToTarget(); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading
core/java/android/service/voice/SoftwareHotwordDetector.java +7 −8 Original line number Diff line number Diff line Loading @@ -233,14 +233,6 @@ class SoftwareHotwordDetector extends AbstractDetector { } } @Override public void onError(int status) throws RemoteException { if (DEBUG) { Slog.i(TAG, "Ignored #onError (" + status + ") event"); } // TODO: Check if we still need to implement this method with DetectorFailure mechanism. } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) Loading @@ -264,6 +256,13 @@ class SoftwareHotwordDetector extends AbstractDetector { + visualQueryDetectionServiceFailure); } @Override public void onSoundTriggerFailure(SoundTriggerFailure onSoundTriggerFailure) throws RemoteException { // It should never be called here. Slog.wtf(TAG, "Unexpected STFailure in software detector: " + onSoundTriggerFailure); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading
core/java/android/service/voice/SoundTriggerFailure.java +16 −5 Original line number Diff line number Diff line Loading @@ -73,18 +73,28 @@ public final class SoundTriggerFailure implements Parcelable { @Retention(RetentionPolicy.SOURCE) public @interface SoundTriggerErrorCode {} private int mErrorCode = ERROR_CODE_UNKNOWN; private String mErrorMessage = "Unknown"; private final int mErrorCode; private final String mErrorMessage; /** * @hide */ @TestApi public SoundTriggerFailure(int errorCode, @NonNull String errorMessage) { public SoundTriggerFailure(@SoundTriggerErrorCode int errorCode, @NonNull String errorMessage) { if (TextUtils.isEmpty(errorMessage)) { throw new IllegalArgumentException("errorMessage is empty or null."); } switch (errorCode) { case ERROR_CODE_UNKNOWN: case ERROR_CODE_MODULE_DIED: case ERROR_CODE_RECOGNITION_RESUME_FAILED: case ERROR_CODE_UNEXPECTED_PREEMPTION: mErrorCode = errorCode; break; default: throw new IllegalArgumentException("Invalid ErrorCode: " + errorCode); } mErrorMessage = errorMessage; } Loading @@ -110,13 +120,14 @@ public final class SoundTriggerFailure implements Parcelable { @FailureSuggestedAction.FailureSuggestedActionDef public int getSuggestedAction() { switch (mErrorCode) { case ERROR_CODE_UNKNOWN: case ERROR_CODE_MODULE_DIED: case ERROR_CODE_UNEXPECTED_PREEMPTION: return FailureSuggestedAction.RECREATE_DETECTOR; case ERROR_CODE_RECOGNITION_RESUME_FAILED: return FailureSuggestedAction.RESTART_RECOGNITION; default: return FailureSuggestedAction.NONE; throw new AssertionError("Unexpected error code"); } } Loading
core/java/android/service/voice/VisualQueryDetector.java +5 −6 Original line number Diff line number Diff line Loading @@ -390,12 +390,6 @@ public class VisualQueryDetector { () -> mCallback.onVisualQueryDetectionServiceRestarted())); } @Override public void onError(int status) throws RemoteException { Slog.v(TAG, "Initialization Error: (" + status + ")"); // Do nothing } @Override public void onHotwordDetectionServiceFailure( HotwordDetectionServiceFailure hotwordDetectionServiceFailure) Loading @@ -419,6 +413,11 @@ public class VisualQueryDetector { })); } @Override public void onSoundTriggerFailure(SoundTriggerFailure soundTriggerFailure) { Slog.wtf(TAG, "Unexpected STFailure in VisualQueryDetector" + soundTriggerFailure); } @Override public void onUnknownFailure(String errorMessage) throws RemoteException { Slog.v(TAG, "onUnknownFailure: " + errorMessage); Loading