catch stopRecognition exceptions in destroy()

Ignore any exceptions coming out of the HotwordDetector#destroy()
method when stopRecognition is called. The stopRecognition call here is
a best effort call which should not be retried if it fails.

Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionHostTestCases
Bug: 193232191
Change-Id: Ie4f8e68ca9078dca0e30fe73408947a2525c5b9a
This commit is contained in:
Nicholas Ambur
2022-03-06 23:05:50 -08:00
parent 274f05a896
commit fabe3ca4ba
2 changed files with 11 additions and 2 deletions

View File

@@ -1215,7 +1215,11 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector {
public void destroy() {
synchronized (mLock) {
if (mAvailability == STATE_KEYPHRASE_ENROLLED) {
stopRecognition();
try {
stopRecognition();
} catch (Exception e) {
Log.i(TAG, "failed to stopRecognition in destroy", e);
}
}
mAvailability = STATE_INVALID;

View File

@@ -30,6 +30,7 @@ import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.SharedMemory;
import android.util.Log;
import android.util.Slog;
import com.android.internal.app.IHotwordRecognitionStatusCallback;
@@ -117,7 +118,11 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector {
@Override
public void destroy() {
stopRecognition();
try {
stopRecognition();
} catch (Exception e) {
Log.i(TAG, "failed to stopRecognition in destroy", e);
}
maybeCloseExistingSession();
try {