Loading core/java/android/service/voice/AbstractDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ abstract class AbstractDetector implements HotwordDetector { mIsDetectorActive = new AtomicBoolean(true); } boolean isSameToken(IBinder token) { if (token == null) { return false; } return mToken == token; } /** * Method to be called for the detector to ready/register itself with underlying system * services. Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -1707,6 +1707,13 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { } } void onDetectorRemoteException() { Message.obtain(mHandler, MSG_DETECTION_ERROR, new HotwordDetectionServiceFailure( HotwordDetectionServiceFailure.ERROR_CODE_REMOTE_EXCEPTION, "Detector remote exception occurs")).sendToTarget(); } class MyHandler extends Handler { MyHandler(@NonNull Looper looper) { super(looper); Loading core/java/android/service/voice/IVoiceInteractionService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -32,4 +32,5 @@ oneway interface IVoiceInteractionService { in IVoiceActionCheckCallback callback); void prepareToShowSession(in Bundle args, int flags); void showSessionFailed(in Bundle args); void detectorRemoteExceptionOccurred(in IBinder token, int detectorType); } core/java/android/service/voice/SoftwareHotwordDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ class SoftwareHotwordDetector extends AbstractDetector { DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } void onDetectorRemoteException() { Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> mCallback.onFailure(new HotwordDetectionServiceFailure( HotwordDetectionServiceFailure.ERROR_CODE_REMOTE_EXCEPTION, "Detector remote exception occurs")))); } @RequiresPermission(RECORD_AUDIO) @Override public boolean startRecognition() throws IllegalDetectorStateException { Loading core/java/android/service/voice/VoiceInteractionService.java +31 −1 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ import android.content.Context; import android.content.Intent; import android.hardware.soundtrigger.KeyphraseEnrollmentInfo; import android.hardware.soundtrigger.SoundTrigger; import android.media.voice.KeyphraseModelManager; import android.media.permission.Identity; import android.media.voice.KeyphraseModelManager; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -180,6 +180,14 @@ public class VoiceInteractionService extends Service { VoiceInteractionService::onShowSessionFailed, VoiceInteractionService.this, args)); } @Override public void detectorRemoteExceptionOccurred(@NonNull IBinder token, int detectorType) { Log.d(TAG, "detectorRemoteExceptionOccurred"); Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onDetectorRemoteException, VoiceInteractionService.this, token, detectorType)); } }; IVoiceInteractionManagerService mSystemService; Loading @@ -192,6 +200,28 @@ public class VoiceInteractionService extends Service { private final Set<HotwordDetector> mActiveDetectors = new ArraySet<>(); private void onDetectorRemoteException(@NonNull IBinder token, int detectorType) { Log.d(TAG, "onDetectorRemoteException for " + HotwordDetector.detectorTypeToString( detectorType)); mActiveDetectors.forEach(detector -> { // TODO: handle normal detector, VQD if (detectorType == HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP && detector instanceof AlwaysOnHotwordDetector) { AlwaysOnHotwordDetector alwaysOnDetector = (AlwaysOnHotwordDetector) detector; if (alwaysOnDetector.isSameToken(token)) { alwaysOnDetector.onDetectorRemoteException(); } } else if (detectorType == HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE && detector instanceof SoftwareHotwordDetector) { SoftwareHotwordDetector softwareDetector = (SoftwareHotwordDetector) detector; if (softwareDetector.isSameToken(token)) { softwareDetector.onDetectorRemoteException(); } } }); } /** * Called when a user has activated an affordance to launch voice assist from the Keyguard. * Loading Loading
core/java/android/service/voice/AbstractDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ abstract class AbstractDetector implements HotwordDetector { mIsDetectorActive = new AtomicBoolean(true); } boolean isSameToken(IBinder token) { if (token == null) { return false; } return mToken == token; } /** * Method to be called for the detector to ready/register itself with underlying system * services. Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -1707,6 +1707,13 @@ public class AlwaysOnHotwordDetector extends AbstractDetector { } } void onDetectorRemoteException() { Message.obtain(mHandler, MSG_DETECTION_ERROR, new HotwordDetectionServiceFailure( HotwordDetectionServiceFailure.ERROR_CODE_REMOTE_EXCEPTION, "Detector remote exception occurs")).sendToTarget(); } class MyHandler extends Handler { MyHandler(@NonNull Looper looper) { super(looper); Loading
core/java/android/service/voice/IVoiceInteractionService.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -32,4 +32,5 @@ oneway interface IVoiceInteractionService { in IVoiceActionCheckCallback callback); void prepareToShowSession(in Bundle args, int flags); void showSessionFailed(in Bundle args); void detectorRemoteExceptionOccurred(in IBinder token, int detectorType); }
core/java/android/service/voice/SoftwareHotwordDetector.java +7 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,13 @@ class SoftwareHotwordDetector extends AbstractDetector { DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } void onDetectorRemoteException() { Binder.withCleanCallingIdentity(() -> mExecutor.execute(() -> mCallback.onFailure(new HotwordDetectionServiceFailure( HotwordDetectionServiceFailure.ERROR_CODE_REMOTE_EXCEPTION, "Detector remote exception occurs")))); } @RequiresPermission(RECORD_AUDIO) @Override public boolean startRecognition() throws IllegalDetectorStateException { Loading
core/java/android/service/voice/VoiceInteractionService.java +31 −1 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ import android.content.Context; import android.content.Intent; import android.hardware.soundtrigger.KeyphraseEnrollmentInfo; import android.hardware.soundtrigger.SoundTrigger; import android.media.voice.KeyphraseModelManager; import android.media.permission.Identity; import android.media.voice.KeyphraseModelManager; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -180,6 +180,14 @@ public class VoiceInteractionService extends Service { VoiceInteractionService::onShowSessionFailed, VoiceInteractionService.this, args)); } @Override public void detectorRemoteExceptionOccurred(@NonNull IBinder token, int detectorType) { Log.d(TAG, "detectorRemoteExceptionOccurred"); Handler.getMain().executeOrSendMessage(PooledLambda.obtainMessage( VoiceInteractionService::onDetectorRemoteException, VoiceInteractionService.this, token, detectorType)); } }; IVoiceInteractionManagerService mSystemService; Loading @@ -192,6 +200,28 @@ public class VoiceInteractionService extends Service { private final Set<HotwordDetector> mActiveDetectors = new ArraySet<>(); private void onDetectorRemoteException(@NonNull IBinder token, int detectorType) { Log.d(TAG, "onDetectorRemoteException for " + HotwordDetector.detectorTypeToString( detectorType)); mActiveDetectors.forEach(detector -> { // TODO: handle normal detector, VQD if (detectorType == HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP && detector instanceof AlwaysOnHotwordDetector) { AlwaysOnHotwordDetector alwaysOnDetector = (AlwaysOnHotwordDetector) detector; if (alwaysOnDetector.isSameToken(token)) { alwaysOnDetector.onDetectorRemoteException(); } } else if (detectorType == HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE && detector instanceof SoftwareHotwordDetector) { SoftwareHotwordDetector softwareDetector = (SoftwareHotwordDetector) detector; if (softwareDetector.isSameToken(token)) { softwareDetector.onDetectorRemoteException(); } } }); } /** * Called when a user has activated an affordance to launch voice assist from the Keyguard. * Loading