Class ShadowSpeechRecognizerImpl
Prior to Android V, SpeechRecognizer contained all functionality within one class. The ShadowSpeechRecognizer shadow would work correctly to shadow both static and instance functions
of the class. With Android V, the instance of SpeechRecognizer returned from SpeechRecognizer.createSpeechRecognizer(Context) is an instance of SpeechRecognizerProxy which delegates all calls to SpeechRecognizerImpl. We need this shadow in order to intercept function calls
correctly and to ensure that the functionality of ShadowSpeechRecognizer still works in
tests prior to Android V and on Android V+.
Customizations for this implementation:
- Intercept of all needed functions in SpeechRecognizerImpl
- Direct access to functions/variables in SpeechRecognizerImpl via
getDirectAccessors() - Parent shadow class' state is used for state (no custom state)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.robolectric.shadows.ShadowSpeechRecognizer
ShadowSpeechRecognizer.ShadowSpeechRecognizerDirectAccessors, ShadowSpeechRecognizer.ShadowSpeechRecognizerState -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckRecognitionSupport(Intent recognizerIntent, Executor executor, Object supportListener) protected voiddestroy()Returns theShadowSpeechRecognizer.ShadowSpeechRecognizerDirectAccessorsimplementation that can handle direct access to functions/variables of a realSpeechRecognizer.protected voidhandleChangeListener(RecognitionListener listener) Handles changing the listener and allows access to the internal listener to trigger events.protected voidstartListening(Intent recognizerIntent) protected voidtriggerModelDownload(Intent recognizerIntent) Methods inherited from class org.robolectric.shadows.ShadowSpeechRecognizer
createOnDeviceSpeechRecognizer, createSpeechRecognizer, getLastRecognizerIntent, getLatestModelDownloadIntent, getLatestSpeechRecognizer, getState, isDestroyed, isOnDeviceRecognitionAvailable, reset, setIsOnDeviceRecognitionAvailable, triggerOnEndOfSpeech, triggerOnError, triggerOnPartialResults, triggerOnReadyForSpeech, triggerOnResults, triggerOnRmsChanged, triggerSupportError, triggerSupportResult
-
Field Details
-
CLASS_NAME
- See Also:
-
-
Constructor Details
-
ShadowSpeechRecognizerImpl
public ShadowSpeechRecognizerImpl()
-
-
Method Details
-
getDirectAccessors
Description copied from class:ShadowSpeechRecognizerReturns theShadowSpeechRecognizer.ShadowSpeechRecognizerDirectAccessorsimplementation that can handle direct access to functions/variables of a realSpeechRecognizer.Subclasses may override this function to customize access in case they are shadowing a subclass of
SpeechRecognizerthat functions differently than the parent class.- Overrides:
getDirectAccessorsin classShadowSpeechRecognizer
-
destroy
- Overrides:
destroyin classShadowSpeechRecognizer
-
startListening
- Overrides:
startListeningin classShadowSpeechRecognizer
-
handleChangeListener
Description copied from class:ShadowSpeechRecognizerHandles changing the listener and allows access to the internal listener to trigger events.- Overrides:
handleChangeListenerin classShadowSpeechRecognizer
-
checkRecognitionSupport
@RequiresApi(api=33) @Implementation(minSdk=33) protected void checkRecognitionSupport(@Nonnull Intent recognizerIntent, @Nonnull Executor executor, @Nonnull Object supportListener) - Overrides:
checkRecognitionSupportin classShadowSpeechRecognizer
-
triggerModelDownload
- Overrides:
triggerModelDownloadin classShadowSpeechRecognizer
-