Revert "Generate an abort event when stopping" am: c4a891c6bc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22787398

Change-Id: Iae2126fc4d872b0c7a137237f3b856f9397e16b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Atneya Nair
2023-05-04 23:45:56 +00:00
committed by Automerger Merge Worker
2 changed files with 2 additions and 45 deletions

View File

@@ -225,13 +225,6 @@ public class SoundTriggerMiddlewareImplTest {
// Stop the recognition.
stopRecognition(module, handle, hwHandle);
ArgumentCaptor<RecognitionEventSys> eventCaptor = ArgumentCaptor.forClass(
RecognitionEventSys.class);
verify(callback).onRecognition(eq(handle), eventCaptor.capture(), eq(101));
RecognitionEventSys lastEvent = eventCaptor.getValue();
assertEquals(-1, lastEvent.halEventReceivedMillis);
assertEquals(RecognitionStatus.ABORTED, lastEvent.recognitionEvent.status);
// Unload the model.
unloadModel(module, handle, hwHandle);
module.detach();
@@ -276,13 +269,6 @@ public class SoundTriggerMiddlewareImplTest {
// Stop the recognition.
stopRecognition(module, handle, hwHandle);
ArgumentCaptor<PhraseRecognitionEventSys> eventCaptor = ArgumentCaptor.forClass(
PhraseRecognitionEventSys.class);
verify(callback).onPhraseRecognition(eq(handle), eventCaptor.capture(), eq(101));
PhraseRecognitionEventSys lastEvent = eventCaptor.getValue();
assertEquals(-1, lastEvent.halEventReceivedMillis);
assertEquals(RecognitionStatus.ABORTED, lastEvent.phraseRecognitionEvent.common.status);
// Unload the model.
unloadModel(module, handle, hwHandle);
module.detach();

View File

@@ -23,7 +23,6 @@ import android.media.soundtrigger.PhraseSoundModel;
import android.media.soundtrigger.Properties;
import android.media.soundtrigger.RecognitionConfig;
import android.media.soundtrigger.SoundModel;
import android.media.soundtrigger.SoundModelType;
import android.media.soundtrigger.Status;
import android.media.soundtrigger_middleware.ISoundTriggerCallback;
import android.media.soundtrigger_middleware.ISoundTriggerModule;
@@ -385,7 +384,6 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
private class Model implements ISoundTriggerHal.ModelCallback {
public int mHandle;
private ModelState mState = ModelState.INIT;
private int mType = SoundModelType.INVALID;
private SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession mSession;
private @NonNull
@@ -402,7 +400,6 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
mSession = audioSession;
mHandle = mHalService.loadSoundModel(model, this);
mType = SoundModelType.GENERIC;
setState(ModelState.LOADED);
mLoadedModels.put(mHandle, this);
return mHandle;
@@ -412,7 +409,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
mSession = audioSession;
mHandle = mHalService.loadPhraseSoundModel(model, this);
mType = SoundModelType.KEYPHRASE;
setState(ModelState.LOADED);
mLoadedModels.put(mHandle, this);
return mHandle;
@@ -441,34 +438,9 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
return;
}
}
// This must be invoked outside the lock.
mHalService.stopRecognition(mHandle);
// No more callbacks for this model after this point.
synchronized (SoundTriggerModule.this) {
// Generate an abortion callback to the client if the model is still active.
if (getState() == ModelState.ACTIVE) {
if (mCallback != null) {
try {
switch (mType) {
case SoundModelType.GENERIC:
mCallback.onRecognition(mHandle, AidlUtil.newAbortEvent(),
mSession.mSessionHandle);
break;
case SoundModelType.KEYPHRASE:
mCallback.onPhraseRecognition(mHandle,
AidlUtil.newAbortPhraseEvent(),
mSession.mSessionHandle);
break;
default:
throw new RuntimeException(
"Unexpected model type: " + mType);
}
} catch (RemoteException e) {
}
}
setState(ModelState.LOADED);
}
setState(ModelState.LOADED);
}
}
@@ -559,5 +531,4 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
}
}
}
}