SoundTriggerHelpoer: Send pause events on abort if a model is running.

If the recognition was aborted due to the service state being set to
false, clients were not made aware that the model had been stopped (but
would get a resume event).

Bug: 30233664
Change-Id: I9f663362ff142eadfd5ef727c5f0c941f8e9e89d
This commit is contained in:
Chris Thornton
2016-07-19 18:56:15 -07:00
parent d71c64f715
commit d0a83b89a6

View File

@@ -696,8 +696,13 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
Slog.w(TAG, "Recognition aborted");
MetricsLogger.count(mContext, "sth_recognition_aborted", 1);
ModelData modelData = getModelDataForLocked(event.soundModelHandle);
if (modelData != null) {
if (modelData != null && modelData.isModelStarted()) {
modelData.setStopped();
try {
modelData.getCallback().onRecognitionPaused();
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException in onRecognitionPaused", e);
}
}
}