Add getData() member to SoundTriggerDetector.EventPayload.
If the HAL populates the recognition event with data that isn't trigger
audio, it's currently impossible for clients to actually read that
opaque data. By adding this getter, clients who understand how the
detection engine works can react to whatever is in the data blob.
Test: Modify SoundTriggerTestApp to verify that the data is accessible.
Change-Id: I8a9feccab98e2d15653dd55f28a43095f8ee1e44
diff --git a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java
index b550cfa..00bf33a 100644
--- a/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java
+++ b/tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java
@@ -689,8 +689,20 @@
AudioFormat format = event.getCaptureAudioFormat();
result = result + "AudioFormat: " + ((format == null) ? "null" : format.toString());
byte[] triggerAudio = event.getTriggerAudio();
- result = result + "TriggerAudio: " + (triggerAudio == null ? "null" : triggerAudio.length);
- result = result + "CaptureSession: " + event.getCaptureSession();
+ result = result + ", TriggerAudio: " + (triggerAudio == null ? "null" : triggerAudio.length);
+ byte[] data = event.getData();
+ result = result + ", Data: " + (data == null ? "null" : data.length);
+ if (data != null) {
+ try {
+ String decodedData = new String(data, "UTF-8");
+ if (decodedData.chars().allMatch(c -> (c >= 32 && c < 128) || c == 0)) {
+ result = result + ", Decoded Data: '" + decodedData + "'";
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to decode data");
+ }
+ }
+ result = result + ", CaptureSession: " + event.getCaptureSession();
result += " )";
return result;
}