Fix AlwaysOnHotwordDetector recognition event bug.
Parcelables don't work well with inheritance. So changed the
IRecognitionStatusCallback to have onKeyphraseDetected() and
onGenericSoundTriggerDetected() for those respective events.
Made corresponding changes to AlwaysOnHotwordDetector and SoundTriggerDetector.
Bug: 27250528
Change-Id: Ic08a431e7cc4248c688b05c865348170246de576
diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java
index 882908a..cc2b764 100644
--- a/core/java/android/hardware/soundtrigger/SoundTrigger.java
+++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java
@@ -595,7 +595,7 @@
}
};
- private static RecognitionEvent fromParcel(Parcel in) {
+ protected static RecognitionEvent fromParcel(Parcel in) {
int status = in.readInt();
int soundModelHandle = in.readInt();
boolean captureAvailable = in.readByte() == 1;
@@ -980,7 +980,7 @@
public static final Parcelable.Creator<KeyphraseRecognitionEvent> CREATOR
= new Parcelable.Creator<KeyphraseRecognitionEvent>() {
public KeyphraseRecognitionEvent createFromParcel(Parcel in) {
- return KeyphraseRecognitionEvent.fromParcel(in);
+ return KeyphraseRecognitionEvent.fromParcelForKeyphrase(in);
}
public KeyphraseRecognitionEvent[] newArray(int size) {
@@ -988,7 +988,7 @@
}
};
- private static KeyphraseRecognitionEvent fromParcel(Parcel in) {
+ private static KeyphraseRecognitionEvent fromParcelForKeyphrase(Parcel in) {
int status = in.readInt();
int soundModelHandle = in.readInt();
boolean captureAvailable = in.readByte() == 1;
@@ -1094,6 +1094,40 @@
captureDelayMs, capturePreambleMs, triggerInData, captureFormat,
data);
}
+
+ public static final Parcelable.Creator<GenericRecognitionEvent> CREATOR
+ = new Parcelable.Creator<GenericRecognitionEvent>() {
+ public GenericRecognitionEvent createFromParcel(Parcel in) {
+ return GenericRecognitionEvent.fromParcelForGeneric(in);
+ }
+
+ public GenericRecognitionEvent[] newArray(int size) {
+ return new GenericRecognitionEvent[size];
+ }
+ };
+
+ private static GenericRecognitionEvent fromParcelForGeneric(Parcel in) {
+ RecognitionEvent event = RecognitionEvent.fromParcel(in);
+ return new GenericRecognitionEvent(event.status, event.soundModelHandle,
+ event.captureAvailable, event.captureSession, event.captureDelayMs,
+ event.capturePreambleMs, event.triggerInData, event.captureFormat, event.data);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass()) return false;
+ RecognitionEvent other = (RecognitionEvent) obj;
+ return super.equals(obj);
+ }
+
+ @Override
+ public String toString() {
+ return "GenericRecognitionEvent ::" + super.toString();
+ }
}
/**