Loading media/java/android/media/soundtrigger/SoundTriggerDetector.java +19 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ public final class SoundTriggerDetector { } /** * Gets the raw audio that triggered the keyphrase. * Gets the raw audio that triggered the detector. * This may be null if the trigger audio isn't available. * If non-null, the format of the audio can be obtained by calling * {@link #getCaptureAudioFormat()}. Loading @@ -153,6 +153,24 @@ public final class SoundTriggerDetector { } } /** * Gets the opaque data passed from the detection engine for the event. * This may be null if it was not populated by the engine, or if the data is known to * contain the trigger audio. * * @see #getTriggerAudio * * @hide */ @Nullable public byte[] getData() { if (!mTriggerAvailable) { return mData; } else { return null; } } /** * Gets the session ID to start a capture from the DSP. * This may be null if streaming capture isn't possible. Loading tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java +14 −2 Original line number Diff line number Diff line Loading @@ -689,8 +689,20 @@ public class SoundTriggerTestService extends Service { 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; } Loading Loading
media/java/android/media/soundtrigger/SoundTriggerDetector.java +19 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ public final class SoundTriggerDetector { } /** * Gets the raw audio that triggered the keyphrase. * Gets the raw audio that triggered the detector. * This may be null if the trigger audio isn't available. * If non-null, the format of the audio can be obtained by calling * {@link #getCaptureAudioFormat()}. Loading @@ -153,6 +153,24 @@ public final class SoundTriggerDetector { } } /** * Gets the opaque data passed from the detection engine for the event. * This may be null if it was not populated by the engine, or if the data is known to * contain the trigger audio. * * @see #getTriggerAudio * * @hide */ @Nullable public byte[] getData() { if (!mTriggerAvailable) { return mData; } else { return null; } } /** * Gets the session ID to start a capture from the DSP. * This may be null if streaming capture isn't possible. Loading
tests/SoundTriggerTestApp/src/com/android/test/soundtrigger/SoundTriggerTestService.java +14 −2 Original line number Diff line number Diff line Loading @@ -689,8 +689,20 @@ public class SoundTriggerTestService extends Service { 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; } Loading