Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -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); } } Loading @@ -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) { Loading Loading @@ -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 Loading @@ -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(); } } } } } } Loading core/java/android/service/voice/VoiceInteractionService.java +34 −9 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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; /** /** Loading @@ -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 Loading Loading @@ -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. Loading Loading @@ -349,17 +366,25 @@ public class VoiceInteractionService extends Service { } } private void safelyShutdownHotwordDetector() { private void safelyShutdownHotwordDetector() { try { synchronized (mLock) { synchronized (mLock) { if (mHotwordDetector != null) { if (mHotwordDetector == null) { mHotwordDetector.stopRecognition(); return; mHotwordDetector.invalidate(); mHotwordDetector = null; } } try { mHotwordDetector.stopRecognition(); } catch (Exception ex) { // Ignore. } } try { mHotwordDetector.invalidate(); } catch (Exception ex) { } catch (Exception ex) { // Ignore. // Ignore. } } mHotwordDetector = null; } } } /** /** Loading services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -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); } } Loading @@ -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) { Loading Loading @@ -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 Loading @@ -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(); } } } } } } Loading
core/java/android/service/voice/VoiceInteractionService.java +34 −9 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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; /** /** Loading @@ -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 Loading Loading @@ -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. Loading Loading @@ -349,17 +366,25 @@ public class VoiceInteractionService extends Service { } } private void safelyShutdownHotwordDetector() { private void safelyShutdownHotwordDetector() { try { synchronized (mLock) { synchronized (mLock) { if (mHotwordDetector != null) { if (mHotwordDetector == null) { mHotwordDetector.stopRecognition(); return; mHotwordDetector.invalidate(); mHotwordDetector = null; } } try { mHotwordDetector.stopRecognition(); } catch (Exception ex) { // Ignore. } } try { mHotwordDetector.invalidate(); } catch (Exception ex) { } catch (Exception ex) { // Ignore. // Ignore. } } mHotwordDetector = null; } } } /** /** Loading
services/core/java/com/android/server/soundtrigger_middleware/SoundTriggerMiddlewareValidation.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading