Fix synchronization issues in AlwaysOnHotwordDetector
- Remove unnecessary recognition status from AlwaysOnHotwordDetector
- Remove unnecessary recognition started callback from IRecognitionStatusCallback
- Fix a bug around the fact that we weren't picking up enrollment at runtime because
we were storing the availability at instantiation time.
- Handle 0-length arrays in SoundTrigger classes while parceling/unparceling
- Fix issue in SoundTrigger helper where we were not comparing binders for start/stop calls
- Unload the previous model when starting a new recognition
- Add more debug logging
Change-Id: Icc56d7f3dd1ffa49a8cfeea49080e3ab4d342c32
diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java
index 7b0a678..9a5cd9b 100644
--- a/core/java/android/hardware/soundtrigger/SoundTrigger.java
+++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java
@@ -247,7 +247,7 @@
String text = in.readString();
int[] users = null;
int numUsers = in.readInt();
- if (numUsers > 0) {
+ if (numUsers >= 0) {
users = new int[numUsers];
in.readIntArray(users);
}
@@ -264,7 +264,7 @@
dest.writeInt(users.length);
dest.writeIntArray(users);
} else {
- dest.writeInt(0);
+ dest.writeInt(-1);
}
}
@@ -349,7 +349,7 @@
UUID uuid = UUID.fromString(in.readString());
byte[] data = null;
int dataLength = in.readInt();
- if (dataLength > 0) {
+ if (dataLength >= 0) {
data = new byte[dataLength];
in.readByteArray(data);
}
@@ -369,10 +369,16 @@
dest.writeInt(data.length);
dest.writeByteArray(data);
} else {
- dest.writeInt(0);
+ dest.writeInt(-1);
}
dest.writeTypedArray(keyphrases, 0);
}
+
+ @Override
+ public String toString() {
+ return "KeyphraseSoundModel [keyphrases=" + Arrays.toString(keyphrases) + ", uuid="
+ + uuid + ", type=" + type + ", data? " + (data != null) + "]";
+ }
}
/**
@@ -471,7 +477,7 @@
in.createTypedArray(KeyphraseRecognitionExtra.CREATOR);
byte[] data = null;
int dataLength = in.readInt();
- if (dataLength > 0) {
+ if (dataLength >= 0) {
data = new byte[dataLength];
in.readByteArray(data);
}
@@ -486,7 +492,7 @@
dest.writeInt(data.length);
dest.writeByteArray(data);
} else {
- dest.writeInt(0);
+ dest.writeInt(-1);
}
}
@@ -494,6 +500,12 @@
public int describeContents() {
return 0;
}
+
+ @Override
+ public String toString() {
+ return "RecognitionConfig [captureRequested=" + captureRequested + ", keyphrases="
+ + Arrays.toString(keyphrases) + ", data? " + (data != null) + "]";
+ }
}
/**