Merge "send SoundTriggerFailure when enrollment prempts session" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f639e3abf6
@@ -323,7 +323,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
|||||||
private final Executor mExternalExecutor;
|
private final Executor mExternalExecutor;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private final IBinder mBinder = new Binder();
|
private final IBinder mBinder = new Binder();
|
||||||
private final int mTargetSdkVersion;
|
|
||||||
private final boolean mSupportSandboxedDetectionService;
|
private final boolean mSupportSandboxedDetectionService;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@@ -866,7 +865,6 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
|||||||
new Handler(Looper.myLooper()));
|
new Handler(Looper.myLooper()));
|
||||||
mInternalCallback = new SoundTriggerListener(mHandler);
|
mInternalCallback = new SoundTriggerListener(mHandler);
|
||||||
mModelManagementService = modelManagementService;
|
mModelManagementService = modelManagementService;
|
||||||
mTargetSdkVersion = targetSdkVersion;
|
|
||||||
mSupportSandboxedDetectionService = supportSandboxedDetectionService;
|
mSupportSandboxedDetectionService = supportSandboxedDetectionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,6 +1390,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
// TODO(b/281608561): remove the enrollment flow from AlwaysOnHotwordDetector
|
||||||
void onSoundModelsChanged() {
|
void onSoundModelsChanged() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mAvailability == STATE_INVALID
|
if (mAvailability == STATE_INVALID
|
||||||
@@ -1411,14 +1410,28 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the recognition before proceeding.
|
// Stop the recognition before proceeding if we are in the enrolled state.
|
||||||
// This is done because we want to stop the recognition on an older model if it changed
|
// The framework makes the guarantee that an actively used model is present in the
|
||||||
// or was deleted.
|
// system server's enrollment database. For this reason we much stop an actively running
|
||||||
// The availability change callback should ensure that the client starts recognition
|
// model when the underlying sound model in enrollment database no longer match.
|
||||||
// again if needed.
|
|
||||||
if (mAvailability == STATE_KEYPHRASE_ENROLLED) {
|
if (mAvailability == STATE_KEYPHRASE_ENROLLED) {
|
||||||
|
// A SoundTriggerFailure will be sent to the client if the model state was
|
||||||
|
// changed. This is an overloading of the onFailure usage because we are sending a
|
||||||
|
// callback even in the successful stop case. If stopRecognition is successful,
|
||||||
|
// suggested next action RESTART_RECOGNITION will be sent.
|
||||||
|
// TODO(b/281608561): This code path will be removed with other enrollment flows in
|
||||||
|
// this class.
|
||||||
try {
|
try {
|
||||||
stopRecognitionLocked();
|
int result = stopRecognitionLocked();
|
||||||
|
if (result == STATUS_OK) {
|
||||||
|
sendSoundTriggerFailure(new SoundTriggerFailure(ERROR_CODE_UNKNOWN,
|
||||||
|
"stopped recognition because of enrollment update",
|
||||||
|
FailureSuggestedAction.RESTART_RECOGNITION));
|
||||||
|
}
|
||||||
|
// only log to logcat here because many failures can be false positives such as
|
||||||
|
// calling stopRecognition where there is no started session.
|
||||||
|
Log.w(TAG, "Failed to stop recognition after enrollment update: code="
|
||||||
|
+ result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slog.w(TAG, "Failed to stop recognition after enrollment update", e);
|
Slog.w(TAG, "Failed to stop recognition after enrollment update", e);
|
||||||
if (CompatChanges.isChangeEnabled(SEND_ON_FAILURE_FOR_ASYNC_EXCEPTIONS)) {
|
if (CompatChanges.isChangeEnabled(SEND_ON_FAILURE_FOR_ASYNC_EXCEPTIONS)) {
|
||||||
@@ -1608,6 +1621,7 @@ public class AlwaysOnHotwordDetector extends AbstractDetector {
|
|||||||
.build())
|
.build())
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenericSoundTriggerDetected(SoundTrigger.GenericRecognitionEvent event) {
|
public void onGenericSoundTriggerDetected(SoundTrigger.GenericRecognitionEvent event) {
|
||||||
Slog.w(TAG, "Generic sound trigger event detected at AOHD: " + event);
|
Slog.w(TAG, "Generic sound trigger event detected at AOHD: " + event);
|
||||||
|
|||||||
Reference in New Issue
Block a user