summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Thornton <thorntonc@google.com> 2016-07-11 22:03:16 -0700
committer Chris Thornton <thorntonc@google.com> 2016-07-11 22:03:16 -0700
commit4ef887457af1bdece916e092a806a448f03e2f3e (patch)
tree259396d8c235a18f1b386f760f0c073fcef9248d
parentbb6f52d06bcfb21ed25b3acb8aae6240a81eacf0 (diff)
SoundTriggerDetector should look at the return code to honour success
The SoundTriggerDetector calls to start/stop recognition should also check what the return code from the SoundTriggerService are saying - otherwise it looks like recognition has started when there's been a problem. Change-Id: Icd6d2ab5ec30a5ffe66082311a77cca376a37148
-rw-r--r--media/java/android/media/soundtrigger/SoundTriggerDetector.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/media/java/android/media/soundtrigger/SoundTriggerDetector.java b/media/java/android/media/soundtrigger/SoundTriggerDetector.java
index df0961bd17d4..d5296ae42031 100644
--- a/media/java/android/media/soundtrigger/SoundTriggerDetector.java
+++ b/media/java/android/media/soundtrigger/SoundTriggerDetector.java
@@ -15,6 +15,7 @@
*/
package android.media.soundtrigger;
+import static android.hardware.soundtrigger.SoundTrigger.STATUS_OK;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -243,27 +244,29 @@ public final class SoundTriggerDetector {
boolean allowMultipleTriggers =
(recognitionFlags & RECOGNITION_FLAG_ALLOW_MULTIPLE_TRIGGERS) != 0;
+ int status = STATUS_OK;
try {
- mSoundTriggerService.startRecognition(new ParcelUuid(mSoundModelId),
+ status = mSoundTriggerService.startRecognition(new ParcelUuid(mSoundModelId),
mRecognitionCallback, new RecognitionConfig(captureTriggerAudio,
allowMultipleTriggers, null, null));
} catch (RemoteException e) {
return false;
}
- return true;
+ return status == STATUS_OK;
}
/**
* Stops recognition for the associated model.
*/
public boolean stopRecognition() {
+ int status = STATUS_OK;
try {
- mSoundTriggerService.stopRecognition(new ParcelUuid(mSoundModelId),
+ status = mSoundTriggerService.stopRecognition(new ParcelUuid(mSoundModelId),
mRecognitionCallback);
} catch (RemoteException e) {
return false;
}
- return true;
+ return status == STATUS_OK;
}
/**