Merge "Merge changes from topic "soundtrigger-hal-error" into rvc-dev am: bf2c076c0c am: 9de51deb54" into rvc-d1-dev-plus-aosp am: f456cdadfb
Change-Id: I02167c3933fd63f6c026b14a63b58c4b60b64cc4
This commit is contained in:
@@ -780,15 +780,16 @@ public class AlwaysOnHotwordDetector {
|
|||||||
audioCapabilities |= AUDIO_CAPABILITY_NOISE_SUPPRESSION;
|
audioCapabilities |= AUDIO_CAPABILITY_NOISE_SUPPRESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = STATUS_ERROR;
|
int code;
|
||||||
try {
|
try {
|
||||||
code = mModelManagementService.startRecognition(
|
code = mModelManagementService.startRecognition(
|
||||||
mKeyphraseMetadata.id, mLocale.toLanguageTag(), mInternalCallback,
|
mKeyphraseMetadata.id, mLocale.toLanguageTag(), mInternalCallback,
|
||||||
new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers,
|
new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers,
|
||||||
recognitionExtra, null /* additional data */, audioCapabilities));
|
recognitionExtra, null /* additional data */, audioCapabilities));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "RemoteException in startRecognition!", e);
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != STATUS_OK) {
|
if (code != STATUS_OK) {
|
||||||
Slog.w(TAG, "startRecognition() failed with error code " + code);
|
Slog.w(TAG, "startRecognition() failed with error code " + code);
|
||||||
}
|
}
|
||||||
@@ -796,12 +797,12 @@ public class AlwaysOnHotwordDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int stopRecognitionLocked() {
|
private int stopRecognitionLocked() {
|
||||||
int code = STATUS_ERROR;
|
int code;
|
||||||
try {
|
try {
|
||||||
code = mModelManagementService.stopRecognition(mKeyphraseMetadata.id,
|
code = mModelManagementService.stopRecognition(mKeyphraseMetadata.id,
|
||||||
mInternalCallback);
|
mInternalCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "RemoteException in stopRecognition!", e);
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != STATUS_OK) {
|
if (code != STATUS_OK) {
|
||||||
@@ -968,12 +969,12 @@ public class AlwaysOnHotwordDetector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleProperties dspModuleProperties = null;
|
ModuleProperties dspModuleProperties;
|
||||||
try {
|
try {
|
||||||
dspModuleProperties =
|
dspModuleProperties =
|
||||||
mModelManagementService.getDspModuleProperties();
|
mModelManagementService.getDspModuleProperties();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "RemoteException in getDspProperties!", e);
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No DSP available
|
// No DSP available
|
||||||
@@ -989,7 +990,7 @@ public class AlwaysOnHotwordDetector {
|
|||||||
mKeyphraseMetadata = mModelManagementService.getEnrolledKeyphraseMetadata(
|
mKeyphraseMetadata = mModelManagementService.getEnrolledKeyphraseMetadata(
|
||||||
mText, mLocale.toLanguageTag());
|
mText, mLocale.toLanguageTag());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "RemoteException in internalUpdateEnrolledKeyphraseMetadata", e);
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.app.IVoiceActionCheckCallback;
|
import com.android.internal.app.IVoiceActionCheckCallback;
|
||||||
@@ -47,6 +48,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +65,8 @@ import java.util.Set;
|
|||||||
* separate process from this one.
|
* separate process from this one.
|
||||||
*/
|
*/
|
||||||
public class VoiceInteractionService extends Service {
|
public class VoiceInteractionService extends Service {
|
||||||
|
static final String TAG = VoiceInteractionService.class.getSimpleName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Intent} that must be declared as handled by the service.
|
* The {@link Intent} that must be declared as handled by the service.
|
||||||
* To be supported, the service must also require the
|
* To be supported, the service must also require the
|
||||||
@@ -240,9 +244,22 @@ public class VoiceInteractionService extends Service {
|
|||||||
public void onReady() {
|
public void onReady() {
|
||||||
mSystemService = IVoiceInteractionManagerService.Stub.asInterface(
|
mSystemService = IVoiceInteractionManagerService.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
|
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
|
||||||
|
Objects.requireNonNull(mSystemService);
|
||||||
|
try {
|
||||||
|
mSystemService.asBinder().linkToDeath(mDeathRecipient, 0);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.wtf(TAG, "unable to link to death with system service");
|
||||||
|
}
|
||||||
mKeyphraseEnrollmentInfo = new KeyphraseEnrollmentInfo(getPackageManager());
|
mKeyphraseEnrollmentInfo = new KeyphraseEnrollmentInfo(getPackageManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBinder.DeathRecipient mDeathRecipient = () -> {
|
||||||
|
Log.e(TAG, "system service binder died shutting down");
|
||||||
|
Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage(
|
||||||
|
VoiceInteractionService::onShutdownInternal, VoiceInteractionService.this));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private void onShutdownInternal() {
|
private void onShutdownInternal() {
|
||||||
onShutdown();
|
onShutdown();
|
||||||
// Stop any active recognitions when shutting down.
|
// Stop any active recognitions when shutting down.
|
||||||
@@ -349,16 +366,24 @@ public class VoiceInteractionService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void safelyShutdownHotwordDetector() {
|
private void safelyShutdownHotwordDetector() {
|
||||||
try {
|
synchronized (mLock) {
|
||||||
synchronized (mLock) {
|
if (mHotwordDetector == null) {
|
||||||
if (mHotwordDetector != null) {
|
return;
|
||||||
mHotwordDetector.stopRecognition();
|
|
||||||
mHotwordDetector.invalidate();
|
|
||||||
mHotwordDetector = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
// Ignore.
|
try {
|
||||||
|
mHotwordDetector.stopRecognition();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mHotwordDetector.invalidate();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
|
||||||
|
mHotwordDetector = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.media.soundtrigger_middleware.SoundModel;
|
|||||||
import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor;
|
import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor;
|
||||||
import android.media.soundtrigger_middleware.Status;
|
import android.media.soundtrigger_middleware.Status;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceSpecificException;
|
import android.os.ServiceSpecificException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -139,6 +140,14 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
|||||||
throw new ServiceSpecificException(((RecoverableException) e).errorCode,
|
throw new ServiceSpecificException(((RecoverableException) e).errorCode,
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Throwing an exception is not enough in this case. When the HAL behaves unexpectedly, the
|
||||||
|
system service and the HAL must be reset and the client must be notified. Without a full
|
||||||
|
reset in this catastrophic case, the state of the HAL and the system service cannot be
|
||||||
|
guaranteed to the client.
|
||||||
|
*/
|
||||||
|
Log.wtf(TAG, "Crashing system server due to unrecoverable exception", e);
|
||||||
|
Process.killProcess(Process.myPid());
|
||||||
throw new InternalServerError(e);
|
throw new InternalServerError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,13 @@ public class SoundTriggerService extends SystemService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBootPhase(int phase) {
|
public void onBootPhase(int phase) {
|
||||||
if (PHASE_SYSTEM_SERVICES_READY == phase) {
|
Slog.d(TAG, "onBootPhase: " + phase + " : " + isSafeMode());
|
||||||
|
if (PHASE_DEVICE_SPECIFIC_SERVICES_READY == phase) {
|
||||||
|
if (isSafeMode()) {
|
||||||
|
Slog.w(TAG, "not enabling SoundTriggerService in safe mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
initSoundTriggerHelper();
|
initSoundTriggerHelper();
|
||||||
mLocalSoundTriggerService.setSoundTriggerHelper(mSoundTriggerHelper);
|
mLocalSoundTriggerService.setSoundTriggerHelper(mSoundTriggerHelper);
|
||||||
} else if (PHASE_THIRD_PARTY_APPS_CAN_START == phase) {
|
} else if (PHASE_THIRD_PARTY_APPS_CAN_START == phase) {
|
||||||
|
|||||||
Reference in New Issue
Block a user