Revert "Generate an abort event when stopping"
This reverts commit 3b660525f3.
This commit causes deadlocks.
Bug: 236826280
Fixes: 274993071
Test: CtsVoiceInteractionTestCases
Test: CtsSoundTriggerTestCases
Test: Manual verification
Change-Id: Ie170e0a2572aae051acc6ec325b5b39afaf761de
This commit is contained in:
@@ -225,13 +225,6 @@ public class SoundTriggerMiddlewareImplTest {
|
|||||||
// Stop the recognition.
|
// Stop the recognition.
|
||||||
stopRecognition(module, handle, hwHandle);
|
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.
|
// Unload the model.
|
||||||
unloadModel(module, handle, hwHandle);
|
unloadModel(module, handle, hwHandle);
|
||||||
module.detach();
|
module.detach();
|
||||||
@@ -276,13 +269,6 @@ public class SoundTriggerMiddlewareImplTest {
|
|||||||
// Stop the recognition.
|
// Stop the recognition.
|
||||||
stopRecognition(module, handle, hwHandle);
|
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.
|
// Unload the model.
|
||||||
unloadModel(module, handle, hwHandle);
|
unloadModel(module, handle, hwHandle);
|
||||||
module.detach();
|
module.detach();
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.media.soundtrigger.PhraseSoundModel;
|
|||||||
import android.media.soundtrigger.Properties;
|
import android.media.soundtrigger.Properties;
|
||||||
import android.media.soundtrigger.RecognitionConfig;
|
import android.media.soundtrigger.RecognitionConfig;
|
||||||
import android.media.soundtrigger.SoundModel;
|
import android.media.soundtrigger.SoundModel;
|
||||||
import android.media.soundtrigger.SoundModelType;
|
|
||||||
import android.media.soundtrigger.Status;
|
import android.media.soundtrigger.Status;
|
||||||
import android.media.soundtrigger_middleware.ISoundTriggerCallback;
|
import android.media.soundtrigger_middleware.ISoundTriggerCallback;
|
||||||
import android.media.soundtrigger_middleware.ISoundTriggerModule;
|
import android.media.soundtrigger_middleware.ISoundTriggerModule;
|
||||||
@@ -385,7 +384,6 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
|||||||
private class Model implements ISoundTriggerHal.ModelCallback {
|
private class Model implements ISoundTriggerHal.ModelCallback {
|
||||||
public int mHandle;
|
public int mHandle;
|
||||||
private ModelState mState = ModelState.INIT;
|
private ModelState mState = ModelState.INIT;
|
||||||
private int mType = SoundModelType.INVALID;
|
|
||||||
private SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession mSession;
|
private SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession mSession;
|
||||||
|
|
||||||
private @NonNull
|
private @NonNull
|
||||||
@@ -402,7 +400,6 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
|||||||
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
|
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
|
||||||
mSession = audioSession;
|
mSession = audioSession;
|
||||||
mHandle = mHalService.loadSoundModel(model, this);
|
mHandle = mHalService.loadSoundModel(model, this);
|
||||||
mType = SoundModelType.GENERIC;
|
|
||||||
setState(ModelState.LOADED);
|
setState(ModelState.LOADED);
|
||||||
mLoadedModels.put(mHandle, this);
|
mLoadedModels.put(mHandle, this);
|
||||||
return mHandle;
|
return mHandle;
|
||||||
@@ -412,7 +409,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
|||||||
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
|
SoundTriggerMiddlewareImpl.AudioSessionProvider.AudioSession audioSession) {
|
||||||
mSession = audioSession;
|
mSession = audioSession;
|
||||||
mHandle = mHalService.loadPhraseSoundModel(model, this);
|
mHandle = mHalService.loadPhraseSoundModel(model, this);
|
||||||
mType = SoundModelType.KEYPHRASE;
|
|
||||||
setState(ModelState.LOADED);
|
setState(ModelState.LOADED);
|
||||||
mLoadedModels.put(mHandle, this);
|
mLoadedModels.put(mHandle, this);
|
||||||
return mHandle;
|
return mHandle;
|
||||||
@@ -441,34 +438,9 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This must be invoked outside the lock.
|
|
||||||
mHalService.stopRecognition(mHandle);
|
mHalService.stopRecognition(mHandle);
|
||||||
|
|
||||||
// No more callbacks for this model after this point.
|
|
||||||
synchronized (SoundTriggerModule.this) {
|
synchronized (SoundTriggerModule.this) {
|
||||||
// Generate an abortion callback to the client if the model is still active.
|
setState(ModelState.LOADED);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,5 +531,4 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user