diff options
author | Sandeep Siddhartha <sansid@google.com> | 2014-07-28 13:25:30 -0700 |
---|---|---|
committer | Sandeep Siddhartha <sansid@google.com> | 2014-07-29 11:24:51 -0700 |
commit | 6817337118655d5792e36e954b123e6daa4174a6 (patch) | |
tree | bacd4155507f64d701c3c7a3e4fa70da89d7d658 /core/java/android/hardware | |
parent | 94703148bc522b9f3fab9257fd07021e678d43f2 (diff) | |
download | frameworks_base-6817337118655d5792e36e954b123e6daa4174a6.zip frameworks_base-6817337118655d5792e36e954b123e6daa4174a6.tar.gz frameworks_base-6817337118655d5792e36e954b123e6daa4174a6.tar.bz2 |
Read the keyphrase ID from the recognition event
Bug: 16516658
Change-Id: Ibeee81c9543aa1091bb075066cfc2269107f13c0
Diffstat (limited to 'core/java/android/hardware')
3 files changed, 163 insertions, 10 deletions
diff --git a/core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl b/core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl index 0bf4f25..b1a02c1 100644 --- a/core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl +++ b/core/java/android/hardware/soundtrigger/IRecognitionStatusCallback.aidl @@ -26,10 +26,8 @@ oneway interface IRecognitionStatusCallback { * Called when the keyphrase is spoken. * * @param data Optional trigger audio data, if it was requested and is available. - * TODO: See if the data being passed in works well, if not use shared memory. - * This *MUST* not exceed 100K. */ - void onDetected(in SoundTrigger.RecognitionEvent recognitionEvent); + void onDetected(in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent); /** * Called when the detection for the associated keyphrase stops. */ diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.aidl b/core/java/android/hardware/soundtrigger/SoundTrigger.aidl index 9adc6bc..e16ea71 100644 --- a/core/java/android/hardware/soundtrigger/SoundTrigger.aidl +++ b/core/java/android/hardware/soundtrigger/SoundTrigger.aidl @@ -18,8 +18,8 @@ package android.hardware.soundtrigger; parcelable SoundTrigger.ConfidenceLevel; parcelable SoundTrigger.Keyphrase; +parcelable SoundTrigger.KeyphraseRecognitionEvent; parcelable SoundTrigger.KeyphraseRecognitionExtra; parcelable SoundTrigger.KeyphraseSoundModel; parcelable SoundTrigger.ModuleProperties; parcelable SoundTrigger.RecognitionConfig; -parcelable SoundTrigger.RecognitionEvent;
\ No newline at end of file diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java index 3e84368..4498789 100644 --- a/core/java/android/hardware/soundtrigger/SoundTrigger.java +++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java @@ -361,13 +361,13 @@ public class SoundTrigger { public void writeToParcel(Parcel dest, int flags) { dest.writeString(uuid.toString()); dest.writeBlob(data); - dest.writeTypedArray(keyphrases, 0); + dest.writeTypedArray(keyphrases, flags); } @Override public String toString() { return "KeyphraseSoundModel [keyphrases=" + Arrays.toString(keyphrases) + ", uuid=" - + uuid + ", type=" + type + ", data? " + (data != null) + "]"; + + uuid + ", type=" + type + ", data=" + (data == null ? 0 : data.length) + "]"; } } @@ -504,6 +504,15 @@ public class SoundTrigger { return false; return true; } + + @Override + public String toString() { + return "RecognitionEvent [status=" + status + ", soundModelHandle=" + soundModelHandle + + ", captureAvailable=" + captureAvailable + ", captureSession=" + + captureSession + ", captureDelayMs=" + captureDelayMs + + ", capturePreambleMs=" + capturePreambleMs + + ", data=" + (data == null ? 0 : data.length) + "]"; + } } /** @@ -551,7 +560,7 @@ public class SoundTrigger { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeByte((byte) (captureRequested ? 1 : 0)); - dest.writeTypedArray(keyphrases, 0); + dest.writeTypedArray(keyphrases, flags); dest.writeBlob(data); } @@ -563,7 +572,8 @@ public class SoundTrigger { @Override public String toString() { return "RecognitionConfig [captureRequested=" + captureRequested + ", keyphrases=" - + Arrays.toString(keyphrases) + ", data? " + (data != null) + "]"; + + Arrays.toString(keyphrases) + + ", data=" + (data == null ? 0 : data.length) + "]"; } } @@ -611,6 +621,37 @@ public class SoundTrigger { public int describeContents() { return 0; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + confidenceLevel; + result = prime * result + userId; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ConfidenceLevel other = (ConfidenceLevel) obj; + if (confidenceLevel != other.confidenceLevel) + return false; + if (userId != other.userId) + return false; + return true; + } + + @Override + public String toString() { + return "ConfidenceLevel [userId=" + userId + + ", confidenceLevel=" + confidenceLevel + "]"; + } } /** @@ -657,13 +698,47 @@ public class SoundTrigger { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(id); dest.writeInt(recognitionModes); - dest.writeTypedArray(confidenceLevels, 0); + dest.writeTypedArray(confidenceLevels, flags); } @Override public int describeContents() { return 0; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(confidenceLevels); + result = prime * result + id; + result = prime * result + recognitionModes; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + KeyphraseRecognitionExtra other = (KeyphraseRecognitionExtra) obj; + if (!Arrays.equals(confidenceLevels, other.confidenceLevels)) + return false; + if (id != other.id) + return false; + if (recognitionModes != other.recognitionModes) + return false; + return true; + } + + @Override + public String toString() { + return "KeyphraseRecognitionExtra [id=" + id + ", recognitionModes=" + recognitionModes + + ", confidenceLevels=" + Arrays.toString(confidenceLevels) + "]"; + } } /** @@ -676,7 +751,7 @@ public class SoundTrigger { /** Additional data available for each recognized key phrases in the model */ public final boolean keyphraseInCapture; - KeyphraseRecognitionEvent(int status, int soundModelHandle, boolean captureAvailable, + public KeyphraseRecognitionEvent(int status, int soundModelHandle, boolean captureAvailable, int captureSession, int captureDelayMs, int capturePreambleMs, byte[] data, boolean keyphraseInCapture, KeyphraseRecognitionExtra[] keyphraseExtras) { super(status, soundModelHandle, captureAvailable, captureSession, captureDelayMs, @@ -684,6 +759,86 @@ public class SoundTrigger { this.keyphraseInCapture = keyphraseInCapture; this.keyphraseExtras = keyphraseExtras; } + + public static final Parcelable.Creator<KeyphraseRecognitionEvent> CREATOR + = new Parcelable.Creator<KeyphraseRecognitionEvent>() { + public KeyphraseRecognitionEvent createFromParcel(Parcel in) { + return KeyphraseRecognitionEvent.fromParcel(in); + } + + public KeyphraseRecognitionEvent[] newArray(int size) { + return new KeyphraseRecognitionEvent[size]; + } + }; + + private static KeyphraseRecognitionEvent fromParcel(Parcel in) { + int status = in.readInt(); + int soundModelHandle = in.readInt(); + boolean captureAvailable = in.readByte() == 1; + int captureSession = in.readInt(); + int captureDelayMs = in.readInt(); + int capturePreambleMs = in.readInt(); + byte[] data = in.readBlob(); + boolean keyphraseInCapture = in.readByte() == 1; + KeyphraseRecognitionExtra[] keyphraseExtras = + in.createTypedArray(KeyphraseRecognitionExtra.CREATOR); + return new KeyphraseRecognitionEvent(status, soundModelHandle, captureAvailable, + captureSession, captureDelayMs, capturePreambleMs, data, keyphraseInCapture, + keyphraseExtras); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(status); + dest.writeInt(soundModelHandle); + dest.writeByte((byte) (captureAvailable ? 1 : 0)); + dest.writeInt(captureSession); + dest.writeInt(captureDelayMs); + dest.writeInt(capturePreambleMs); + dest.writeBlob(data); + dest.writeByte((byte) (keyphraseInCapture ? 1 : 0)); + dest.writeTypedArray(keyphraseExtras, flags); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Arrays.hashCode(keyphraseExtras); + result = prime * result + (keyphraseInCapture ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + KeyphraseRecognitionEvent other = (KeyphraseRecognitionEvent) obj; + if (!Arrays.equals(keyphraseExtras, other.keyphraseExtras)) + return false; + if (keyphraseInCapture != other.keyphraseInCapture) + return false; + return true; + } + + @Override + public String toString() { + return "KeyphraseRecognitionEvent [keyphraseExtras=" + Arrays.toString(keyphraseExtras) + + ", keyphraseInCapture=" + keyphraseInCapture + ", status=" + status + + ", soundModelHandle=" + soundModelHandle + ", captureAvailable=" + + captureAvailable + ", captureSession=" + captureSession + ", captureDelayMs=" + + captureDelayMs + ", capturePreambleMs=" + capturePreambleMs + + ", data=" + (data == null ? 0 : data.length) + "]"; + } } /** |